mirror of
https://github.com/penpot/penpot.git
synced 2026-11-19 00:20:35 +00:00
* ♻️ Give the Team management link in the team hero a real href "Team management" in the "Team up!" notice of a team's Projects page was an <a> without href. It now links to the team Members page; a plain click still runs the in-app navigation (prevent default), and Ctrl/Cmd-click opens the link in a new tab. New visual test "Shows the Team management link": 0 px of difference at rest and on hover. AI-assisted-by: claude-opus-5-5 * ♻️ Give the Go to login link of the recovery page a real href "Go to login" on the password recovery page was an <a> without href. It now links to the login page; a plain click still runs the in-app navigation (prevent default), and Ctrl/Cmd-click opens the link in a new tab. New visual test "Shows the Go to login link": 0 px of difference at rest and on hover. AI-assisted-by: claude-opus-5-5
126 lines
4.4 KiB
JavaScript
126 lines
4.4 KiB
JavaScript
import { test, expect } from "@playwright/test";
|
|
import { LoginPage } from "../pages/LoginPage";
|
|
|
|
test.beforeEach(async ({ page }) => {
|
|
await LoginPage.init(page);
|
|
|
|
const login = new LoginPage(page);
|
|
await login.initWithLoggedOutUser();
|
|
await login.page.goto("/?screen=auth-login");
|
|
});
|
|
|
|
test.describe("Login form", () => {
|
|
test("Shows the login form correctly", async ({ page }) => {
|
|
const login = new LoginPage(page);
|
|
await expect(login.page).toHaveScreenshot();
|
|
});
|
|
|
|
test("Shows form error messages correctly ", async ({ page }) => {
|
|
const login = new LoginPage(page);
|
|
await login.setupLoginSuccess();
|
|
|
|
await login.fillEmailAndPasswordInputs("foo", "lorenIpsum");
|
|
|
|
await expect(login.invalidEmailError).toBeVisible();
|
|
await expect(login.page).toHaveScreenshot();
|
|
});
|
|
|
|
test("Shows error toasts correctly", async ({ page }) => {
|
|
const login = new LoginPage(page);
|
|
await login.setupLoginError();
|
|
|
|
await login.fillEmailAndPasswordInputs("test@example.com", "loremipsum");
|
|
await login.clickLoginButton();
|
|
|
|
await expect(login.invalidCredentialsError).toBeVisible();
|
|
await expect(login.page).toHaveURL(/screen=auth-login$/);
|
|
await expect(login.page).toHaveScreenshot();
|
|
});
|
|
});
|
|
|
|
test.describe("Login dialog section links", () => {
|
|
const shot = { maxDiffPixelRatio: 0, threshold: 0 };
|
|
|
|
// The links switch the dialog section: the tests use the keyboard to
|
|
// check they work as buttons.
|
|
test("Login and register modal", async ({ page }) => {
|
|
// The viewer and the MCP authorize page share this modal; the MCP page
|
|
// opens it on a 401, with no file to load.
|
|
await LoginPage.mockConfigFlags(page, ["enable-registration"]);
|
|
await page.route("**/api/mcp/oauth/request?*", (route) =>
|
|
route.fulfill({
|
|
status: 401,
|
|
contentType: "application/json",
|
|
body: "{}",
|
|
}),
|
|
);
|
|
await page.goto("/?screen=mcp-authorize&request=test");
|
|
|
|
const modal = page.getByRole("dialog");
|
|
const forgot = modal.getByText("Forgot password?", { exact: true });
|
|
await expect(forgot).toBeVisible();
|
|
await page.mouse.move(10, 10);
|
|
await expect(forgot).toHaveScreenshot(shot);
|
|
await forgot.hover();
|
|
await expect(forgot).toHaveScreenshot(shot);
|
|
|
|
const create = modal.getByText("Create an account", { exact: true });
|
|
await create.hover();
|
|
await expect(create).toHaveScreenshot(shot);
|
|
|
|
await create.focus();
|
|
await page.keyboard.press("Enter");
|
|
const loginHere = modal.getByText("Login here.", { exact: true });
|
|
await expect(loginHere).toBeVisible();
|
|
await page.mouse.move(10, 10);
|
|
await expect(loginHere).toHaveScreenshot(shot);
|
|
await loginHere.hover();
|
|
await expect(loginHere).toHaveScreenshot(shot);
|
|
|
|
await loginHere.focus();
|
|
await page.keyboard.press("Enter");
|
|
await page.mouse.move(10, 10);
|
|
await expect(modal).toHaveScreenshot(shot);
|
|
});
|
|
|
|
test("Not found page dialog", async ({ page }) => {
|
|
await LoginPage.mockConfigFlags(page, ["enable-registration"]);
|
|
// An invalid team id is a not found error; logged out users get the
|
|
// login dialog on top of it.
|
|
await page.goto("/?screen=dashboard-recent&team-id=not-a-uuid");
|
|
|
|
const create = page.getByText("Create an account", { exact: true });
|
|
await expect(create).toBeVisible();
|
|
await page.mouse.move(10, 10);
|
|
await expect(create).toHaveScreenshot(shot);
|
|
await create.hover();
|
|
await expect(create).toHaveScreenshot(shot);
|
|
|
|
await create.focus();
|
|
await page.keyboard.press("Enter");
|
|
const loginHere = page.getByText("Login here.", { exact: true });
|
|
await expect(loginHere).toBeVisible();
|
|
// The new section reuses the focused button: blur it for the rest shot.
|
|
await loginHere.blur();
|
|
await page.mouse.move(10, 10);
|
|
await expect(loginHere).toHaveScreenshot(shot);
|
|
await loginHere.hover();
|
|
await expect(loginHere).toHaveScreenshot(shot);
|
|
});
|
|
});
|
|
|
|
test.describe("Password recovery page", () => {
|
|
test("Shows the Go to login link", async ({ page }) => {
|
|
const shot = { maxDiffPixelRatio: 0, threshold: 0 };
|
|
await page.goto("/?screen=auth-recovery&token=fake-token");
|
|
|
|
const link = page.getByText("Go to login", { exact: true });
|
|
await expect(link).toBeVisible();
|
|
await page.mouse.move(10, 10);
|
|
await expect(link).toHaveScreenshot(shot);
|
|
|
|
await link.hover();
|
|
await expect(link).toHaveScreenshot(shot);
|
|
});
|
|
});
|