Skip to content

Commit

Permalink
Fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
jeffdaley committed Oct 12, 2023
1 parent 7a29a4b commit 5900658
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ export default class DocumentSidebarRelatedResourcesListItemComponent extends Co
edit: {
label: "Edit",
icon: "edit",
action: () => this.showModal,
action: () => this.showModal(),
},
};
}
Expand Down
2 changes: 1 addition & 1 deletion web/app/components/related-resources/overflow-menu.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
{{on "click" dd.attrs.action}}
class="related-resources-overflow-menu-item-button"
>
<FlightIcon @name={{dd.attrs.icon}} />
<FlightIcon @name={{dd.attrs.icon}} class="shrink-0" />
<span data-test-label>
{{dd.attrs.label}}
</span>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { TestContext, click, render } from "@ember/test-helpers";
import { TestContext, click, findAll, render } from "@ember/test-helpers";
import { hbs } from "ember-cli-htmlbars";
import { setupRenderingTest } from "ember-qunit";
import { OverflowItem } from "hermes/components/related-resources/overflow-menu";
Expand All @@ -7,7 +7,7 @@ import { module, test } from "qunit";
const POPOVER = "[data-test-related-resources-list-item-overflow-menu]";
const TOGGLE = "[data-test-x-dropdown-list-toggle-action]";
const ACTION = `${POPOVER} [data-test-action]`;
const ICON = `${POPOVER} [data-test-flight-icon]`;
const ICON = `${POPOVER} .flight-icon`;
const LABEL = `${POPOVER} [data-test-label]`;

interface RelatedResourcesOverflowMenuTestContext extends TestContext {
Expand Down Expand Up @@ -50,19 +50,13 @@ module("Integration | Component | related-resources/add", function (hooks) {
const expectedLabels = ["Item 1", "Item 2"];
const expectedIcons = ["square", "circle"];

assert.equal(
[...this.element.querySelectorAll(LABEL)].map(
(el) => el.textContent?.trim(),
),
expectedLabels,
const actualLabels = findAll(LABEL).map((el) => el.textContent?.trim());
const actualIcons = findAll(ICON).map(
(el) => el.getAttribute("data-test-icon")?.trim(),
);

assert.equal(
[...this.element.querySelectorAll(ICON)].map(
(el) => el.getAttribute("data-test-flight-icon")?.trim(),
),
expectedIcons,
);
assert.deepEqual(actualLabels, expectedLabels);
assert.deepEqual(actualIcons, expectedIcons);

// Click the first action
await click(ACTION);
Expand Down

0 comments on commit 5900658

Please sign in to comment.