1
0
forked from baron/baron-sso
Files
baron-sso/devfront/tests/devfront-relationships.spec.ts
2026-04-20 15:48:42 +09:00

64 lines
1.9 KiB
TypeScript

import { expect, test } from "@playwright/test";
import {
type ClientRelation,
type Consent,
installDevApiMock,
makeClient,
seedAuth,
} from "./helpers/devfront-fixtures";
import { captureEvidence } from "./helpers/evidence";
test.describe("DevFront relationships", () => {
test.afterEach(async ({ page }, testInfo) => {
if (testInfo.status === "passed") {
await captureEvidence(page, testInfo, testInfo.title);
}
});
test.beforeEach(async ({ page }) => {
page.on("dialog", async (dialog) => {
await dialog.accept();
});
await seedAuth(page, "rp_admin");
});
test("list add and remove direct RP relationships", async ({ page }) => {
const state = {
clients: [makeClient("client-rel", { name: "Relations app" })],
consents: [] as Consent[],
relations: {
"client-rel": [
{
relation: "config_editor",
subject: "User:user-1",
subjectType: "User",
subjectId: "user-1",
},
] satisfies ClientRelation[],
},
auditLogsByCursor: undefined,
};
await installDevApiMock(page, state);
await page.goto("/clients/client-rel/relationships");
await expect(page.getByText("Client Relationships")).toBeVisible();
await expect(page.getByText("User:user-1")).toBeVisible();
await page.getByLabel(/Relation/i).selectOption("secret_rotator");
await page.getByLabel(/User ID/i).fill("user-2");
await page.getByRole("button", { name: /^Add$/i }).click();
await expect(page.getByText("User:user-2")).toBeVisible();
await expect.poll(() => state.relations["client-rel"]?.length ?? 0).toBe(2);
await page
.locator("tr")
.filter({ hasText: "User:user-2" })
.getByRole("button", { name: /Delete|삭제/i })
.click();
await expect(page.getByText("User:user-2")).toHaveCount(0);
await expect.poll(() => state.relations["client-rel"]?.length ?? 0).toBe(1);
});
});