keycloak-scim/js/apps/account-ui/test/login.ts
Hynek Mlnarik 2f0a9ba547 Ensure referrer link is shown while navigating
Fixes: #27622
Signed-off-by: Hynek Mlnarik <hmlnarik@redhat.com>
2024-03-26 09:40:27 +01:00

20 lines
629 B
TypeScript

import { Page } from "@playwright/test";
import { DEFAULT_REALM } from "../src/constants";
import { getRootPath } from "../src/utils/getRootPath";
export const login = async (
page: Page,
username: string,
password: string,
realm = DEFAULT_REALM,
queryParams?: Record<string, string>,
) => {
const rootPath =
getRootPath(realm) +
(queryParams ? "?" + new URLSearchParams(queryParams) : "");
await page.goto(rootPath);
await page.getByLabel("Username").fill(username);
await page.getByLabel("Password", { exact: true }).fill(password);
await page.getByRole("button", { name: "Sign In" }).click();
};