fix(e2e): dismiss import-models modal after adding connection (sync-models mock + close)

This commit is contained in:
diegosouzapw
2026-06-08 13:12:37 -03:00
parent f112bc966f
commit 11bd96ec5c

View File

@@ -106,6 +106,11 @@ async function installProviderFetchMock(page: Page) {
return jsonResponse({ valid }, valid ? 200 : 400);
}
// Stub sync-models so the import modal reaches "done" immediately after adding a connection
if (path.match(/^\/api\/providers\/[^/]+\/sync-models$/) && method === "POST") {
return jsonResponse({ syncedModels: 0, models: [], availableModelsCount: 0 });
}
const testMatch = path.match(/^\/api\/providers\/([^/]+)\/test$/);
if (testMatch && method === "POST") {
state.retestCalls += 1;
@@ -261,7 +266,14 @@ test.describe("Providers management", () => {
.toBeGreaterThan(0);
await expect(page.getByText("Primary OpenAI")).toBeVisible();
await expect.poll(async () => (await readProviderMockState(page)).connections.length).toBe(1);
await expect(addDialog).not.toBeVisible();
// After save, the UI opens a model-import modal (setShowImportModal). The sync-models
// endpoint is mocked to return instantly (0 models), so the modal reaches "done" phase
// and shows a Close button. Dismiss it before interacting with the connection list.
const importDialog = page.getByRole("dialog");
await expect(importDialog.getByRole("button", { name: "Close" })).toBeVisible({ timeout: 15_000 });
await importDialog.getByRole("button", { name: "Close" }).click();
await expect(importDialog).not.toBeVisible();
await page.getByTitle(/^edit$/i).click();
const editDialog = page.getByRole("dialog");