Skip to content

Commit

Permalink
Update index.spec.ts for e2e fix
Browse files Browse the repository at this point in the history
  • Loading branch information
acouch committed Dec 18, 2024
1 parent 1aa9834 commit dd80b68
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions frontend/tests/e2e/index.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,9 +56,13 @@ test("skips to main content when navigating via keyboard", async ({
test("displays mobile nav at mobile width", async ({ page }, { project }) => {
if (project.name.match(/[Mm]obile/)) {
// confirm that nav items are not visible by default with menu closed
const primaryNavItems = page.locator(".usa-nav__primary-item");
await expect(primaryNavItems).toHaveCount(6);
const allNavItems = await page.locator(".usa-nav__primary-item").all();
const primaryNavItems = page.locator(
".usa-accordion > .usa-nav__primary-item",
);
await expect(primaryNavItems).toHaveCount(5);
const allNavItems = await page
.locator(".usa-accordion > .usa-nav__primary-item")
.all();
await Promise.all(
allNavItems.map((item) => {
return expect(item).not.toBeVisible();
Expand Down Expand Up @@ -86,7 +90,9 @@ test("hides mobile nav at expected times", async ({ page }, { project }) => {
await menuOpener.click();

// mobile menu closes when a navigation link is clicked
const firstNavItem = page.locator(".usa-nav__primary-item > a").first();
const firstNavItem = page
.locator(".usa-accordion > .usa-nav__primary-item > a")
.first();
await expect(firstNavItem).toBeVisible();
await firstNavItem.click();
await expect(firstNavItem).not.toBeVisible();
Expand Down

0 comments on commit dd80b68

Please sign in to comment.