test: add hamburger button tests

This commit is contained in:
nachtjasmin 2022-10-26 14:25:37 +02:00 committed by Jasmin
parent cc1ce48234
commit 93751b6c05

View file

@ -21,3 +21,35 @@ test.describe("exit button", () => {
await expect(page.context().pages()).toHaveLength(2); 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();
});
});