From 9c93ff6c131d531c640da3e6f02e2ba28833841d Mon Sep 17 00:00:00 2001 From: Carlos Alcaide Date: Fri, 16 Jul 2021 13:55:33 -0700 Subject: [PATCH] =?UTF-8?q?test:=20=F0=9F=92=8D=20Add=20test=20cases=20to?= =?UTF-8?q?=20credential=20stores=20route?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Add new test cases to credential stores route --- .../acceptance/credential-stores-test.js | 30 +++++++++++++++++-- 1 file changed, 28 insertions(+), 2 deletions(-) diff --git a/ui/admin/tests/acceptance/credential-stores-test.js b/ui/admin/tests/acceptance/credential-stores-test.js index b62c0f3fe..4a8f46177 100644 --- a/ui/admin/tests/acceptance/credential-stores-test.js +++ b/ui/admin/tests/acceptance/credential-stores-test.js @@ -1,13 +1,16 @@ import { module, test } from 'qunit'; -import { visit, currentURL } from '@ember/test-helpers'; +import { visit, currentURL, click, fillIn } 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'; module('Acceptance | credential-stores', function (hooks) { setupApplicationTest(hooks); setupMirage(hooks); + let getCredentialStoresCount; + const instances = { scopes: { global: null, @@ -32,17 +35,40 @@ module('Acceptance | credential-stores', function (hooks) { type: 'project', scope: { id: instances.scopes.org.id, type: 'org' }, }); + instances.credentialStore = this.server.create('credential-store', { + scope: instances.scopes.project, + }); // Generate route URLs for resources urls.globalScope = `/scopes/global/scopes`; urls.orgScope = `/scopes/${instances.scopes.org.id}/scopes`; urls.projectScope = `/scopes/${instances.scopes.project.id}`; urls.credentialStores = `${urls.projectScope}/credential-stores`; + urls.credentialStore = `${urls.credentialStores}/${instances.credentialStore.id}`; + urls.unknownCredentialStore = `${urls.credentialStores}/foo`; + urls.newCredentialStore = `${urls.credentialStores}/new`; + // Generate resource counter + getCredentialStoresCount = () => { + return this.server.schema.credentialStores.all().models.length; + }; + authenticateSession({}); }); test('visiting /credential-stores', async function (assert) { - assert.expect(1); + assert.expect(2); await visit(urls.credentialStores); await a11yAudit(); assert.equal(currentURL(), urls.credentialStores); + await visit(urls.credentialStore); + await a11yAudit(); + assert.equal(currentURL(), urls.credentialStore); + }); + + test('can create a new credential store', async function (assert) { + assert.expect(1); + const count = getCredentialStoresCount(); + await visit(urls.newCredentialStore); + await fillIn('[name="name"]', 'random string'); + await click('[type="submit"]'); + assert.equal(getCredentialStoresCount(), count + 1); }); });