2024-02-19 15:14:29 +00:00
|
|
|
import { expect, test } from "@playwright/test";
|
2024-03-04 12:38:28 +00:00
|
|
|
import { getRootPath } from "../src/utils/getRootPath";
|
2024-02-19 15:14:29 +00:00
|
|
|
import { login } from "./login";
|
2024-03-04 12:38:28 +00:00
|
|
|
import { getAccountUrl, getAdminUrl } from "./utils";
|
2024-02-19 15:14:29 +00:00
|
|
|
|
|
|
|
test.describe("Applications test", () => {
|
|
|
|
test.beforeEach(async ({ page }) => {
|
|
|
|
// Sign out all devices before each test
|
2024-03-04 12:38:28 +00:00
|
|
|
await login(page, "admin", "admin");
|
2024-02-19 15:14:29 +00:00
|
|
|
await page.getByTestId("accountSecurity").click();
|
|
|
|
await page.getByTestId("account-security/device-activity").click();
|
|
|
|
|
|
|
|
await page
|
|
|
|
.getByRole("button", { name: "Sign out all devices", exact: true })
|
|
|
|
.click();
|
|
|
|
await page.getByRole("button", { name: "Confirm" }).click();
|
|
|
|
|
|
|
|
await expect(
|
|
|
|
page.getByRole("heading", { name: "Sign in to your account" }),
|
|
|
|
).toBeVisible();
|
|
|
|
});
|
|
|
|
|
|
|
|
test("Single application", async ({ page }) => {
|
2024-03-04 12:38:28 +00:00
|
|
|
await login(page, "admin", "admin");
|
2024-02-19 15:14:29 +00:00
|
|
|
|
|
|
|
await page.getByTestId("applications").click();
|
|
|
|
|
|
|
|
await expect(page.getByTestId("applications-list-item")).toHaveCount(1);
|
|
|
|
await expect(page.getByTestId("applications-list-item")).toContainText(
|
|
|
|
process.env.CI ? "Account Console" : "security-admin-console-v2",
|
|
|
|
);
|
|
|
|
});
|
|
|
|
|
|
|
|
test("Single application twice", async ({ browser }) => {
|
|
|
|
const context1 = await browser.newContext({
|
|
|
|
userAgent:
|
|
|
|
"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko)",
|
|
|
|
});
|
|
|
|
const context2 = await browser.newContext();
|
|
|
|
try {
|
|
|
|
const page1 = await context1.newPage();
|
|
|
|
const page2 = await context2.newPage();
|
|
|
|
|
2024-03-04 12:38:28 +00:00
|
|
|
await login(page1, "admin", "admin");
|
|
|
|
await login(page2, "admin", "admin");
|
2024-02-19 15:14:29 +00:00
|
|
|
|
|
|
|
await page1.getByTestId("applications").click();
|
|
|
|
|
|
|
|
await expect(page1.getByTestId("applications-list-item")).toHaveCount(1);
|
|
|
|
await expect(
|
|
|
|
page1.getByTestId("applications-list-item").nth(0),
|
|
|
|
).toContainText(
|
|
|
|
process.env.CI ? "Account Console" : "security-admin-console-v2",
|
|
|
|
);
|
|
|
|
} finally {
|
|
|
|
await context1.close();
|
|
|
|
await context2.close();
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
test("Two applications", async ({ page }) => {
|
|
|
|
test.skip(
|
|
|
|
!process.env.CI,
|
|
|
|
"Skip this test if not running with regular Keycloak",
|
|
|
|
);
|
|
|
|
|
2024-03-04 12:38:28 +00:00
|
|
|
await login(page, "admin", "admin");
|
2024-02-19 15:14:29 +00:00
|
|
|
|
|
|
|
// go to admin console
|
|
|
|
await page.goto("/");
|
2024-03-04 12:38:28 +00:00
|
|
|
await expect(page).toHaveURL(getAdminUrl());
|
|
|
|
await page.waitForURL(getAdminUrl());
|
2024-06-03 11:42:44 +00:00
|
|
|
await expect(page.getByTestId("realmSelector")).toBeVisible();
|
2024-02-19 15:14:29 +00:00
|
|
|
|
2024-03-04 12:38:28 +00:00
|
|
|
await page.goto(getRootPath());
|
|
|
|
await page.waitForURL(getAccountUrl());
|
2024-02-19 15:14:29 +00:00
|
|
|
|
|
|
|
await page.getByTestId("applications").click();
|
|
|
|
|
|
|
|
await expect(page.getByTestId("applications-list-item")).toHaveCount(2);
|
|
|
|
await expect(
|
|
|
|
page
|
|
|
|
.getByTestId("applications-list-item")
|
|
|
|
.filter({ hasText: "Account Console" }),
|
|
|
|
).toBeVisible();
|
|
|
|
await expect(
|
|
|
|
page
|
|
|
|
.getByTestId("applications-list-item")
|
|
|
|
.filter({ hasText: "security-admin-console" }),
|
|
|
|
).toBeVisible();
|
|
|
|
});
|
|
|
|
});
|