Measure credential cards, dialog and footer across both provider toggles

This commit is contained in:
Tonio committed 2026-12-02 01:00:43 -08:00
1 parent 8eb82c5f9d
commit 832dc257d9
1 file changed
+45
+45
View File
@@ -0,0 +1,45 @@
import { expect, test } from "@playwright/test";
import { json } from "./agent-chat.shared";
test("Connect account keeps the card and footer steady when switching credential methods", async ({ page, request }) => {
await page.setViewportSize({ width: 1440, height: 1200 });
const company = await json(await request.post("/api/companies", { data: { name: `Credential layout ${Date.now()}` } }));
try {
const agent = await json(await request.post(`/api/companies/${company.id}/agents`, { data: {
name: "Layout test", role: "general", adapterType: "claude_local",
} }));
await page.goto(`/${company.issuePrefix}/agents/${agent.id}/runtime`);
const connection = page.getByRole("combobox", { name: "Connection", exact: true });
await connection.or(page.getByRole("button", { name: "Choose a managed connection" })).first().waitFor();
if (!await connection.isVisible()) await page.getByRole("button", { name: "Choose a managed connection" }).click();
await connection.click();
await page.getByRole("option", { name: "Connect an account…" }).click();
const dialog = page.getByRole("dialog", { name: "Connect account" });
const card = dialog.locator("[data-login-card]");
const back = dialog.getByRole("button", { name: "Back", exact: true });
const measure = async () => {
const [frame, panel, footer] = await Promise.all([dialog.boundingBox(), card.boundingBox(), back.boundingBox()]);
return [frame?.height, panel?.height, footer?.y];
};
for (const provider of ["Claude", "OpenAI"]) {
if (provider === "OpenAI") {
await dialog.getByText("Other Models", { exact: true }).click();
await dialog.getByText("OpenAI", { exact: true }).click();
}
await expect(card).toBeVisible();
await expect(back).toBeVisible();
await dialog.getByRole("button", { name: "Use API key instead" }).click();
await expect(dialog.getByPlaceholder("Enter API key here")).toBeVisible();
await back.click({ trial: true });
const apiLayout = await measure();
await dialog.getByRole("button", { name: "Use subscription instead" }).click();
await expect(card).toBeVisible();
await expect.poll(measure).toEqual(apiLayout);
await dialog.getByRole("button", { name: "Use API key instead" }).click();
await expect(dialog.getByPlaceholder("Enter API key here")).toBeVisible();
await expect.poll(measure).toEqual(apiLayout);
}
} finally {
await request.patch(`/api/companies/${company.id}`, { data: { status: "archived" } });
}
});