UI: Fix flaky secrets-sync test with optional chaining (#31176)

* UI: Fix flaky secrets-sync test with optional chaining

* resolve timing issues by moving cleanup directly to test and stubbing endpoint instead of relying on req.passthrough()

* Revert "UI: Fix flaky secrets-sync test with optional chaining"

This reverts commit 3e170db4a3.

* add data wrappers & reset hvd flag before deleting the admin namespace

---------

Co-authored-by: claire bontempo <cbontempo@hashicorp.com>
This commit is contained in:
Shannon Roberts (Beagin) 2025-07-02 16:31:02 -07:00 committed by GitHub
parent eee353e40b
commit 0ee8d99d9c
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -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')]);
});
});
});