From e8a3650fbed07b650be6d5f6a544380ffd0b2e68 Mon Sep 17 00:00:00 2001 From: lisbet-alvarez <107949262+lisbet-alvarez@users.noreply.github.com> Date: Mon, 28 Nov 2022 14:44:34 -0800 Subject: [PATCH] =?UTF-8?q?refactor:=20=F0=9F=92=A1=20adjust=20css=20selec?= =?UTF-8?q?tor=20for=20specific=20asserts=20(#1468)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * refactor: 💡 adjust css selector for specific asserts ✅ Closes: ICU-6889 * refactor: 💡 small update * refactor: 💡 selectors for .doesNotExist() * Update addons/core/tests/integration/helpers/relative-datetime-live-test.js Co-authored-by: Cameron Perera --- .../acceptance/credential-store/credentials/list-test.js | 2 +- .../acceptance/credential-store/credentials/read-test.js | 4 ++-- ui/admin/tests/acceptance/credential-store/read-test.js | 8 +++----- .../tests/acceptance/host-catalogs/host-sets/read-test.js | 6 ++---- .../tests/acceptance/host-catalogs/hosts/read-test.js | 6 ++---- ui/admin/tests/acceptance/host-catalogs/list-test.js | 6 +++--- ui/admin/tests/acceptance/host-catalogs/read-test.js | 6 ++---- ui/admin/tests/acceptance/host-catalogs/update-test.js | 4 +--- ui/admin/tests/acceptance/sessions-test.js | 5 ++++- .../targets/brokered-credential-sources-test.js | 2 +- .../injected-application-credential-sources-test.js | 5 ++--- ui/admin/tests/acceptance/targets/read-test.js | 8 +++----- 12 files changed, 26 insertions(+), 36 deletions(-) diff --git a/ui/admin/tests/acceptance/credential-store/credentials/list-test.js b/ui/admin/tests/acceptance/credential-store/credentials/list-test.js index 29bcc2810..84e10e605 100644 --- a/ui/admin/tests/acceptance/credential-store/credentials/list-test.js +++ b/ui/admin/tests/acceptance/credential-store/credentials/list-test.js @@ -90,7 +90,7 @@ module('Acceptance | credential-stores | credentials | list', function (hooks) { 'create' ) ); - assert.dom(`[href="${urls.credentials}"]`).doesNotExist(); + assert.dom('.rose-nav-tabs a:nth-child(2)').doesNotExist(); }); test('User can navigate to index with only create action', async function (assert) { diff --git a/ui/admin/tests/acceptance/credential-store/credentials/read-test.js b/ui/admin/tests/acceptance/credential-store/credentials/read-test.js index 91bdd9479..ff67baa3d 100644 --- a/ui/admin/tests/acceptance/credential-store/credentials/read-test.js +++ b/ui/admin/tests/acceptance/credential-store/credentials/read-test.js @@ -93,7 +93,7 @@ module('Acceptance | credential-stores | credentials | read', function (hooks) { (item) => item != 'read' ); await visit(urls.credentials); - assert.dom(`[href="${urls.usernamePasswordCredential}"]`).doesNotExist(); + assert.dom('.rose-table-body tr:first-child a').doesNotExist(); }); test('cannot navigate to a username & key pair credential form without proper authorization', async function (assert) { @@ -103,7 +103,7 @@ module('Acceptance | credential-stores | credentials | read', function (hooks) { (item) => item != 'read' ); await visit(urls.credentials); - assert.dom(`[href="${urls.usernameKeyPairCredential}"]`).doesNotExist(); + assert.dom('.rose-table-body tr:nth-child(2) a').doesNotExist(); }); test('visiting an unknown credential displays 404 message', async function (assert) { diff --git a/ui/admin/tests/acceptance/credential-store/read-test.js b/ui/admin/tests/acceptance/credential-store/read-test.js index bf252adde..05ae717cf 100644 --- a/ui/admin/tests/acceptance/credential-store/read-test.js +++ b/ui/admin/tests/acceptance/credential-store/read-test.js @@ -93,7 +93,7 @@ module('Acceptance | credential-stores | read', function (hooks) { await click(`[href="${urls.credentialStores}"]`); - assert.dom(`[href="${urls.staticCredentialStore}"]`).doesNotExist(); + assert.dom('.rose-table-body tr:first-child a').doesNotExist(); assert.dom(`[href="${urls.vaultCredentialStore}"]`).exists(); }); @@ -107,14 +107,12 @@ module('Acceptance | credential-stores | read', function (hooks) { await click(`[href="${urls.credentialStores}"]`); - assert.dom(`[href="${urls.vaultCredentialStore}"]`).doesNotExist(); + assert.dom('.rose-table-body tr:nth-child(2) a').doesNotExist(); assert.dom(`[href="${urls.staticCredentialStore}"]`).exists(); }); test('visiting an unknown credential store displays 404 message', async function (assert) { - assert.expect(2); - await visit(urls.credentialStores); - assert.dom(`[href="${urls.unknownCredentialStore}"]`).doesNotExist(); + assert.expect(1); await visit(urls.unknownCredentialStore); await a11yAudit(); diff --git a/ui/admin/tests/acceptance/host-catalogs/host-sets/read-test.js b/ui/admin/tests/acceptance/host-catalogs/host-sets/read-test.js index 120d046e3..b3e945ed8 100644 --- a/ui/admin/tests/acceptance/host-catalogs/host-sets/read-test.js +++ b/ui/admin/tests/acceptance/host-catalogs/host-sets/read-test.js @@ -86,13 +86,11 @@ module('Acceptance | host-catalogs | host sets | read', function (hooks) { await click(`[href="${urls.hostSets}"]`); - assert.dom(`[href="${urls.hostSet}"]`).doesNotExist(); + assert.dom('.rose-table-body tr:first-child a').doesNotExist(); }); test('visiting an unknown host set displays 404 message', async function (assert) { - assert.expect(2); - await visit(urls.hostSets); - assert.dom(`[href="${urls.unknownHostSet}"]`).doesNotExist(); + assert.expect(1); await visit(urls.unknownHostSet); await a11yAudit(); diff --git a/ui/admin/tests/acceptance/host-catalogs/hosts/read-test.js b/ui/admin/tests/acceptance/host-catalogs/hosts/read-test.js index b3777e64e..75061483c 100644 --- a/ui/admin/tests/acceptance/host-catalogs/hosts/read-test.js +++ b/ui/admin/tests/acceptance/host-catalogs/hosts/read-test.js @@ -86,13 +86,11 @@ module('Acceptance | host-catalogs | hosts | read', function (hooks) { await click(`[href="${urls.hosts}"]`); - assert.dom(`[href="${urls.host}"]`).doesNotExist(); + assert.dom('.rose-table-body tr:first-child a').doesNotExist(); }); test('visiting an unknown host displays 404 message', async function (assert) { - assert.expect(2); - await visit(urls.hosts); - assert.dom(`[href="${urls.unknownHost}"]`).doesNotExist(); + assert.expect(1); await visit(urls.unknownHost); await a11yAudit(); diff --git a/ui/admin/tests/acceptance/host-catalogs/list-test.js b/ui/admin/tests/acceptance/host-catalogs/list-test.js index 43968e7f7..1b1d0ae81 100644 --- a/ui/admin/tests/acceptance/host-catalogs/list-test.js +++ b/ui/admin/tests/acceptance/host-catalogs/list-test.js @@ -90,8 +90,8 @@ module('Acceptance | host-catalogs | list', function (hooks) { ].includes('create') ); assert - .dom(`nav:nth-child(2) a[href="${urls.hostCatalogs}"]`) - .doesNotExist(); + .dom('[title="Resources"] a:nth-of-type(3)') + .doesNotIncludeText('Host Catalogs'); }); test('user can navigate to index with only create action', async function (assert) { @@ -118,7 +118,7 @@ module('Acceptance | host-catalogs | list', function (hooks) { await click(`[href="${urls.hostCatalogs}"]`); - assert.dom(`nav:nth-child(2) a[href="${urls.hostCatalog}"]`).doesNotExist(); + assert.dom('.rose-table-body tr:first-child a').doesNotExist(); }); test('user can navigate to index with only list action', async function (assert) { diff --git a/ui/admin/tests/acceptance/host-catalogs/read-test.js b/ui/admin/tests/acceptance/host-catalogs/read-test.js index 56779ac35..980763627 100644 --- a/ui/admin/tests/acceptance/host-catalogs/read-test.js +++ b/ui/admin/tests/acceptance/host-catalogs/read-test.js @@ -78,13 +78,11 @@ module('Acceptance | host-catalogs | read', function (hooks) { await click(`[href="${urls.hostCatalogs}"]`); - assert.dom(`[href="${urls.hostCatalog}"]`).doesNotExist(); + assert.dom('.rose-table-body tr:first-child a').doesNotExist(); }); test('visiting an unknown host catalog displays 404 message', async function (assert) { - assert.expect(2); - await visit(urls.hostCatalogs); - assert.dom(`[href="${urls.unknownHostCatalog}"]`).doesNotExist(); + assert.expect(1); await visit(urls.unknownHostCatalog); await a11yAudit(); diff --git a/ui/admin/tests/acceptance/host-catalogs/update-test.js b/ui/admin/tests/acceptance/host-catalogs/update-test.js index e90c78916..680fd9e49 100644 --- a/ui/admin/tests/acceptance/host-catalogs/update-test.js +++ b/ui/admin/tests/acceptance/host-catalogs/update-test.js @@ -79,9 +79,7 @@ module('Acceptance | host-catalogs | update', function (hooks) { await click(`[href="${urls.hostCatalog}"]`); - assert - .dom('.rose-layout-page-actions .rose-button-secondary') - .doesNotExist(); + assert.dom('form [type="button"]').doesNotExist(); }); test('clicking cancel in edit mode does not save changes', async function (assert) { diff --git a/ui/admin/tests/acceptance/sessions-test.js b/ui/admin/tests/acceptance/sessions-test.js index cc2a8297b..1e17d7eaa 100644 --- a/ui/admin/tests/acceptance/sessions-test.js +++ b/ui/admin/tests/acceptance/sessions-test.js @@ -94,7 +94,10 @@ module('Acceptance | sessions', function (hooks) { 'list' ) ); - assert.dom(`[href="${urls.sessions}"]`).doesNotExist(); + + assert + .dom('[title="Resources"] a:first-of-type') + .doesNotIncludeText('Sessions'); }); test('users can navigate to sessions with proper authorization', async function (assert) { diff --git a/ui/admin/tests/acceptance/targets/brokered-credential-sources-test.js b/ui/admin/tests/acceptance/targets/brokered-credential-sources-test.js index 1aba8e936..84f4048a4 100644 --- a/ui/admin/tests/acceptance/targets/brokered-credential-sources-test.js +++ b/ui/admin/tests/acceptance/targets/brokered-credential-sources-test.js @@ -236,7 +236,7 @@ module('Acceptance | targets | brokered credential sources', function (hooks) { (item) => item !== 'add-credential-sources' ); await visit(urls.brokeredCredentialSources); - assert.dom(`[href="${urls.addBrokeredCredentialSources}"]`).doesNotExist(); + assert.dom('.rose-dropdown-content a:nth-child(2)').doesNotExist(); }); test('can select and cancel credential sources to add', async function (assert) { diff --git a/ui/admin/tests/acceptance/targets/injected-application-credential-sources-test.js b/ui/admin/tests/acceptance/targets/injected-application-credential-sources-test.js index 2f4e3f8ec..fed2a6956 100644 --- a/ui/admin/tests/acceptance/targets/injected-application-credential-sources-test.js +++ b/ui/admin/tests/acceptance/targets/injected-application-credential-sources-test.js @@ -264,9 +264,8 @@ module( (item) => item !== 'add-credential-sources' ); await visit(urls.injectedApplicationCredentialSources); - assert - .dom(`[href="${urls.addInjectedApplicationCredentialSources}"]`) - .doesNotExist(); + + assert.dom('.rose-dropdown-content a:nth-child(2)').doesNotExist(); }); test('can select and cancel credential sources to add', async function (assert) { diff --git a/ui/admin/tests/acceptance/targets/read-test.js b/ui/admin/tests/acceptance/targets/read-test.js index 399d6966a..5eaaba87a 100644 --- a/ui/admin/tests/acceptance/targets/read-test.js +++ b/ui/admin/tests/acceptance/targets/read-test.js @@ -94,7 +94,7 @@ module('Acceptance | targets | read', function (hooks) { await click(`[href="${urls.targets}"]`); - assert.dom(`[href="${urls.sshTarget}"]`).doesNotExist(); + assert.dom('.rose-table-body tr:first-child a').doesNotExist(); assert.dom(`[href="${urls.tcpTarget}"]`).exists(); }); @@ -106,14 +106,12 @@ module('Acceptance | targets | read', function (hooks) { await click(`[href="${urls.targets}"]`); - assert.dom(`[href="${urls.tcpTarget}"]`).doesNotExist(); + assert.dom('.rose-table-body tr:nth-child(2) a').doesNotExist(); assert.dom(`[href="${urls.sshTarget}"]`).exists(); }); test('visiting an unknown target displays 404 message', async function (assert) { - assert.expect(2); - await visit(urls.targets); - assert.dom(`[href="${urls.unknownTarget}"]`).doesNotExist(); + assert.expect(1); await visit(urls.unknownTarget); await a11yAudit();