Skip to content

Commit

Permalink
fix: Search e2e tests
Browse files Browse the repository at this point in the history
  • Loading branch information
bprusinowski committed Nov 9, 2022
1 parent 8a45f7c commit ea7329b
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions e2e/search.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,11 +65,14 @@ test("sort order", async ({ page, selectors, screen, actions }) => {
await page.goto("/en/browse?dataSource=Int");
const resultCount = await selectors.search.resultsCount();
const text = await resultCount.textContent();
const select = selectors.search.datasetSort().locator("select");
// Custom MUI select element; uses an input element under the hood
const select = selectors.search.datasetSort().locator("input");

expect(await getSelectValue(select)).toBe("CREATED_DESC");

const searchInput = screen.getAllByPlaceholderText("Search");
const searchInput = screen.getAllByPlaceholderText(
"Name, organization, keyword..."
);

// Search something, order should be score
await searchInput.type("NFI");
Expand Down Expand Up @@ -97,16 +100,17 @@ test("sort order", async ({ page, selectors, screen, actions }) => {
await page.keyboard.press("Enter");
expect(await getSelectValue(select)).toBe("SCORE");

// Select another order, clear, then search
await select.selectOption("TITLE_ASC");
// Select another order, clear, then search. Using fill due to the select
// being custom MUI implementation
await select.fill("TITLE_ASC");
await actions.search.clear();
await searchInput.type("NFI");
await page.keyboard.press("Enter");
expect(await getSelectValue(select)).toBe("TITLE_ASC");

// Select another order, clear, then search, order should be back
// to previous order
await select.selectOption("SCORE");
await select.fill("SCORE");
await actions.search.clear();
expect(await getSelectValue(select)).toBe("CREATED_DESC");
await searchInput.type("NFI");
Expand Down

0 comments on commit ea7329b

Please sign in to comment.