From 93751b6c058f9adff5abefedfa0329cb9f5ec4fb Mon Sep 17 00:00:00 2001 From: nachtjasmin Date: Wed, 26 Oct 2022 14:25:37 +0200 Subject: [PATCH] test: add hamburger button tests --- tests/start.spec.ts | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/tests/start.spec.ts b/tests/start.spec.ts index bfc58a6..55dc680 100644 --- a/tests/start.spec.ts +++ b/tests/start.spec.ts @@ -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(); + }); +});