From 92d7380f832c16ed8962626993f374661a991b78 Mon Sep 17 00:00:00 2001 From: Randall Morey Date: Tue, 8 Feb 2022 13:11:08 -0500 Subject: [PATCH 1/2] =?UTF-8?q?chore:=20=F0=9F=A4=96=20clean=20up=20unused?= =?UTF-8?q?=20new=20instances?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ui/admin/app/routes/scopes/scope/host-catalogs/new.js | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/ui/admin/app/routes/scopes/scope/host-catalogs/new.js b/ui/admin/app/routes/scopes/scope/host-catalogs/new.js index 40cf6f01a..588ecac90 100644 --- a/ui/admin/app/routes/scopes/scope/host-catalogs/new.js +++ b/ui/admin/app/routes/scopes/scope/host-catalogs/new.js @@ -17,6 +17,14 @@ export default class ScopesScopeHostCatalogsNewRoute extends Route { // =methods + /** + * Rollback/destroy any new, unsaved instances from this route before + * creating another. + */ + beforeModel() { + if (this.currentModel?.isNew) this.currentModel.rollbackAttributes(); + } + /** * Creates a new unsaved host catalog belonging to the current scope. * @return {HostCatalogModel} From 353a7f94ad40ffbc91e7423a7058a50e9c31990b Mon Sep 17 00:00:00 2001 From: dharini Date: Tue, 8 Feb 2022 10:30:11 -0800 Subject: [PATCH 2/2] =?UTF-8?q?test:=20=F0=9F=92=8D=20update=20tests?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../acceptance/host-catalogs/create-test.js | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/ui/admin/tests/acceptance/host-catalogs/create-test.js b/ui/admin/tests/acceptance/host-catalogs/create-test.js index f07467f8e..19fc1dd3d 100644 --- a/ui/admin/tests/acceptance/host-catalogs/create-test.js +++ b/ui/admin/tests/acceptance/host-catalogs/create-test.js @@ -97,7 +97,7 @@ module('Acceptance | host-catalogs | create', function (hooks) { assert.equal(gethostCatalogCount(), count + 1); }); - test('Users can cancel create new host catalogs', async function (assert) { + test('Users can cancel creation of new static host catalogs', async function (assert) { assert.expect(2); const count = gethostCatalogCount(); await visit(urls.newStaticHostCatalog); @@ -107,7 +107,17 @@ module('Acceptance | host-catalogs | create', function (hooks) { 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( @@ -118,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'] = []; @@ -131,7 +141,7 @@ module('Acceptance | host-catalogs | create', function (hooks) { 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(