vault/ui/tests/integration/components/sync/sync-header-test.js
Angel Garbarino 927da859f7
UI Hide Secrets Sync from nav if not on license and/or no policy permissions (#27262)
* intial changes, haven't tested client counts or done test coverage

* client count rename getter to clairfy

* fix has-permission api-paths

* wip

* wip

* fix: explicitly refresh vault.cluster model to re-fetch activatedFeatures after actication

* tests: fix # of assertions for verifying that activation was called

* tests: tidy overview-test

* add additional api permission path and move fetch back to application

* add test coverage for the service

* cleanup

* remove test that checked for upsell without license or on community

* small comment change

* welp missed component getter

* flaky test fix

* flaky test

* small nit changes from pr reviews

* add defaults to sync mirage handler

* Gate sync overview route for users without access (#27320)

* routes: add redirect if user does not have access to sync

* tests: verify redirect on sync overview page happens

* tests: organize tests modules to ensure enterprise is explicitly set up

* add type enterprise required now because we do a check for this first

* fix oss test

---------

Co-authored-by: Noelle Daley <noelledaley@users.noreply.github.com>
2024-06-11 08:20:01 -06:00

76 lines
2.3 KiB
JavaScript

/**
* Copyright (c) HashiCorp, Inc.
* SPDX-License-Identifier: BUSL-1.1
*/
import { module, test } from 'qunit';
import { setupRenderingTest } from 'ember-qunit';
import { setupEngine } from 'ember-engines/test-support';
import hbs from 'htmlbars-inline-precompile';
import { render } from '@ember/test-helpers';
import { PAGE } from 'vault/tests/helpers/sync/sync-selectors';
const { title, breadcrumb } = PAGE;
module('Integration | Component | sync | SyncHeader', function (hooks) {
setupRenderingTest(hooks);
setupEngine(hooks, 'sync');
hooks.beforeEach(function () {
this.version = this.owner.lookup('service:version');
this.flags = this.owner.lookup('service:flags');
this.title = 'Secrets Sync';
this.renderComponent = () => {
return render(hbs`<SyncHeader @title={{this.title}} @breadcrumbs={{this.breadcrumbs}} />`, {
owner: this.engine,
});
};
});
test('it should render breadcrumbs', async function (assert) {
this.breadcrumbs = [{ label: 'Destinations', route: 'destinations' }];
await this.renderComponent();
assert.dom(breadcrumb).includesText('Destinations', 'renders breadcrumb');
});
module('ent', function (hooks) {
hooks.beforeEach(async function () {
this.version.type = 'enterprise';
});
test('it should render title if license has secrets sync feature', async function (assert) {
this.version.features = ['Secrets Sync'];
await this.renderComponent();
assert.dom(title).hasText('Secrets Sync');
});
});
module('managed', function (hooks) {
hooks.beforeEach(function () {
this.version.type = 'enterprise';
this.flags.featureFlags = ['VAULT_CLOUD_ADMIN_NAMESPACE'];
});
test('it should render title and plus badge', async function (assert) {
await this.renderComponent();
assert.dom(title).hasText('Secrets Sync Plus feature');
});
});
test('it should yield actions block', async function (assert) {
await render(
hbs`
<SyncHeader @title={{this.title}} @breadcrumbs={{this.breadcrumbs}}>
<:actions>
<span data-test-action-block>Test</span>
</:actions>
</SyncHeader>
`,
{ owner: this.engine }
);
assert.dom('[data-test-action-block]').exists('Component yields block for actions');
});
});