Keycloak

Форк
0
/
applications.spec.ts 
91 строка · 2.8 Кб
1
import { expect, test } from "@playwright/test";
2
import { getRootPath } from "../src/utils/getRootPath";
3
import { login } from "./login";
4
import { getAccountUrl, getAdminUrl } from "./utils";
5

6
test.describe("Applications test", () => {
7
  test.beforeEach(async ({ page }) => {
8
    // Sign out all devices before each test
9
    await login(page, "admin", "admin");
10
    await page.getByTestId("accountSecurity").click();
11
    await page.getByTestId("account-security/device-activity").click();
12

13
    await page
14
      .getByRole("button", { name: "Sign out all devices", exact: true })
15
      .click();
16
    await page.getByRole("button", { name: "Confirm" }).click();
17

18
    await expect(
19
      page.getByRole("heading", { name: "Sign in to your account" }),
20
    ).toBeVisible();
21
  });
22

23
  test("Single application", async ({ page }) => {
24
    await login(page, "admin", "admin");
25

26
    await page.getByTestId("applications").click();
27

28
    await expect(page.getByTestId("applications-list-item")).toHaveCount(1);
29
    await expect(page.getByTestId("applications-list-item")).toContainText(
30
      process.env.CI ? "Account Console" : "security-admin-console-v2",
31
    );
32
  });
33

34
  test("Single application twice", async ({ browser }) => {
35
    const context1 = await browser.newContext({
36
      userAgent:
37
        "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko)",
38
    });
39
    const context2 = await browser.newContext();
40
    try {
41
      const page1 = await context1.newPage();
42
      const page2 = await context2.newPage();
43

44
      await login(page1, "admin", "admin");
45
      await login(page2, "admin", "admin");
46

47
      await page1.getByTestId("applications").click();
48

49
      await expect(page1.getByTestId("applications-list-item")).toHaveCount(1);
50
      await expect(
51
        page1.getByTestId("applications-list-item").nth(0),
52
      ).toContainText(
53
        process.env.CI ? "Account Console" : "security-admin-console-v2",
54
      );
55
    } finally {
56
      await context1.close();
57
      await context2.close();
58
    }
59
  });
60

61
  test("Two applications", async ({ page }) => {
62
    test.skip(
63
      !process.env.CI,
64
      "Skip this test if not running with regular Keycloak",
65
    );
66

67
    await login(page, "admin", "admin");
68

69
    // go to admin console
70
    await page.goto("/");
71
    await expect(page).toHaveURL(getAdminUrl());
72
    await page.waitForURL(getAdminUrl());
73

74
    await page.goto(getRootPath());
75
    await page.waitForURL(getAccountUrl());
76

77
    await page.getByTestId("applications").click();
78

79
    await expect(page.getByTestId("applications-list-item")).toHaveCount(2);
80
    await expect(
81
      page
82
        .getByTestId("applications-list-item")
83
        .filter({ hasText: "Account Console" }),
84
    ).toBeVisible();
85
    await expect(
86
      page
87
        .getByTestId("applications-list-item")
88
        .filter({ hasText: "security-admin-console" }),
89
    ).toBeVisible();
90
  });
91
});
92

Использование cookies

Мы используем файлы cookie в соответствии с Политикой конфиденциальности и Политикой использования cookies.

Нажимая кнопку «Принимаю», Вы даете АО «СберТех» согласие на обработку Ваших персональных данных в целях совершенствования нашего веб-сайта и Сервиса GitVerse, а также повышения удобства их использования.

Запретить использование cookies Вы можете самостоятельно в настройках Вашего браузера.