mirror of
				https://github.com/optim-enterprises-bv/vault.git
				synced 2025-10-30 18:17:55 +00:00 
			
		
		
		
	UI: stabilize flaky ns test (#25488)
* Add test waiter for namespace fetch * Add waitfor, unskip test * remove comment
This commit is contained in:
		| @@ -7,7 +7,9 @@ import Service, { service } from '@ember/service'; | |||||||
| import { task } from 'ember-concurrency'; | import { task } from 'ember-concurrency'; | ||||||
| import { getRelativePath } from 'core/utils/sanitize-path'; | import { getRelativePath } from 'core/utils/sanitize-path'; | ||||||
| import { tracked } from '@glimmer/tracking'; | import { tracked } from '@glimmer/tracking'; | ||||||
|  | import { buildWaiter } from '@ember/test-waiters'; | ||||||
|  |  | ||||||
|  | const waiter = buildWaiter('namespaces'); | ||||||
| const ROOT_NAMESPACE = ''; | const ROOT_NAMESPACE = ''; | ||||||
| export default class NamespaceService extends Service { | export default class NamespaceService extends Service { | ||||||
|   @service store; |   @service store; | ||||||
| @@ -51,6 +53,7 @@ export default class NamespaceService extends Service { | |||||||
|  |  | ||||||
|   @task({ drop: true }) |   @task({ drop: true }) | ||||||
|   *findNamespacesForUser() { |   *findNamespacesForUser() { | ||||||
|  |     const waiterToken = waiter.beginAsync(); | ||||||
|     // uses the adapter and the raw response here since |     // uses the adapter and the raw response here since | ||||||
|     // models get wiped when switching namespaces and we |     // models get wiped when switching namespaces and we | ||||||
|     // want to keep track of these separately |     // want to keep track of these separately | ||||||
| @@ -78,6 +81,8 @@ export default class NamespaceService extends Service { | |||||||
|       }); |       }); | ||||||
|     } catch (e) { |     } catch (e) { | ||||||
|       //do nothing here |       //do nothing here | ||||||
|  |     } finally { | ||||||
|  |       waiter.endAsync(waiterToken); | ||||||
|     } |     } | ||||||
|   } |   } | ||||||
|  |  | ||||||
|   | |||||||
| @@ -3,8 +3,8 @@ | |||||||
|  * SPDX-License-Identifier: BUSL-1.1 |  * SPDX-License-Identifier: BUSL-1.1 | ||||||
|  */ |  */ | ||||||
|  |  | ||||||
| import { click, settled, visit, fillIn, currentURL } from '@ember/test-helpers'; | import { click, settled, visit, fillIn, currentURL, waitFor } from '@ember/test-helpers'; | ||||||
| import { module, test, skip } from 'qunit'; | import { module, test } from 'qunit'; | ||||||
| import { setupApplicationTest } from 'ember-qunit'; | import { setupApplicationTest } from 'ember-qunit'; | ||||||
| import { runCmd, createNS } from 'vault/tests/helpers/commands'; | import { runCmd, createNS } from 'vault/tests/helpers/commands'; | ||||||
| import authPage from 'vault/tests/pages/auth'; | import authPage from 'vault/tests/pages/auth'; | ||||||
| @@ -28,11 +28,7 @@ module('Acceptance | Enterprise | namespaces', function (hooks) { | |||||||
|     assert.dom('[data-test-namespace-link]').doesNotExist('Additional namespace have been cleared'); |     assert.dom('[data-test-namespace-link]').doesNotExist('Additional namespace have been cleared'); | ||||||
|   }); |   }); | ||||||
|  |  | ||||||
|   // this test is flaky and is intentionally being skipped for now |   test('it shows nested namespaces if you log in with a namespace starting with a /', async function (assert) { | ||||||
|   // after seeing it fail both in CI and locally, an attempt at stabilizing it was made in https://github.com/hashicorp/vault/pull/23867 |  | ||||||
|   // this seemed to make it consistently pass locally while continuing to fail sporadically in CI |  | ||||||
|   // that fix attempt was reverted in favor of skipping until it can be reworked to reliably pass |  | ||||||
|   skip('it shows nested namespaces if you log in with a namespace starting with a /', async function (assert) { |  | ||||||
|     assert.expect(5); |     assert.expect(5); | ||||||
|  |  | ||||||
|     await click('[data-test-namespace-toggle]'); |     await click('[data-test-namespace-toggle]'); | ||||||
| @@ -46,6 +42,7 @@ module('Acceptance | Enterprise | namespaces', function (hooks) { | |||||||
|       const url = `/vault/secrets?namespace=${targetNamespace}`; |       const url = `/vault/secrets?namespace=${targetNamespace}`; | ||||||
|       // this is usually triggered when creating a ns in the form -- trigger a reload of the namespaces manually |       // this is usually triggered when creating a ns in the form -- trigger a reload of the namespaces manually | ||||||
|       await click('[data-test-refresh-namespaces]'); |       await click('[data-test-refresh-namespaces]'); | ||||||
|  |       await waitFor(`[data-test-namespace-link="${targetNamespace}"]`); | ||||||
|       // check that the single namespace "beep" or "boop" not "beep/boop" shows in the toggle display |       // check that the single namespace "beep" or "boop" not "beep/boop" shows in the toggle display | ||||||
|       assert |       assert | ||||||
|         .dom(`[data-test-namespace-link="${targetNamespace}"]`) |         .dom(`[data-test-namespace-link="${targetNamespace}"]`) | ||||||
| @@ -61,7 +58,7 @@ module('Acceptance | Enterprise | namespaces', function (hooks) { | |||||||
|     await authPage.tokenInput('root').submit(); |     await authPage.tokenInput('root').submit(); | ||||||
|     await settled(); |     await settled(); | ||||||
|     await click('[data-test-namespace-toggle]'); |     await click('[data-test-namespace-toggle]'); | ||||||
|  |     await waitFor('[data-test-current-namespace]'); | ||||||
|     assert.dom('[data-test-current-namespace]').hasText('/beep/boop/', 'current namespace begins with a /'); |     assert.dom('[data-test-current-namespace]').hasText('/beep/boop/', 'current namespace begins with a /'); | ||||||
|     assert |     assert | ||||||
|       .dom('[data-test-namespace-link="beep/boop/bop"]') |       .dom('[data-test-namespace-link="beep/boop/bop"]') | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user
	 Chelsea Shaw
					Chelsea Shaw