From 0bc4cd6e21db5610ff2a33e0ab30e79c531f4250 Mon Sep 17 00:00:00 2001 From: dharini Date: Mon, 26 Jul 2021 16:43:28 -0700 Subject: [PATCH 1/2] =?UTF-8?q?test:=20=F0=9F=92=8D=20add=20cred=20list=20?= =?UTF-8?q?tests?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../credential-library-test.js | 23 ++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/ui/admin/tests/acceptance/credential-library/credential-library-test.js b/ui/admin/tests/acceptance/credential-library/credential-library-test.js index 9faf69576..56cbbdac1 100644 --- a/ui/admin/tests/acceptance/credential-library/credential-library-test.js +++ b/ui/admin/tests/acceptance/credential-library/credential-library-test.js @@ -1,7 +1,8 @@ import { module, test } from 'qunit'; -import { visit, click } from '@ember/test-helpers'; +import { visit, currentURL, find, 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'; import { authenticateSession } from 'ember-simple-auth/test-support'; import { resolve, reject } from 'rsvp'; import sinon from 'sinon'; @@ -29,6 +30,7 @@ module('Acceptance | credential-library', function (hooks) { credentialLibrary: null, credentialLibraries: null, newCredentialLibrary: null, + unknownCredentialLibrary: null, }; hooks.beforeEach(function () { @@ -56,12 +58,31 @@ module('Acceptance | credential-library', function (hooks) { urls.credentialStore = `${urls.credentialStores}/${instances.credentialStore.id}`; urls.credentialLibraries = `${urls.credentialStore}/credential-libraries`; urls.credentialLibrary = `${urls.credentialLibraries}/${instances.credentialLibrary.id}`; + urls.unknownCredentialLibrary = `${urls.credentialLibraries}/foo`; // Generate resource couner getCredentialLibraryCount = () => this.server.schema.credentialLibraries.all().models.length; authenticateSession({}); }); + test('visiting credential-libraries', async function (assert) { + assert.expect(2); + await visit(urls.credentialLibraries); + await a11yAudit(); + assert.equal(currentURL(), urls.credentialLibraries); + await visit(urls.credentialLibrary); + await a11yAudit(); + assert.equal(currentURL(), urls.credentialLibrary); + }); + + test('visiting an unknown credentila library displays 404 message', async function (assert) { + assert.expect(1); + await visit(urls.unknownCredentialLibrary); + await a11yAudit(); + console.debug(find('.rose-message-subtitle')); + assert.ok(find('.rose-message-subtitle').textContent.trim(), 'Error 404'); + }); + test('can delete credential library', async function (assert) { assert.expect(1); const count = getCredentialLibraryCount(); From 025ae1bfe2e5887c78d2c7052353e27d370247d1 Mon Sep 17 00:00:00 2001 From: dharini Date: Mon, 26 Jul 2021 16:58:23 -0700 Subject: [PATCH 2/2] =?UTF-8?q?test:=20=F0=9F=92=8D=20Credential=20library?= =?UTF-8?q?=20deletion=20error=20test?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../credential-library-test.js | 20 ++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/ui/admin/tests/acceptance/credential-library/credential-library-test.js b/ui/admin/tests/acceptance/credential-library/credential-library-test.js index 9faf69576..dfab8c002 100644 --- a/ui/admin/tests/acceptance/credential-library/credential-library-test.js +++ b/ui/admin/tests/acceptance/credential-library/credential-library-test.js @@ -1,5 +1,5 @@ import { module, test } from 'qunit'; -import { visit, click } from '@ember/test-helpers'; +import { visit, click, find } from '@ember/test-helpers'; import { setupApplicationTest } from 'ember-qunit'; import setupMirage from 'ember-cli-mirage/test-support/setup-mirage'; import { authenticateSession } from 'ember-simple-auth/test-support'; @@ -93,4 +93,22 @@ module('Acceptance | credential-library', function (hooks) { assert.equal(getCredentialLibraryCount(), count); assert.ok(confirmService.confirm.calledOnce); }); + + test('deleting a credential library which errors displays error messages', async function (assert) { + assert.expect(1); + this.server.del('/credential-libraries/:id', () => { + return new Response( + 490, + {}, + { + status: 490, + code: 'error', + message: 'Oops.', + } + ); + }); + await visit(urls.credentialLibrary); + await click('.rose-layout-page-actions .rose-dropdown-button-danger'); + assert.ok(find('[role="alert"]').textContent.trim(), 'Oops.'); + }); });