Merge branch 'main' into chore-radio-template

This commit is contained in:
Randall Morey authored and GitHub committed 2022-02-23 12:29:45 -05:00
commit 05be4c1349
67 files changed
+2043 -494

No files matched your search

@@ -31,6 +31,8 @@ module('Acceptance | host-catalogs | create', function (hooks) {
hostCatalogs: null,
hostCatalog: null,
newHostCatalog: null,
newStaticHostCatalog: null,
newDynamicHostCatalog: null,
};
hooks.beforeEach(function () {
@@ -64,6 +66,8 @@ module('Acceptance | host-catalogs | create', function (hooks) {
urls.hostCatalog = `${urls.hostCatalogs}/${instances.hostCatalog.id}`;
urls.newHostCatalog = `${urls.hostCatalogs}/new`;
urls.newStaticHostCatalog = `${urls.newHostCatalog}?type=static`;
urls.newDynamicHostCatalog = `${urls.newHostCatalog}?type=aws`;
// Generate resource couner
gethostCatalogCount = () =>
this.server.schema.hostCatalogs.all().models.length;
@@ -71,26 +75,49 @@ module('Acceptance | host-catalogs | create', function (hooks) {
authenticateSession({});
});
test('Users can create new host catalogs', async function (assert) {
test('Users can create new static host catalogs', async function (assert) {
assert.expect(1);
const count = gethostCatalogCount();
await visit(urls.newHostCatalog);
await visit(urls.newStaticHostCatalog);
await fillIn('[name="name"]', 'random string');
await fillIn('[name="description"]', 'random string');
await fillIn('[name="types"]', 'static');
await click('[type="submit"]');
assert.equal(gethostCatalogCount(), count + 1);
});
test('Users can cancel create new host catalogs', async function (assert) {
test('Users can create new dynamic host catalogs', async function (assert) {
assert.expect(1);
const count = gethostCatalogCount();
await visit(urls.newDynamicHostCatalog);
await fillIn('[name="name"]', 'random string');
await fillIn('[name="description"]', 'random string');
await fillIn('[name="types"]', 'aws');
await click('[type="submit"]');
assert.equal(gethostCatalogCount(), count + 1);
});
test('Users can cancel creation of new static host catalogs', async function (assert) {
assert.expect(2);
const count = gethostCatalogCount();
await visit(urls.newHostCatalog);
await visit(urls.newStaticHostCatalog);
await fillIn('[name="name"]', 'random string');
await click('.rose-form-actions [type="button"]');
assert.equal(currentURL(), urls.hostCatalogs);
assert.equal(gethostCatalogCount(), count);
});
test('Users can navigate to new host catalogs route with proper authorization', async function (assert) {
test('Users can cancel creation of new dynamic host catalogs', async function (assert) {
assert.expect(2);
const count = gethostCatalogCount();
await visit(urls.newDynamicHostCatalog);
await fillIn('[name="name"]', 'random string');
await click('.rose-form-actions [type="button"]');
assert.equal(currentURL(), urls.hostCatalogs);
assert.equal(gethostCatalogCount(), count);
});
test('Users can navigate to new static host catalogs route with proper authorization', async function (assert) {
assert.expect(2);
await visit(urls.hostCatalogs);
assert.ok(
@@ -101,7 +128,7 @@ module('Acceptance | host-catalogs | create', function (hooks) {
assert.ok(find(`[href="${urls.newHostCatalog}"]`));
});
test('Users cannot navigate to new host catalogs route without proper authorization', async function (assert) {
test('Users cannot navigate to new static host catalogs route without proper authorization', async function (assert) {
assert.expect(2);
instances.scopes.project.authorized_collection_actions['host-catalogs'] =
[];
@@ -111,10 +138,10 @@ module('Acceptance | host-catalogs | create', function (hooks) {
'host-catalogs'
].includes('create')
);
assert.notOk(find(`[href="${urls.newHostCatalog}"]`));
assert.notOk(find(`[href="${urls.newStaticHostCatalog}"]`));
});
test('saving a new host catalog with invalid fields displays error messages', async function (assert) {
test('saving a new static host catalog with invalid fields displays error messages', async function (assert) {
assert.expect(2);
this.server.post('/host-catalogs', () => {
return new Response(
@@ -135,7 +162,7 @@ module('Acceptance | host-catalogs | create', function (hooks) {
}
);
});
await visit(urls.newHostCatalog);
await visit(urls.newStaticHostCatalog);
await click('[type="submit"]');
assert.ok(
find('[role="alert"]').textContent.trim(),
@@ -0,0 +1,14 @@
import { module, test } from 'qunit';
import { setupTest } from 'ember-qunit';
module('Unit | Controller | scopes/scope/host-catalogs/new', function (hooks) {
setupTest(hooks);
// TODO: Replace this with your real tests.
test('it exists', function (assert) {
let controller = this.owner.lookup(
'controller:scopes/scope/host-catalogs/new'
);
assert.ok(controller);
});
});