From 2eb7084643ef0ae01430e70a57d68dd7e8ee07a8 Mon Sep 17 00:00:00 2001 From: Carlos Alcaide Date: Wed, 21 Jul 2021 13:31:48 -0700 Subject: [PATCH] =?UTF-8?q?test:=20=F0=9F=92=8D=20Adding=20acceptance=20te?= =?UTF-8?q?st=20for=20delete=20CRUD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Add acceptance test for delete CRUD operation in credential stores --- .../acceptance/credential-stores-test.js | 52 +++++++++++++++++++ 1 file changed, 52 insertions(+) diff --git a/ui/admin/tests/acceptance/credential-stores-test.js b/ui/admin/tests/acceptance/credential-stores-test.js index f41d31a12..53c98d274 100644 --- a/ui/admin/tests/acceptance/credential-stores-test.js +++ b/ui/admin/tests/acceptance/credential-stores-test.js @@ -5,6 +5,8 @@ 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 { Response } from 'miragejs'; +import { resolve, reject } from 'rsvp'; +import sinon from 'sinon'; module('Acceptance | credential-stores', function (hooks) { setupApplicationTest(hooks); @@ -236,4 +238,54 @@ module('Acceptance | credential-stores', function (hooks) { ); } }); + + test('can delete credential store', async function (assert) { + assert.expect(1); + const count = getCredentialStoresCount(); + await visit(urls.credentialStore); + await click('.rose-layout-page-actions .rose-dropdown-button-danger'); + assert.equal(getCredentialStoresCount(), count - 1); + }); + + test('can accept delete credential store via dialog', async function (assert) { + assert.expect(2); + const confirmService = this.owner.lookup('service:confirm'); + confirmService.enabled = true; + confirmService.confirm = sinon.fake.returns(resolve()); + const count = getCredentialStoresCount(); + await visit(urls.credentialStore); + await click('.rose-layout-page-actions .rose-dropdown-button-danger'); + assert.equal(getCredentialStoresCount(), count - 1); + assert.ok(confirmService.confirm.calledOnce); + }); + + test('cannot cancel delete credential store via dialog', async function (assert) { + assert.expect(2); + const confirmService = this.owner.lookup('service:confirm'); + confirmService.enabled = true; + confirmService.confirm = sinon.fake.returns(reject()); + const count = getCredentialStoresCount(); + await visit(urls.credentialStore); + await click('.rose-layout-page-actions .rose-dropdown-button-danger'); + assert.equal(getCredentialStoresCount(), count); + assert.ok(confirmService.confirm.calledOnce); + }); + + test('deleting a host catalog which errors displays error messages', async function (assert) { + assert.expect(1); + this.server.del('/credential-stores/:id', () => { + return new Response( + 490, + {}, + { + status: 490, + code: 'error', + message: 'Oops.', + } + ); + }); + await visit(urls.credentialStore); + await click('.rose-layout-page-actions .rose-dropdown-button-danger'); + assert.ok(find('[role="alert"]').textContent.trim(), 'Oops.'); + }); });