diff --git a/ui/admin/app/components/host-catalogs/host-catalog/host-sets/host-set/actions/index.hbs b/ui/admin/app/components/host-catalogs/host-catalog/host-sets/host-set/actions/index.hbs index 111ef7615..932629510 100644 --- a/ui/admin/app/components/host-catalogs/host-catalog/host-sets/host-set/actions/index.hbs +++ b/ui/admin/app/components/host-catalogs/host-catalog/host-sets/host-set/actions/index.hbs @@ -3,31 +3,25 @@ SPDX-License-Identifier: BUSL-1.1 }} - + + + {{#if (can 'addHosts hostSet' @model)}} - - {{t 'resources.host-set.actions.create-and-add-host'}} - - + - {{t 'resources.host-set.actions.add-hosts'}} - - + /> + {{/if}} {{#if (can 'delete model' @model)}} - - {{t 'resources.host-set.actions.delete'}} - + /> {{/if}} - \ No newline at end of file + \ No newline at end of file diff --git a/ui/admin/tests/acceptance/host-catalogs/host-sets/delete-test.js b/ui/admin/tests/acceptance/host-catalogs/host-sets/delete-test.js index 0883ef0e9..ca62e615a 100644 --- a/ui/admin/tests/acceptance/host-catalogs/host-sets/delete-test.js +++ b/ui/admin/tests/acceptance/host-catalogs/host-sets/delete-test.js @@ -22,6 +22,10 @@ module('Acceptance | host-catalogs | host sets | delete', function (hooks) { setupMirage(hooks); let getHostSetCount; + const MANAGE_DROPDOWN_SELECTOR = + '[data-test-manage-dropdown-host-sets] div:first-child button'; + const DELETE_ACTION_SELECTOR = + '[data-test-manage-dropdown-host-sets] ul li button'; const instances = { scopes: { @@ -80,7 +84,8 @@ module('Acceptance | host-catalogs | host sets | delete', function (hooks) { test('can delete host', async function (assert) { const count = getHostSetCount(); await visit(urls.hostSet); - await click('.rose-layout-page-actions .rose-dropdown-button-danger'); + await click(MANAGE_DROPDOWN_SELECTOR); + await click(DELETE_ACTION_SELECTOR); assert.strictEqual(getHostSetCount(), count - 1); }); @@ -90,7 +95,8 @@ module('Acceptance | host-catalogs | host sets | delete', function (hooks) { confirmService.confirm = sinon.fake.returns(resolve()); const count = getHostSetCount(); await visit(urls.hostSet); - await click('.rose-layout-page-actions .rose-dropdown-button-danger'); + await click(MANAGE_DROPDOWN_SELECTOR); + await click(DELETE_ACTION_SELECTOR); assert.strictEqual(getHostSetCount(), count - 1); assert.ok(confirmService.confirm.calledOnce); }); @@ -99,6 +105,7 @@ module('Acceptance | host-catalogs | host sets | delete', function (hooks) { instances.hostSet.authorized_actions = instances.hostSet.authorized_actions.filter((item) => item !== 'delete'); await visit(urls.hostSet); + await click(MANAGE_DROPDOWN_SELECTOR); assert.notOk( find('.rose-layout-page-actions .rose-dropdown-button-danger'), ); @@ -110,7 +117,8 @@ module('Acceptance | host-catalogs | host sets | delete', function (hooks) { confirmService.confirm = sinon.fake.returns(reject()); const count = getHostSetCount(); await visit(urls.hostSet); - await click('.rose-layout-page-actions .rose-dropdown-button-danger'); + await click(MANAGE_DROPDOWN_SELECTOR); + await click(DELETE_ACTION_SELECTOR); assert.strictEqual(getHostSetCount(), count); assert.ok(confirmService.confirm.calledOnce); }); @@ -128,7 +136,8 @@ module('Acceptance | host-catalogs | host sets | delete', function (hooks) { ); }); await visit(urls.hostSet); - await click('.rose-layout-page-actions .rose-dropdown-button-danger'); + await click(MANAGE_DROPDOWN_SELECTOR); + await click(DELETE_ACTION_SELECTOR); assert.ok(find('[role="alert"]').textContent.trim(), 'Oops.'); }); }); diff --git a/ui/admin/tests/acceptance/host-catalogs/host-sets/hosts-test.js b/ui/admin/tests/acceptance/host-catalogs/host-sets/hosts-test.js index dde8e2c30..beb642302 100644 --- a/ui/admin/tests/acceptance/host-catalogs/host-sets/hosts-test.js +++ b/ui/admin/tests/acceptance/host-catalogs/host-sets/hosts-test.js @@ -28,6 +28,12 @@ module('Acceptance | host-catalogs | host-sets | hosts', function (hooks) { setupMirage(hooks); let getHostSetHostCount; + const MANAGE_DROPDOWN_SELECTOR = + '[data-test-manage-dropdown-host-sets] div:first-child button'; + const CREATE_AND_ADD_HOSTS_SELECTOR = + '[data-test-manage-dropdown-host-sets] div ul li:first-child a'; + const ADD_EXISTING_HOSTS_SELECTOR = + '[data-test-manage-dropdown-host-sets] div ul li:nth-child(2) a'; const instances = { scopes: { @@ -141,6 +147,7 @@ module('Acceptance | host-catalogs | host-sets | hosts', function (hooks) { test('can navigate to add hosts with proper authorization', async function (assert) { await visit(urls.hostSet); + await click(MANAGE_DROPDOWN_SELECTOR); assert.ok(find(`[href="${urls.addHosts}"]`)); }); @@ -157,7 +164,8 @@ module('Acceptance | host-catalogs | host-sets | hosts', function (hooks) { instances.hostSet.update({ hostIds: [] }); await visit(urls.hostSetHosts); assert.strictEqual(findAll('tbody tr').length, 0); - await click('.rose-layout-page-actions a:nth-child(2)'); + await click(MANAGE_DROPDOWN_SELECTOR); + await click(ADD_EXISTING_HOSTS_SELECTOR); assert.strictEqual(currentURL(), urls.addHosts); // Click three times to select, unselect, then reselect (for coverage) await click('tbody label'); @@ -175,7 +183,8 @@ module('Acceptance | host-catalogs | host-sets | hosts', function (hooks) { await click('[data-test-host-set-hosts-dropdown-toggle]'); await click('[data-test-host-set-hosts-dropdown-remove-host]'); assert.strictEqual(findAll('tbody tr').length, count - 1); - await click('.rose-layout-page-actions a:nth-child(2)'); + await click(MANAGE_DROPDOWN_SELECTOR); + await click(ADD_EXISTING_HOSTS_SELECTOR); assert.strictEqual(currentURL(), urls.addHosts); await click('tbody .hds-table__tr .hds-form-label'); await click('form [type="button"]'); @@ -213,7 +222,8 @@ module('Acceptance | host-catalogs | host-sets | hosts', function (hooks) { instances.hostSet.update({ hostIds: [] }); await visit(urls.hostSet); assert.strictEqual(findAll('tbody tr').length, 0); - await click('.rose-layout-page-actions a:nth-child(1)'); + await click(MANAGE_DROPDOWN_SELECTOR); + await click(CREATE_AND_ADD_HOSTS_SELECTOR); assert.strictEqual(currentURL(), urls.createAndAddHost); await fillIn('[name="name"]', 'Test Name'); await fillIn('[name="description"]', 'description');