Files
Felis/panel/e2e/mobile.spec.ts
T

53 lines
1.9 KiB
TypeScript

import { test, expect, t, expectFitsScreen } from "./fixtures";
test("the menu drawer reaches the other sections", async ({ page, signIn }) => {
await signIn("linked");
await page.goto("/");
await page.getByRole("button", { name: t("common:open_menu") }).click();
const drawer = page.getByRole("dialog");
await expect(drawer).toBeVisible();
await drawer.getByRole("link", { name: t("navigation:account") }).click();
await expect(page).toHaveURL(/\/account$/);
await expect(drawer).toBeHidden();
});
for (const [account, path] of [
["linked", "/"],
["linked", "/servers"],
["linked", "/servers/lobby"],
["linked", "/account"],
["owner", "/servers"],
["owner", "/admin/users"],
["owner", "/servers/survival/luckperms"],
] as const) {
test(`${path} fits a 375px screen for ${account}`, async ({ page, signIn }) => {
await signIn(account);
await page.goto(path);
await page.waitForLoadState("networkidle");
await expectFitsScreen(page);
});
}
test("the LuckPerms player list leaves the rest of the page on the first screen", async ({ page, signIn }) => {
await signIn("owner");
await page.goto("/servers/survival/luckperms");
const list = page.getByRole("button", { name: "mock_player", exact: true }).locator("..");
await expect(list).toBeVisible();
// Twelve players online: the list scrolls inside its card, so the prompt
// under it shows without scrolling the page.
await expect(page.getByText(t("servers:luckperms_select_player_prompt"))).toBeInViewport({ ratio: 1 });
const { scrollHeight, clientHeight } = await list.evaluate((el) => ({
scrollHeight: el.scrollHeight,
clientHeight: el.clientHeight,
}));
expect(scrollHeight).toBeGreaterThan(clientHeight);
// The last one is still a tap away.
await page.getByRole("button", { name: "Herobrine", exact: true }).click();
await expect(page.getByRole("textbox", { name: t("servers:luckperms_player_lookup") })).toHaveValue("Herobrine");
});