test(auth): gate local and OIDC authentication release
This commit is contained in:
+32
-9
@@ -1,4 +1,5 @@
|
||||
import { test, expect } from "@playwright/test";
|
||||
import { expect, test, type Page } from "@playwright/test";
|
||||
import { createAuthenticationStack } from "./fixtures/auth-stack.mjs";
|
||||
|
||||
/**
|
||||
* E2E F1 loop — hermetic (no VPN, no real Pi, no real Python).
|
||||
@@ -9,20 +10,42 @@ import { test, expect } from "@playwright/test";
|
||||
* which emits the f1_disambiguation.json scenario (select widget with
|
||||
* "interpretazione A" / "interpretazione B").
|
||||
*
|
||||
* Flow: open app → open NewSessionDialog → fill question → submit (Crea)
|
||||
* Flow: authenticate locally → focus the new-session composer → fill question → submit (Send)
|
||||
* → wait for F1 select widget → click an option → assert no error shown.
|
||||
*/
|
||||
test("F1 loop: new question → F1 widget → respond", async ({ page }) => {
|
||||
await page.goto("/");
|
||||
test.describe.configure({ mode: "serial" });
|
||||
|
||||
// Open the new-session dialog.
|
||||
await page.getByRole("button", { name: /nuova/i }).click();
|
||||
let stack: Awaited<ReturnType<typeof createAuthenticationStack>>;
|
||||
|
||||
test.beforeAll(async () => {
|
||||
stack = await createAuthenticationStack({ withF1Workspace: true });
|
||||
await stack.useLocalMode();
|
||||
});
|
||||
|
||||
test.afterAll(async () => {
|
||||
await stack?.close();
|
||||
});
|
||||
|
||||
async function signInLocally(page: Page): Promise<void> {
|
||||
const account = stack.localAccount("ordinary");
|
||||
await page.getByLabel("Username").fill(account.username);
|
||||
await page.getByLabel("Password").fill(account.password);
|
||||
await page.getByRole("button", { name: "Sign in", exact: true }).click();
|
||||
await expect(page.getByTestId("app-shell")).toBeVisible({ timeout: 30_000 });
|
||||
}
|
||||
|
||||
test("F1 loop: new question → F1 widget → respond", async ({ page }) => {
|
||||
await page.goto(stack.publicUrl);
|
||||
await signInLocally(page);
|
||||
|
||||
// Focus the composer for a new session.
|
||||
await page.getByRole("button", { name: "New session", exact: true }).click();
|
||||
|
||||
// Fill in the question.
|
||||
await page.getByLabel(/domanda/i).fill("quante cardioversioni nel 2024");
|
||||
await page.getByLabel("New question").fill("quante cardioversioni nel 2024");
|
||||
|
||||
// Submit — the backend creates the session (fake-tht) and spawns Pi (fake-pi).
|
||||
await page.getByRole("button", { name: /^crea$/i }).click();
|
||||
await page.getByRole("button", { name: "Send", exact: true }).click();
|
||||
|
||||
// Wait for the F1 disambiguation select widget to appear.
|
||||
// The fake-pi emits extension_ui_request → backend bridges to SSE → frontend
|
||||
@@ -41,5 +64,5 @@ test("F1 loop: new question → F1 widget → respond", async ({ page }) => {
|
||||
await expect(
|
||||
page.getByRole("button", { name: /interpretazione A/i }),
|
||||
).not.toBeVisible({ timeout: 10_000 });
|
||||
await expect(page.locator("body")).not.toContainText(/errore/i);
|
||||
await expect(page.locator("body")).not.toContainText(/error/i);
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user