test(ui): strengthen dashboard journey assertions

This commit is contained in:
Yuneng Jiang 2026-09-17 23:06:17 -07:00
parent 1fea84a2a4
commit 8d1ca16652
No known key found for this signature in database
4 changed files with 24 additions and 27 deletions

View file

@ -13,6 +13,7 @@ test.describe("Prompt upload form", () => {
page,
}) => {
const promptId = `e2e-prompt-${uniqueSuffix()}`;
const promptContent = "Hello {{name}}";
await navigateToPage(page, DashboardPage.Prompts);
await page.getByRole("button", { name: "Upload .prompt File" }).click();
@ -25,7 +26,7 @@ test.describe("Prompt upload form", () => {
name: "e2e.prompt",
mimeType: "text/plain",
buffer: Buffer.from(
'model: fake-openai-gpt-4\ntemplate: "Hello {{name}}"\n',
`model: fake-openai-gpt-4\ntemplate: "${promptContent}"\n`,
),
});
await expect(page.getByText("Selected: e2e.prompt")).toBeVisible();
@ -39,17 +40,22 @@ test.describe("Prompt upload form", () => {
headers: { Authorization: `Bearer ${masterKey()}` },
},
);
return response.ok();
if (!response.ok()) return undefined;
const promptInfo = (await response.json()) as {
raw_prompt_template?: { content?: string };
};
return promptInfo.raw_prompt_template?.content;
})
.toBe(true);
.toContain(promptContent);
await expect(page.getByText(promptId, { exact: true })).toBeVisible();
} finally {
await page.request.delete(
const deleteResponse = await page.request.delete(
`/prompts/${encodeURIComponent(promptId)}?environment=development`,
{
headers: { Authorization: `Bearer ${masterKey()}` },
},
);
expect(deleteResponse.ok()).toBe(true);
}
});
});

View file

@ -64,13 +64,14 @@ test.describe("Tag management", () => {
})
.toBe(updatedDescription);
} finally {
await page.request.post("/tag/delete", {
const deleteResponse = await page.request.post("/tag/delete", {
headers: {
Authorization: `Bearer ${masterKey()}`,
"Content-Type": "application/json",
},
data: { name: tagName },
});
expect(deleteResponse.ok()).toBe(true);
}
});
});

View file

@ -421,27 +421,18 @@ describe("PaginatedSearchSelect", () => {
}),
enabled: query.length > 0,
});
return (
<>
<button type="button" onClick={() => setQuery("A")}>
Search A
</button>
<button type="button" onClick={() => setQuery("B")}>
Search B
</button>
<PaginatedSearchSelect options={result.data ?? []} onValueChange={vi.fn()} onSearchChange={setQuery} />
</>
);
return <PaginatedSearchSelect options={result.data ?? []} onValueChange={vi.fn()} onSearchChange={setQuery} />;
}
const user = userEvent.setup();
render(<QueryBackedSelect />);
await user.click(screen.getByRole("button", { name: "Search A" }));
await user.click(screen.getByRole("button", { name: "Search B" }));
await waitFor(() => {
expect(pending.has("A")).toBe(true);
expect(pending.has("B")).toBe(true);
});
const input = screen.getByRole("combobox");
await user.click(input);
await user.type(input, "A");
await waitFor(() => expect(pending.has("A")).toBe(true));
await user.clear(input);
await user.type(input, "B");
await waitFor(() => expect(pending.has("B")).toBe(true));
pending.get("B")?.([{ label: "B result", value: "b" }]);
await user.click(screen.getByRole("combobox"));

View file

@ -112,7 +112,7 @@ describe("SearchSelect", () => {
expect(onValueChange).not.toHaveBeenCalled();
});
it("supports keyboard select, clear, escape, blur, and reopen", async () => {
it("supports keyboard select, clear, and reselect", async () => {
const onValueChange = vi.fn();
const user = userEvent.setup();
function Controlled() {
@ -139,9 +139,8 @@ describe("SearchSelect", () => {
clear.focus();
await user.keyboard("{Enter}");
expect(onValueChange).toHaveBeenLastCalledWith(null);
await user.keyboard("{Escape}");
await user.tab();
await user.tab({ shift: true });
expect(input).toHaveFocus();
input.focus();
await user.keyboard("{Enter}{ArrowDown}{Enter}");
expect(onValueChange).toHaveBeenLastCalledWith("team-1");
});
});