Icu 5330 credentials crudl tests (#1219)
* test: 💍 Add credentials CRUDL tests * fix: 🐛 Deleted empty files * test: 💍 Add missing tests for credentials * test: 💍 Revise tests in read-test.js ✅ Closes: ICU-5330
This commit is contained in:
1 parent
2b58e82d6d
commit
f6e1fb0e3b
5 files changed
+615
No files matched your search
@@ -0,0 +1,124 @@
|
||||
import { module, test } from 'qunit';
|
||||
import { visit, currentURL, find, click, fillIn } 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';
|
||||
import { Response } from 'miragejs';
|
||||
|
||||
module(
|
||||
'Acceptance | credential-stores | credentials | create',
|
||||
function (hooks) {
|
||||
setupApplicationTest(hooks);
|
||||
setupMirage(hooks);
|
||||
|
||||
let getCredentialsCount;
|
||||
|
||||
const instances = {
|
||||
scopes: {
|
||||
org: null,
|
||||
project: null,
|
||||
},
|
||||
};
|
||||
|
||||
const urls = {
|
||||
projectScope: null,
|
||||
credentialStores: null,
|
||||
staticCredentialStore: null,
|
||||
credentials: null,
|
||||
newCredential: null,
|
||||
};
|
||||
|
||||
hooks.beforeEach(function () {
|
||||
// Generate resources
|
||||
instances.scopes.org = this.server.create('scope', {
|
||||
type: 'org',
|
||||
scope: { id: 'global', type: 'global' },
|
||||
});
|
||||
instances.scopes.project = this.server.create('scope', {
|
||||
type: 'project',
|
||||
scope: { id: instances.scopes.org.id, type: 'org' },
|
||||
});
|
||||
instances.staticCredentialStore = this.server.create('credential-store', {
|
||||
scope: instances.scopes.project,
|
||||
type: 'static',
|
||||
});
|
||||
// Generate route URLs for resources
|
||||
urls.projectScope = `/scopes/${instances.scopes.project.id}`;
|
||||
urls.credentialStores = `${urls.projectScope}/credential-stores`;
|
||||
urls.staticCredentialStore = `${urls.credentialStores}/${instances.staticCredentialStore.id}`;
|
||||
urls.credentials = `${urls.staticCredentialStore}/credentials`;
|
||||
urls.newCredential = `${urls.staticCredentialStore}/credentials/new`;
|
||||
// Generate resource counter
|
||||
getCredentialsCount = () => {
|
||||
return this.server.schema.credentials.all().models.length;
|
||||
};
|
||||
authenticateSession({});
|
||||
});
|
||||
|
||||
test('Users can create a new credential', async function (assert) {
|
||||
assert.expect(1);
|
||||
const credentialsCount = getCredentialsCount();
|
||||
await visit(urls.newCredential);
|
||||
await fillIn('[name="name"]', 'random string');
|
||||
await click('[type="submit"]');
|
||||
assert.strictEqual(getCredentialsCount(), credentialsCount + 1);
|
||||
});
|
||||
|
||||
test('Users can cancel create new credential', async function (assert) {
|
||||
assert.expect(2);
|
||||
const credentialsCount = getCredentialsCount();
|
||||
await visit(urls.newCredential);
|
||||
await fillIn('[name="name"]', 'random string');
|
||||
await click('.rose-form-actions [type="button"]');
|
||||
assert.strictEqual(currentURL(), urls.credentials);
|
||||
assert.strictEqual(getCredentialsCount(), credentialsCount);
|
||||
});
|
||||
|
||||
test('Users cannot navigate to new credential route without proper authorization', async function (assert) {
|
||||
assert.expect(2);
|
||||
instances.staticCredentialStore.authorized_collection_actions.credentials =
|
||||
[];
|
||||
await visit(urls.staticCredentialStore);
|
||||
assert.notOk(
|
||||
instances.staticCredentialStore.authorized_collection_actions.credentials.includes(
|
||||
'create'
|
||||
)
|
||||
);
|
||||
assert.notOk(find(`[href="${urls.newCredential}"]`));
|
||||
});
|
||||
|
||||
test('saving a new credential with invalid fields displays error messages', async function (assert) {
|
||||
assert.expect(2);
|
||||
this.server.post('/credentials', () => {
|
||||
return new Response(
|
||||
400,
|
||||
{},
|
||||
{
|
||||
status: 400,
|
||||
code: 'invalid_argument',
|
||||
message: 'Error in provided request.',
|
||||
details: {
|
||||
request_fields: [
|
||||
{
|
||||
name: 'attributes.password',
|
||||
description:
|
||||
'Field required for creating a username-password credential.',
|
||||
},
|
||||
],
|
||||
},
|
||||
}
|
||||
);
|
||||
});
|
||||
await visit(urls.newCredential);
|
||||
await click('[type="submit"]');
|
||||
assert.ok(
|
||||
find('[role="alert"]').textContent.trim(),
|
||||
'Error in provided request.'
|
||||
);
|
||||
assert.ok(
|
||||
find('.rose-form-error-message').textContent.trim(),
|
||||
'Field required for creating a username-password credential.'
|
||||
);
|
||||
});
|
||||
}
|
||||
);
|
||||
@@ -0,0 +1,131 @@
|
||||
import { module, test } from 'qunit';
|
||||
import { setupApplicationTest } from 'ember-qunit';
|
||||
import setupMirage from 'ember-cli-mirage/test-support/setup-mirage';
|
||||
import { authenticateSession } from 'ember-simple-auth/test-support';
|
||||
import { click, currentURL, visit, find } from '@ember/test-helpers';
|
||||
import { resolve, reject } from 'rsvp';
|
||||
import sinon from 'sinon';
|
||||
import { Response } from 'miragejs';
|
||||
|
||||
module(
|
||||
'Acceptance | credential-stores | credentials | delete',
|
||||
function (hooks) {
|
||||
setupApplicationTest(hooks);
|
||||
setupMirage(hooks);
|
||||
|
||||
let getCredentialsCount;
|
||||
|
||||
const instances = {
|
||||
scopes: {
|
||||
org: null,
|
||||
project: null,
|
||||
},
|
||||
};
|
||||
|
||||
const urls = {
|
||||
projectScope: null,
|
||||
credentialStores: null,
|
||||
staticCredentialStore: null,
|
||||
credentials: null,
|
||||
credential: null,
|
||||
};
|
||||
|
||||
hooks.beforeEach(function () {
|
||||
// Generate resources
|
||||
instances.scopes.org = this.server.create('scope', {
|
||||
type: 'org',
|
||||
scope: { id: 'global', type: 'global' },
|
||||
});
|
||||
instances.scopes.project = this.server.create('scope', {
|
||||
type: 'project',
|
||||
scope: { id: instances.scopes.org.id, type: 'org' },
|
||||
});
|
||||
instances.staticCredentialStore = this.server.create('credential-store', {
|
||||
scope: instances.scopes.project,
|
||||
type: 'static',
|
||||
});
|
||||
instances.credential = this.server.create('credential', {
|
||||
scope: instances.scopes.project,
|
||||
credentialStore: instances.staticCredentialStore,
|
||||
type: 'username_password',
|
||||
});
|
||||
// Generate route URLs for resources
|
||||
urls.projectScope = `/scopes/${instances.scopes.project.id}`;
|
||||
urls.credentialStores = `${urls.projectScope}/credential-stores`;
|
||||
urls.staticCredentialStore = `${urls.credentialStores}/${instances.staticCredentialStore.id}`;
|
||||
urls.credentials = `${urls.staticCredentialStore}/credentials`;
|
||||
urls.credential = `${urls.credentials}/${instances.credential.id}`;
|
||||
// Generate resource counter
|
||||
getCredentialsCount = () => {
|
||||
return this.server.schema.credentials.all().models.length;
|
||||
};
|
||||
authenticateSession({});
|
||||
});
|
||||
|
||||
test('can delete credential', async function (assert) {
|
||||
assert.expect(2);
|
||||
const credentialsCount = getCredentialsCount();
|
||||
await visit(urls.credential);
|
||||
await click('.rose-layout-page-actions .rose-dropdown-button-danger');
|
||||
assert.strictEqual(currentURL(), urls.credentials);
|
||||
assert.strictEqual(getCredentialsCount(), credentialsCount - 1);
|
||||
});
|
||||
|
||||
test('cannot delete a credential store without proper authorization', async function (assert) {
|
||||
assert.expect(3);
|
||||
const credentialsCount = getCredentialsCount();
|
||||
instances.credential.authorized_actions =
|
||||
instances.credential.authorized_actions.filter(
|
||||
(item) => item !== 'delete'
|
||||
);
|
||||
await visit(urls.credential);
|
||||
assert.strictEqual(currentURL(), urls.credential);
|
||||
assert.notOk(
|
||||
find('.rose-layout-page-actions .rose-dropdown-button-danger')
|
||||
);
|
||||
assert.strictEqual(getCredentialsCount(), credentialsCount);
|
||||
});
|
||||
|
||||
test('can accept delete credential 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 credentialsCount = getCredentialsCount();
|
||||
await visit(urls.credential);
|
||||
await click('.rose-layout-page-actions .rose-dropdown-button-danger');
|
||||
assert.strictEqual(getCredentialsCount(), credentialsCount - 1);
|
||||
assert.ok(confirmService.confirm.calledOnce);
|
||||
});
|
||||
|
||||
test('cannot cancel delete credential 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 credentialsCount = getCredentialsCount();
|
||||
await visit(urls.credential);
|
||||
await click('.rose-layout-page-actions .rose-dropdown-button-danger');
|
||||
assert.strictEqual(getCredentialsCount(), credentialsCount);
|
||||
assert.ok(confirmService.confirm.calledOnce);
|
||||
});
|
||||
|
||||
test('deleting a credential which errors displays error message', async function (assert) {
|
||||
assert.expect(1);
|
||||
this.server.del('/credentials/:id', () => {
|
||||
return new Response(
|
||||
490,
|
||||
{},
|
||||
{
|
||||
status: 490,
|
||||
code: 'error',
|
||||
message: 'Oops.',
|
||||
}
|
||||
);
|
||||
});
|
||||
await visit(urls.credential);
|
||||
await click('.rose-layout-page-actions .rose-dropdown-button-danger');
|
||||
assert.ok(find('[role="alert"]').textContent.trim(), 'Oops.');
|
||||
});
|
||||
}
|
||||
);
|
||||
@@ -0,0 +1,86 @@
|
||||
import { module, test } from 'qunit';
|
||||
import { visit, 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';
|
||||
|
||||
module('Acceptance | credential-stores | credentials | list', function (hooks) {
|
||||
setupApplicationTest(hooks);
|
||||
setupMirage(hooks);
|
||||
|
||||
const instances = {
|
||||
scopes: {
|
||||
org: null,
|
||||
project: null,
|
||||
},
|
||||
};
|
||||
|
||||
const urls = {
|
||||
projectScope: null,
|
||||
credentialStores: null,
|
||||
staticCredentialStore: null,
|
||||
credentials: null,
|
||||
newCredential: null,
|
||||
};
|
||||
|
||||
hooks.beforeEach(function () {
|
||||
// Generate resources
|
||||
instances.scopes.org = this.server.create('scope', {
|
||||
type: 'org',
|
||||
scope: { id: 'global', type: 'global' },
|
||||
});
|
||||
instances.scopes.project = this.server.create('scope', {
|
||||
type: 'project',
|
||||
scope: { id: instances.scopes.org.id, type: 'org' },
|
||||
});
|
||||
instances.staticCredentialStore = this.server.create('credential-store', {
|
||||
scope: instances.scopes.project,
|
||||
type: 'static',
|
||||
});
|
||||
// Generate route URLs for resources
|
||||
urls.projectScope = `/scopes/${instances.scopes.project.id}`;
|
||||
urls.credentialStores = `${urls.projectScope}/credential-stores`;
|
||||
urls.staticCredentialStore = `${urls.credentialStores}/${instances.staticCredentialStore.id}`;
|
||||
urls.credentials = `${urls.staticCredentialStore}/credentials`;
|
||||
urls.newCredential = `${urls.staticCredentialStore}/credentials/new`;
|
||||
authenticateSession({});
|
||||
});
|
||||
|
||||
test('Users can navigate to credentials with proper authorization', async function (assert) {
|
||||
assert.expect(2);
|
||||
await visit(urls.staticCredentialStore);
|
||||
assert.ok(
|
||||
instances.staticCredentialStore.authorized_collection_actions.credentials.includes(
|
||||
'list'
|
||||
)
|
||||
);
|
||||
assert.ok(find(`[href="${urls.credentials}"]`));
|
||||
});
|
||||
|
||||
test('User cannot navigate to index without either list or create action', async function (assert) {
|
||||
assert.expect(3);
|
||||
instances.staticCredentialStore.authorized_collection_actions.credentials =
|
||||
[];
|
||||
await visit(urls.staticCredentialStore);
|
||||
assert.notOk(
|
||||
instances.staticCredentialStore.authorized_collection_actions.credentials.includes(
|
||||
'list'
|
||||
)
|
||||
);
|
||||
assert.notOk(
|
||||
instances.staticCredentialStore.authorized_collection_actions.credentials.includes(
|
||||
'create'
|
||||
)
|
||||
);
|
||||
assert.notOk(find(`[href="${urls.credentials}"]`));
|
||||
});
|
||||
|
||||
test('User can navigate to index with only create action', async function (assert) {
|
||||
assert.expect(2);
|
||||
instances.staticCredentialStore.authorized_collection_actions.credentials =
|
||||
['create'];
|
||||
await visit(urls.staticCredentialStore);
|
||||
assert.ok(find(`[href="${urls.credentials}"]`));
|
||||
assert.ok(find(`.rose-layout-page-actions [href="${urls.newCredential}"]`));
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,90 @@
|
||||
import { module, test } from 'qunit';
|
||||
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';
|
||||
|
||||
module('Acceptance | credential-stores | credentials | read', function (hooks) {
|
||||
setupApplicationTest(hooks);
|
||||
setupMirage(hooks);
|
||||
|
||||
const instances = {
|
||||
scopes: {
|
||||
org: null,
|
||||
project: null,
|
||||
},
|
||||
};
|
||||
|
||||
const urls = {
|
||||
projectScope: null,
|
||||
credentialStores: null,
|
||||
staticCredentialStore: null,
|
||||
credentials: null,
|
||||
credential: null,
|
||||
unknownCredential: null,
|
||||
};
|
||||
|
||||
hooks.beforeEach(function () {
|
||||
// Generate resources
|
||||
instances.scopes.org = this.server.create('scope', {
|
||||
type: 'org',
|
||||
scope: { id: 'global', type: 'global' },
|
||||
});
|
||||
instances.scopes.project = this.server.create('scope', {
|
||||
type: 'project',
|
||||
scope: { id: instances.scopes.org.id, type: 'org' },
|
||||
});
|
||||
instances.staticCredentialStore = this.server.create('credential-store', {
|
||||
scope: instances.scopes.project,
|
||||
type: 'static',
|
||||
});
|
||||
instances.credential = this.server.create('credential', {
|
||||
scope: instances.scopes.project,
|
||||
credentialStore: instances.staticCredentialStore,
|
||||
type: 'username_password',
|
||||
});
|
||||
// Generate route URLs for resources
|
||||
urls.projectScope = `/scopes/${instances.scopes.project.id}`;
|
||||
urls.credentialStores = `${urls.projectScope}/credential-stores`;
|
||||
urls.staticCredentialStore = `${urls.credentialStores}/${instances.staticCredentialStore.id}`;
|
||||
urls.credentials = `${urls.staticCredentialStore}/credentials`;
|
||||
urls.credential = `${urls.credentials}/${instances.credential.id}`;
|
||||
urls.unknownCredential = `${urls.credentials}/foo`;
|
||||
authenticateSession({});
|
||||
});
|
||||
|
||||
test('visiting /credentials', async function (assert) {
|
||||
assert.expect(2);
|
||||
await visit(urls.staticCredentialStore);
|
||||
await click(`[href="${urls.credentials}"]`);
|
||||
await a11yAudit();
|
||||
assert.strictEqual(currentURL(), urls.credentials);
|
||||
await click(`[href="${urls.credential}"]`);
|
||||
await a11yAudit();
|
||||
assert.strictEqual(currentURL(), urls.credential);
|
||||
});
|
||||
|
||||
test('cannot navigate to a credential form without proper authorization', async function (assert) {
|
||||
assert.expect(1);
|
||||
instances.credential.authorized_actions =
|
||||
instances.credential.authorized_actions.filter((item) => item != 'read');
|
||||
await visit(urls.credentials);
|
||||
assert.notOk(find(`[href="${urls.credential}"]`));
|
||||
});
|
||||
|
||||
test('visiting an unknown credential displays 404 message', async function (assert) {
|
||||
assert.expect(1);
|
||||
await visit(urls.unknownCredential);
|
||||
await a11yAudit();
|
||||
assert.ok(find('.rose-message-subtitle').textContent.trim(), 'Error 404');
|
||||
});
|
||||
|
||||
test('Users can link to docs page for credential store', async function (assert) {
|
||||
assert.expect(1);
|
||||
await visit(urls.credential);
|
||||
assert.ok(
|
||||
find(`[href="https://boundaryproject.io/help/admin-ui/credentials"]`)
|
||||
);
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,184 @@
|
||||
import { module, test } from 'qunit';
|
||||
import { visit, currentURL, find, click, fillIn } from '@ember/test-helpers';
|
||||
import { setupApplicationTest } from 'ember-qunit';
|
||||
import setupMirage from 'ember-cli-mirage/test-support/setup-mirage';
|
||||
import { Response } from 'miragejs';
|
||||
import { authenticateSession } from 'ember-simple-auth/test-support';
|
||||
|
||||
module(
|
||||
'Acceptance | credential-stores | credentials | update',
|
||||
function (hooks) {
|
||||
setupApplicationTest(hooks);
|
||||
setupMirage(hooks);
|
||||
|
||||
const instances = {
|
||||
scopes: {
|
||||
global: null,
|
||||
org: null,
|
||||
project: null,
|
||||
},
|
||||
};
|
||||
|
||||
const urls = {
|
||||
projectScope: null,
|
||||
credentialStores: null,
|
||||
staticCredentialStore: null,
|
||||
credentials: null,
|
||||
credential: null,
|
||||
};
|
||||
|
||||
hooks.beforeEach(function () {
|
||||
// Generate resources
|
||||
instances.scopes.global = this.server.create('scope', { id: 'global' });
|
||||
instances.scopes.org = this.server.create('scope', {
|
||||
type: 'org',
|
||||
scope: { id: 'global', type: 'global' },
|
||||
});
|
||||
instances.scopes.project = this.server.create('scope', {
|
||||
type: 'project',
|
||||
scope: { id: instances.scopes.org.id, type: 'org' },
|
||||
});
|
||||
instances.staticCredentialStore = this.server.create('credential-store', {
|
||||
scope: instances.scopes.project,
|
||||
type: 'static',
|
||||
});
|
||||
instances.credential = this.server.create('credential', {
|
||||
scope: instances.scopes.project,
|
||||
credentialStore: instances.staticCredentialStore,
|
||||
type: 'username_password',
|
||||
});
|
||||
// Generate route URLs for resources
|
||||
urls.projectScope = `/scopes/${instances.scopes.project.id}`;
|
||||
urls.credentialStores = `${urls.projectScope}/credential-stores`;
|
||||
urls.staticCredentialStore = `${urls.credentialStores}/${instances.staticCredentialStore.id}`;
|
||||
urls.credentials = `${urls.staticCredentialStore}/credentials`;
|
||||
urls.credential = `${urls.credentials}/${instances.credential.id}`;
|
||||
authenticateSession({});
|
||||
});
|
||||
|
||||
test('can save changes to existing credential', async function (assert) {
|
||||
assert.expect(3);
|
||||
assert.notEqual(instances.credential.name, 'random string');
|
||||
await visit(urls.credential);
|
||||
await click('form [type="button"]', 'Activate edit mode');
|
||||
await fillIn('[name="name"]', 'random string');
|
||||
await click('.rose-form-actions [type="submit"]');
|
||||
assert.strictEqual(currentURL(), urls.credential);
|
||||
assert.strictEqual(
|
||||
this.server.schema.credentials.all().models[0].name,
|
||||
'random string'
|
||||
);
|
||||
});
|
||||
|
||||
test('cannot make changes to an existing credential without proper authorization', async function (assert) {
|
||||
assert.expect(1);
|
||||
instances.credential.authorized_actions =
|
||||
instances.credential.authorized_actions.filter(
|
||||
(item) => item !== 'update'
|
||||
);
|
||||
await visit(urls.credential);
|
||||
assert.notOk(find('.rose-layout-page-actions .rose-button-secondary'));
|
||||
});
|
||||
|
||||
test('can cancel changes to existing credential', async function (assert) {
|
||||
assert.expect(2);
|
||||
await visit(urls.credential);
|
||||
await click('form [type="button"]', 'Activate edit mode');
|
||||
await fillIn('[name="name"]', 'random string');
|
||||
await click('.rose-form-actions [type="button"]');
|
||||
assert.notEqual(instances.credential.name, 'random string');
|
||||
assert.strictEqual(
|
||||
find('[name="name"]').value,
|
||||
instances.credential.name
|
||||
);
|
||||
});
|
||||
|
||||
test('saving an existing credential with invalid fields displays error message', async function (assert) {
|
||||
assert.expect(2);
|
||||
this.server.patch('/credentials/:id', () => {
|
||||
return new Response(
|
||||
400,
|
||||
{},
|
||||
{
|
||||
status: 400,
|
||||
code: 'invalid_argument',
|
||||
message: 'Error in provided request.',
|
||||
details: {
|
||||
request_fields: [
|
||||
{
|
||||
name: 'name',
|
||||
description: 'Name is required.',
|
||||
},
|
||||
],
|
||||
},
|
||||
}
|
||||
);
|
||||
});
|
||||
await visit(urls.credential);
|
||||
await click('form [type="button"]', 'Activate edit mode');
|
||||
await fillIn('[name="name"]', 'random string');
|
||||
await click('[type="submit"]');
|
||||
assert.ok(
|
||||
find('[role="alert"]').textContent.trim(),
|
||||
'Error in provided request.'
|
||||
);
|
||||
assert.ok(
|
||||
find('.rose-form-error-message').textContent.trim(),
|
||||
'Name is required.'
|
||||
);
|
||||
});
|
||||
|
||||
test('can discard unsaved credential changes via dialog', async function (assert) {
|
||||
assert.expect(5);
|
||||
const confirmService = this.owner.lookup('service:confirm');
|
||||
confirmService.enabled = true;
|
||||
assert.notEqual(instances.credential.name, 'random string');
|
||||
await visit(urls.credential);
|
||||
await click('form [type="button"]', 'Activate edit mode');
|
||||
await fillIn('[name="name"]', 'random string');
|
||||
assert.strictEqual(currentURL(), urls.credential);
|
||||
try {
|
||||
await visit(urls.credentials);
|
||||
} catch (e) {
|
||||
assert.ok(find('.rose-dialog'));
|
||||
await click('.rose-dialog-footer button:first-child', 'Click Discard');
|
||||
assert.strictEqual(currentURL(), urls.credentials);
|
||||
assert.notEqual(
|
||||
this.server.schema.credentials.all().models[0].name,
|
||||
'random string'
|
||||
);
|
||||
}
|
||||
});
|
||||
|
||||
test('can cancel discard unsaved credential changes via dialog', async function (assert) {
|
||||
assert.expect(5);
|
||||
const confirmService = this.owner.lookup('service:confirm');
|
||||
confirmService.enabled = true;
|
||||
assert.notEqual(instances.credential.name, 'random string');
|
||||
await visit(urls.credential);
|
||||
await click('form [type="button"]', 'Activate edit mode');
|
||||
await fillIn('[name="name"]', 'random string');
|
||||
assert.strictEqual(currentURL(), urls.credential);
|
||||
try {
|
||||
await visit(urls.credentials);
|
||||
} catch (e) {
|
||||
assert.ok(find('.rose-dialog'));
|
||||
await click('.rose-dialog-footer button:last-child', 'Click Cancel');
|
||||
assert.strictEqual(currentURL(), urls.credential);
|
||||
assert.notEqual(
|
||||
this.server.schema.credentials.all().models[0].name,
|
||||
'random string'
|
||||
);
|
||||
}
|
||||
});
|
||||
|
||||
test('password field renders in edit mode only for a credential', async function (assert) {
|
||||
assert.expect(3);
|
||||
await visit(urls.credential);
|
||||
assert.notOk(find('[name="password"]'));
|
||||
await click('form [type="button"]', 'Activate edit mode');
|
||||
assert.strictEqual(currentURL(), urls.credential);
|
||||
assert.ok(find('[name="password"]'));
|
||||
});
|
||||
}
|
||||
);
|
||||
Reference in new issue
Block a user