Skip to content

Commit

Permalink
test: add hamburger button tests
Browse files Browse the repository at this point in the history
  • Loading branch information
nachtjasmin committed Oct 26, 2022
1 parent cc1ce48 commit 93751b6
Showing 1 changed file with 32 additions and 0 deletions.
32 changes: 32 additions & 0 deletions tests/start.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,35 @@ test.describe("exit button", () => {
await expect(page.context().pages()).toHaveLength(2);
});
});
test.describe("hamburger button", () => {
// Use a Pixel 5 as a reference mobile device.
test.use({
viewport: { width: 393, height: 851 },
deviceScaleFactor: 2,
hasTouch: true,
});

const buttonLocator = ".js-header-button:visible";

test.beforeEach(async ({ page, baseURL }) => {
test.fail(baseURL === undefined, "baseURL should be set");
await page.goto(baseURL!);
});

test("should be visible", async ({ page }) => {
await expect(page.locator(buttonLocator)).toBeVisible();
});
test("click reveals and unreveals menu", async ({ page }) => {
page.locator(buttonLocator).click();
await expect(page.locator("#mobile-header")).toBeVisible();

page.locator(buttonLocator).click();
await expect(page.locator("#mobile-header")).toBeHidden();
});
test("info menu button is not affected", async ({ page }) => {
const headerBtn = page.locator(buttonLocator);
headerBtn.click();
await page.locator("#open-menu-btn").tap();
await expect(page.locator("#menu >> .z-menu")).toBeVisible();
});
});

0 comments on commit 93751b6

Please sign in to comment.