diff --git a/ui/tests/acceptance/sync/secrets/overview-test.js b/ui/tests/acceptance/sync/secrets/overview-test.js index c634ec5f5e..1919880260 100644 --- a/ui/tests/acceptance/sync/secrets/overview-test.js +++ b/ui/tests/acceptance/sync/secrets/overview-test.js @@ -168,11 +168,6 @@ module('Acceptance | sync | overview', function (hooks) { await loginNs('admin/foo'); }); - hooks.afterEach(async function () { - await visit('vault/dashboard'); - await runCmd([`delete admin/sys/namespaces/foo -f`, deleteNS('admin')]); - }); - test('it should make activation-flag requests to correct namespace', async function (assert) { assert.expect(3); @@ -201,14 +196,25 @@ module('Acceptance | sync | overview', function (hooks) { await click(ts.overview.activationModal.checkbox); await click(ts.overview.activationModal.confirm); - // During the afterEach hook cleanup endpoint is hit again which increases the assertion count (above) - // Re-stub here without the assertion to prep for namespace cleanup. - this.server.get('/sys/activation-flags', (_, req) => req.passthrough()); + // During the namespace cleanup in the afterEach hook this endpoint is hit again which increases the assertion count (above) + // Re-stub here without the assertion to reduce unnecessary assertions. + this.server.get('/sys/activation-flags', () => { + return { + data: { + activated: ['secrets-sync'], + unactivated: [], + }, + }; + }); + await visit('vault/dashboard'); + await runCmd([`delete admin/sys/namespaces/foo -f`, deleteNS('admin')]); }); test('it should make activation-flag requests to correct namespace when managed', async function (assert) { assert.expect(3); - this.owner.lookup('service:flags').featureFlags = ['VAULT_CLOUD_ADMIN_NAMESPACE']; + + const flagService = this.owner.lookup('service:flags'); + flagService.featureFlags = ['VAULT_CLOUD_ADMIN_NAMESPACE']; this.server.get('/sys/activation-flags', (_, req) => { assert.deepEqual(req.requestHeaders, {}, 'Request is unauthenticated and in root namespace'); @@ -236,9 +242,25 @@ module('Acceptance | sync | overview', function (hooks) { await click(ts.overview.activationModal.checkbox); await click(ts.overview.activationModal.confirm); - // During the afterEach hook this endpoint is hit again which increases the assertion count (above) - // Re-stub here without the assertion to prep for namespace cleanup. - this.server.get('/sys/activation-flags', (_, req) => req.passthrough()); + // During the namespace cleanup in the afterEach hook this endpoint is hit again which increases the assertion count (above) + // Re-stub here without the assertion to reduce unnecessary assertions. + this.server.get('/sys/activation-flags', () => { + return { + data: { + activated: ['secrets-sync'], + unactivated: [], + }, + }; + }); + + // Delete the admin/foo namespace + await visit('vault/dashboard'); + await runCmd([deleteNS('foo')]); + + // Reset the HVD feature flag so that we can delete the admin namespace + flagService.featureFlags = []; + await login(); + await runCmd([deleteNS('admin')]); }); }); });