Tests for applications page
Fixes: #21249 Signed-off-by: Hynek Mlnarik <hmlnarik@redhat.com>
This commit is contained in:
parent
eadd1c45c4
commit
7b384280b6
5 changed files with 92 additions and 25 deletions
|
@ -19,7 +19,6 @@ export default defineConfig({
|
||||||
|
|
||||||
/* Configure projects for major browsers */
|
/* Configure projects for major browsers */
|
||||||
projects: [
|
projects: [
|
||||||
{ name: "setup", testMatch: /.auth\.setup\.ts/ },
|
|
||||||
{
|
{
|
||||||
name: "import realms",
|
name: "import realms",
|
||||||
testMatch: /realm\.setup\.ts/,
|
testMatch: /realm\.setup\.ts/,
|
||||||
|
@ -31,20 +30,10 @@ export default defineConfig({
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "chromium",
|
name: "chromium",
|
||||||
use: {
|
|
||||||
...devices["Desktop Chrome"],
|
|
||||||
storageState: ".auth/user.json",
|
|
||||||
},
|
|
||||||
dependencies: ["setup", "import realms"],
|
|
||||||
testIgnore: ["**/personal-info.spec.ts"],
|
|
||||||
},
|
|
||||||
{
|
|
||||||
name: "personal-info",
|
|
||||||
use: {
|
use: {
|
||||||
...devices["Desktop Chrome"],
|
...devices["Desktop Chrome"],
|
||||||
},
|
},
|
||||||
dependencies: ["import realms"],
|
dependencies: ["import realms"],
|
||||||
testMatch: ["**/personal-info.spec.ts"],
|
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
});
|
});
|
||||||
|
|
|
@ -117,6 +117,7 @@ export const Applications = () => {
|
||||||
<DataListItem
|
<DataListItem
|
||||||
key={application.clientId}
|
key={application.clientId}
|
||||||
aria-labelledby="applications-list"
|
aria-labelledby="applications-list"
|
||||||
|
data-testid="applications-list-item"
|
||||||
isExpanded={application.open}
|
isExpanded={application.open}
|
||||||
>
|
>
|
||||||
<DataListItemRow className="pf-u-align-items-center">
|
<DataListItemRow className="pf-u-align-items-center">
|
||||||
|
|
89
js/apps/account-ui/test/applications.spec.ts
Normal file
89
js/apps/account-ui/test/applications.spec.ts
Normal file
|
@ -0,0 +1,89 @@
|
||||||
|
import { expect, test } from "@playwright/test";
|
||||||
|
import { login } from "./login";
|
||||||
|
|
||||||
|
test.describe("Applications test", () => {
|
||||||
|
test.beforeEach(async ({ page }) => {
|
||||||
|
// Sign out all devices before each test
|
||||||
|
await login(page, "admin", "admin", "master");
|
||||||
|
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 }) => {
|
||||||
|
await login(page, "admin", "admin", "master");
|
||||||
|
|
||||||
|
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();
|
||||||
|
|
||||||
|
await login(page1, "admin", "admin", "master");
|
||||||
|
await login(page2, "admin", "admin", "master");
|
||||||
|
|
||||||
|
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",
|
||||||
|
);
|
||||||
|
|
||||||
|
await login(page, "admin", "admin", "master");
|
||||||
|
|
||||||
|
// go to admin console
|
||||||
|
await page.goto("/");
|
||||||
|
await expect(page).toHaveURL("http://localhost:8080/admin/master/console/");
|
||||||
|
await page.waitForURL("http://localhost:8080/admin/master/console/");
|
||||||
|
|
||||||
|
await page.goto("/realms/master/account");
|
||||||
|
await page.waitForURL("http://localhost:8080/realms/master/account/");
|
||||||
|
|
||||||
|
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();
|
||||||
|
});
|
||||||
|
});
|
|
@ -1,14 +0,0 @@
|
||||||
import { test as setup } from "@playwright/test";
|
|
||||||
import { login } from "./login";
|
|
||||||
import { useTheme } from "./admin-client";
|
|
||||||
|
|
||||||
const authFile = ".auth/user.json";
|
|
||||||
|
|
||||||
setup("authenticate", async ({ page }) => {
|
|
||||||
useTheme();
|
|
||||||
await page.goto("./");
|
|
||||||
await login(page, "admin", "admin");
|
|
||||||
await page.waitForURL("./");
|
|
||||||
|
|
||||||
await page.context().storageState({ path: authFile });
|
|
||||||
});
|
|
|
@ -2,6 +2,8 @@ import { test, expect } from "@playwright/test";
|
||||||
import { login } from "./login";
|
import { login } from "./login";
|
||||||
|
|
||||||
test.describe("My resources page", () => {
|
test.describe("My resources page", () => {
|
||||||
|
test.describe.configure({ mode: "serial" });
|
||||||
|
|
||||||
test("List my resources", async ({ page }) => {
|
test("List my resources", async ({ page }) => {
|
||||||
await login(page, "jdoe", "jdoe", "photoz");
|
await login(page, "jdoe", "jdoe", "photoz");
|
||||||
await page.getByTestId("resources").click();
|
await page.getByTestId("resources").click();
|
||||||
|
|
Loading…
Reference in a new issue