From a91cbaf231abac6d07e042938ad43441997a3021 Mon Sep 17 00:00:00 2001 From: lisbet-alvarez <107949262+lisbet-alvarez@users.noreply.github.com> Date: Wed, 2 Nov 2022 11:11:02 -0700 Subject: [PATCH] =?UTF-8?q?refactor:=20=F0=9F=92=A1=20host=20set=20read=20?= =?UTF-8?q?acceptance=20tests=20(#1402)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * refactor: 💡 host set read acceptance tests ✅ Closes: ICU-6546 --- .../host-catalogs/host-sets/read-test.js | 41 ++++++++++++++----- 1 file changed, 30 insertions(+), 11 deletions(-) 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 56c535666..120d046e3 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 @@ -1,5 +1,5 @@ import { module, test } from 'qunit'; -import { visit, currentURL, find } from '@ember/test-helpers'; +import { visit, currentURL, click } from '@ember/test-helpers'; import { setupApplicationTest } from 'ember-qunit'; import setupMirage from 'ember-cli-mirage/test-support/setup-mirage'; import a11yAudit from 'ember-a11y-testing/test-support/audit'; @@ -19,10 +19,11 @@ module('Acceptance | host-catalogs | host sets | read', function (hooks) { global: null, org: null, project: null, - hostCatalog: null, - host: null, }, + hostCatalog: null, + hostSet: null, }; + const urls = { globalScope: null, orgScope: null, @@ -32,7 +33,6 @@ module('Acceptance | host-catalogs | host sets | read', function (hooks) { hostSets: null, hostSet: null, unknownHostSet: null, - newHostSet: null, }; hooks.beforeEach(function () { @@ -62,8 +62,7 @@ module('Acceptance | host-catalogs | host sets | read', function (hooks) { urls.hostSets = `${urls.hostCatalog}/host-sets`; urls.hostSet = `${urls.hostSets}/${instances.hostSet.id}`; urls.unknownHostSet = `${urls.hostSets}/foo`; - urls.newHostSet = `${urls.hostSets}/new`; - // Generate resource couner + authenticateSession({}); }); @@ -72,23 +71,43 @@ module('Acceptance | host-catalogs | host sets | read', function (hooks) { await visit(urls.hostSets); await a11yAudit(); assert.strictEqual(currentURL(), urls.hostSets); - await visit(urls.hostSet); + + await click(`[href="${urls.hostSet}"]`); await a11yAudit(); + assert.strictEqual(currentURL(), urls.hostSet); }); test('cannot navigate to a host set form without proper authorization', async function (assert) { assert.expect(1); + await visit(urls.hostCatalog); instances.hostSet.authorized_actions = instances.hostSet.authorized_actions.filter((item) => item !== 'read'); - await visit(urls.hostSet); - assert.notOk(find('main tbody .rose-table-header-cell:nth-child(1) a')); + + await click(`[href="${urls.hostSets}"]`); + + assert.dom(`[href="${urls.hostSet}"]`).doesNotExist(); }); test('visiting an unknown host set displays 404 message', async function (assert) { - assert.expect(1); + assert.expect(2); + await visit(urls.hostSets); + assert.dom(`[href="${urls.unknownHostSet}"]`).doesNotExist(); + await visit(urls.unknownHostSet); await a11yAudit(); - assert.ok(find('.rose-message-subtitle').textContent.trim(), 'Error 404'); + + assert.dom('.rose-message-subtitle').hasText('Error 404'); + }); + + test('users can link to docs page for host sets', async function (assert) { + assert.expect(1); + await visit(urls.hostSets); + + await click(`[href="${urls.hostSet}"]`); + + assert + .dom(`[href="https://boundaryproject.io/help/admin-ui/host-sets"]`) + .exists(); }); });