test improvements (#39329)

* small test improvements

Signed-off-by: Erik Jan de Wit <erikjan.dewit@gmail.com>

* fix flaky test

Signed-off-by: Erik Jan de Wit <erikjan.dewit@gmail.com>

---------

Signed-off-by: Erik Jan de Wit <erikjan.dewit@gmail.com>
This commit is contained in:
Erik Jan de Wit
2025-04-29 15:35:29 +02:00
committed by GitHub
parent 4c17ec26e3
commit 563e94524e
7 changed files with 18 additions and 31 deletions

View File

@@ -25,6 +25,7 @@ export const HelpHeader = () => {
const dropdownItems = [
<DropdownItem key="link" id="link">
<FormattedLink
data-testId="documentation-link"
href={helpUrls.documentationUrl}
title={t("documentation")}
/>
@@ -60,6 +61,7 @@ export const HelpHeader = () => {
onClick={() => setOpen(!open)}
aria-label="Help"
id="help"
data-testid="help-toggle"
>
<HelpIcon />
</MenuToggle>

View File

@@ -15,11 +15,11 @@ export async function assertSupportedApplications(
}
export async function setPolicyType(page: Page, type: string) {
page.getByTestId(type).click();
await page.getByTestId(type).click();
}
export async function increaseInitialCounter(page: Page) {
page.locator("#otpPolicyInitialCounter").getByLabel("Plus").click();
await page.locator("#otpPolicyInitialCounter").getByLabel("Plus").click();
}
export async function goToWebauthnPage(page: Page) {

View File

@@ -62,7 +62,7 @@ test.describe("Client registration policies tab", () => {
});
test("edit anonymous client registration policy", async ({ page }) => {
await clickTableRowItem(page, policyName);
await clickTableRowItem(page, "Consent Required");
await fillPolicyForm(page, { name: policyNameUpdated });
await clickSaveButton(page);
@@ -76,7 +76,7 @@ test.describe("Client registration policies tab", () => {
});
test("delete anonymous client registration policy", async ({ page }) => {
await clickRowKebabItem(page, policyNameUpdated, "Delete");
await clickRowKebabItem(page, "Full Scope Disabled", "Delete");
await confirmModal(page);
await assertNotificationMessage(
@@ -114,7 +114,7 @@ test.describe("Client registration policies tab", () => {
});
test("edit authenticated client registration policy", async ({ page }) => {
await clickTableRowItem(page, policyName);
await clickTableRowItem(page, "Allowed Protocol Mapper Types");
await fillPolicyForm(page, { name: policyNameUpdated });
await clickSaveButton(page);
@@ -129,7 +129,7 @@ test.describe("Client registration policies tab", () => {
test("delete authenticated client registration policy", async ({
page,
}) => {
await clickRowKebabItem(page, policyNameUpdated, "Delete");
await clickRowKebabItem(page, "Allowed Client Scopes", "Delete");
await confirmModal(page);
await assertNotificationMessage(

View File

@@ -71,7 +71,6 @@ test.describe("SAML identity provider test", () => {
},
{ type: "saml-user-attribute", name: "Attribute Importer" },
{ type: "oidc-hardcoded-role", name: "Hardcoded Role" },
{ type: "hardcoded-attribute", name: "Hardcoded Attribute" },
{ type: "saml-role", name: "SAML Attribute To Role" },
];

View File

@@ -7,7 +7,6 @@ import { goToClients } from "../utils/sidebar";
import {
assertIsDesktopView,
assertIsMobileView,
clickDocumentationLink,
clickGlobalHelp,
getDocumentationLink,
goToAccountManagement,
@@ -43,13 +42,10 @@ test.describe("Masthead tests", () => {
test("Should go to documentation page", async ({ page }) => {
await clickGlobalHelp(page);
const href = await getDocumentationLink(page);
if (href) {
await clickDocumentationLink(page);
await expect(page.locator("#header")).toContainText(
"Server Administration Guide",
);
}
await expect(getDocumentationLink(page)).toHaveAttribute(
"href",
"https://www.keycloak.org/docs/latest/server_admin/index.html",
);
});
test("Enable/disable help mode in desktop mode", async ({ page }) => {
@@ -59,7 +55,7 @@ test.describe("Masthead tests", () => {
await expect(page.locator(helpLabel)).toBeVisible();
await clickGlobalHelp(page);
await toggleGlobalHelp(page);
await expect(page.locator(helpLabel)).not.toBeVisible();
await expect(page.locator(helpLabel)).toBeHidden();
await toggleGlobalHelp(page);
await expect(page.locator(helpLabel)).toBeVisible();
});

View File

@@ -25,13 +25,13 @@ export async function goToAccountManagement(page: Page) {
}
export async function assertIsMobileView(page: Page) {
await expect(getUserDropdownSelector(page)).not.toBeVisible();
await expect(getUserDropdownSelector(page)).toBeHidden();
await expect(getMobileUserDropdownSelector(page)).toBeVisible();
}
export async function assertIsDesktopView(page: Page) {
await expect(getUserDropdownSelector(page)).toBeVisible();
await expect(getMobileUserDropdownSelector(page)).not.toBeVisible();
await expect(getMobileUserDropdownSelector(page)).toBeHidden();
}
export async function toggleUsernameDropdown(page: Page) {
@@ -42,18 +42,12 @@ export async function toggleMobileViewHelp(page: Page) {
await page.getByRole("menuitem", { name: "Help on" }).click();
}
export async function getDocumentationLink(page: Page) {
return await page
.getByRole("menuitem", { name: "Documentation" })
.getAttribute("href");
}
export async function clickDocumentationLink(page: Page) {
await page.getByRole("menuitem", { name: "Documentation" }).click();
export function getDocumentationLink(page: Page) {
return page.getByTestId("documentation-link");
}
export async function clickGlobalHelp(page: Page) {
await page.getByRole("button", { name: "Help" }).click();
await page.getByTestId("help-toggle").click();
}
export async function toggleGlobalHelp(page: Page) {

View File

@@ -35,18 +35,14 @@ test.describe("Email", () => {
await goToRealmSettings(page);
await goToEmailTab(page);
await assertEmailPageNoAuth(page);
});
test("Add email data with password authentication", async ({ page }) => {
await populateEmailPageWithPasswordAuth(page);
await clickSaveEmailButton(page);
await assertNotificationMessage(page, "Realm successfully updated");
await goToRealmSettings(page);
await goToEmailTab(page);
await assertEmailPageWithPasswordAuth(page);
});
test("Add email data with token authentication", async ({ page }) => {
await populateEmailPageWithTokenAuth(page);
await clickSaveEmailButton(page);
await assertNotificationMessage(page, "Realm successfully updated");