add assertRealmsSorted to admin ui test functions

This commit is contained in:
Amr Elnaggar 2026-05-18 04:19:38 +03:00
parent 48a8ab9a6e
commit d9f026057d
2 changed files with 13 additions and 7 deletions

View file

@ -1,4 +1,4 @@
import { test, expect } from "@playwright/test";
import { test } from "@playwright/test";
import { v4 as uuid } from "uuid";
import adminClient from "../utils/AdminClient.ts";
import { DEFAULT_REALM } from "../utils/constants.ts";
@ -21,6 +21,7 @@ import {
goToRealmSection,
getTextArea,
assertTextAreaContains,
assertRealmsSorted,
} from "./realm.ts";
const testRealmName = `Test-realm-${uuid()}`;
@ -123,12 +124,7 @@ test.describe.serial("Realm tests", () => {
const realms = await page
.locator(".pf-v5-c-table tr td:nth-child(2)")
.allInnerTexts();
expect(
realms.every((value, index, realms) => {
if (index === 0) return true;
return realms[index - 1] <= value;
}),
).toBeTruthy();
assertRealmsSorted(realms, 3);
});
test("should disable preview if json very long", async ({ page }) => {

View file

@ -50,3 +50,13 @@ export function getTextArea(page: Page) {
export async function assertTextAreaContains(page: Page, content: string) {
await expect(getTextArea(page)).toContainText(content);
}
export function assertRealmsSorted(realms: string[], length: number) {
expect(realms.length).toBeGreaterThanOrEqual(length);
expect(
realms.every((value, index, realms) => {
if (index === 0) return true;
return realms[index - 1] <= value;
}),
).toBeTruthy();
}