From eb4ec5f6de97b6e20612b773a6d8da4a893b3e96 Mon Sep 17 00:00:00 2001 From: Cameron Perera Date: Thu, 4 Apr 2024 15:54:23 -0500 Subject: [PATCH] =?UTF-8?q?refactor:=20=F0=9F=92=A1=20update=20Dropdown=20?= =?UTF-8?q?component=20to=20have=20name=20&=20toggleText=20(#2218)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * refactor: 💡 update Dropdown component to have name & toggleText ✅ Closes: https://hashicorp.atlassian.net/browse/ICU-13336 * test: 💍 remove hds class selector ✅ Closes: https://hashicorp.atlassian.net/browse/ICU-13336 --- .../core/addon/components/dropdown/index.hbs | 4 +-- .../components/dropdown/index-test.js | 30 ++++++++++++------- .../scopes/scope/credential-stores/index.hbs | 3 +- .../templates/scopes/scope/sessions/index.hbs | 9 ++++-- .../templates/scopes/scope/targets/index.hbs | 6 ++-- .../acceptance/credential-store/list-test.js | 2 +- .../tests/acceptance/sessions/list-test.js | 12 ++++---- .../tests/acceptance/targets/list-test.js | 8 ++--- .../scopes/scope/projects/sessions/index.hbs | 9 ++++-- .../scopes/scope/projects/targets/index.hbs | 9 ++++-- 10 files changed, 56 insertions(+), 36 deletions(-) diff --git a/addons/core/addon/components/dropdown/index.hbs b/addons/core/addon/components/dropdown/index.hbs index a17ef41b9..e48b0dee4 100644 --- a/addons/core/addon/components/dropdown/index.hbs +++ b/addons/core/addon/components/dropdown/index.hbs @@ -4,15 +4,15 @@ }} diff --git a/addons/core/tests/integration/components/dropdown/index-test.js b/addons/core/tests/integration/components/dropdown/index-test.js index 13f6a6656..62ee9f84a 100644 --- a/addons/core/tests/integration/components/dropdown/index-test.js +++ b/addons/core/tests/integration/components/dropdown/index-test.js @@ -23,17 +23,19 @@ module('Integration | Component | dropdown/index', function (hooks) { name: 'Fake Project', displayName: 'Fake Project', }; - const name = 'Click Me'; + const name = 'test'; + const toggleText = 'Click Me'; const FIRST_ITEM_SELECTOR = `[data-test-checkbox="${firstItem.id}"]`; const SECOND_ITEM_SELECTOR = `[data-test-checkbox="${secondItem.id}"]`; - const TOGGLE_DROPDOWN_SELECTOR = '.hds-dropdown-toggle-button'; + const TOGGLE_DROPDOWN_SELECTOR = `[name=${name}] button`; const SEARCH_INPUT_SELECTOR = '[data-test-dropdown-search]'; - const COUNT_SELECTOR = '.hds-dropdown-toggle-button__count'; - const ITEM_SELECTOR = '.hds-dropdown-list-item'; + const COUNT_SELECTOR = `[name=${name}] button div:nth-child(2)`; + const ITEM_SELECTOR = 'li'; hooks.beforeEach(function () { this.set('name', name); + this.set('toggleText', toggleText); this.set('array', [firstItem, secondItem]); this.set('checkedItems', [firstItem.id]); this.set('applyFilter', () => {}); @@ -41,14 +43,15 @@ module('Integration | Component | dropdown/index', function (hooks) { test('it renders', async function (assert) { await render(hbs``); await click(TOGGLE_DROPDOWN_SELECTOR); - assert.dom('.hds-dropdown-toggle-button__text').hasText(name); + assert.dom(TOGGLE_DROPDOWN_SELECTOR).includesText(toggleText); assert.dom(FIRST_ITEM_SELECTOR).isVisible(); assert.dom(FIRST_ITEM_SELECTOR).isChecked(); assert.dom(SECOND_ITEM_SELECTOR).isVisible(); @@ -58,7 +61,8 @@ module('Integration | Component | dropdown/index', function (hooks) { test('it renders a search input when isSearchable is true', async function (assert) { await render(hbs`