mirror of
https://github.com/snapotter-hq/SnapOtter.git
synced 2026-08-03 07:46:42 +02:00
Adds a prefilled 'Request a tool' affordance to the home search empty state and beneath weak results. Opens the in-app feedback dialog with a new search_miss source and a structured search_query when analytics is on; links to a prefilled GitHub Discussions (Ideas) post when off, so a request is never silently dropped. Reuses the existing feedback pipe, dialog, and analytics gate; no new storage. i18n across all 21 locales.
54 lines
2.0 KiB
TypeScript
54 lines
2.0 KiB
TypeScript
import { expect, test } from "@playwright/test";
|
|
|
|
test.describe("search-miss tool request", () => {
|
|
test("offers a request when a search finds nothing", async ({ page }) => {
|
|
await page.goto("/");
|
|
|
|
const searchInput = page.locator("[data-search-input]");
|
|
await expect(searchInput).toBeVisible();
|
|
await searchInput.fill("zzxqwv nonexistent capability");
|
|
|
|
const request = page.getByTestId("request-tool").first();
|
|
await expect(request).toBeVisible();
|
|
|
|
const href = await request.getAttribute("href");
|
|
if (href) {
|
|
expect(href).toContain("/discussions/new");
|
|
expect(href).toContain("category=ideas");
|
|
} else {
|
|
await request.click();
|
|
const dialog = page.getByRole("dialog");
|
|
await expect(dialog).toBeVisible();
|
|
await expect(dialog).toContainText("Request a tool");
|
|
}
|
|
});
|
|
|
|
test("opens the in-app request dialog when analytics is enabled", async ({ page }) => {
|
|
// Force the client to see analytics as enabled so the affordance renders as an
|
|
// in-app dialog trigger instead of a Discussions link. Merge with the real
|
|
// config response so unrelated fields stay intact.
|
|
await page.route("**/api/v1/config/analytics", async (route) => {
|
|
const response = await route.fetch();
|
|
const body = await response.json();
|
|
await route.fulfill({ json: { ...body, enabled: true } });
|
|
});
|
|
|
|
await page.goto("/");
|
|
|
|
const searchInput = page.locator("[data-search-input]");
|
|
await expect(searchInput).toBeVisible();
|
|
await searchInput.fill("zzxqwv nonexistent capability");
|
|
|
|
const request = page.getByTestId("request-tool").first();
|
|
await expect(request).toBeVisible();
|
|
// With analytics "on" the affordance is a button (no href) that opens the dialog.
|
|
await expect(request).not.toHaveAttribute("href", /.+/);
|
|
await request.click();
|
|
|
|
const dialog = page.getByRole("dialog");
|
|
await expect(dialog).toBeVisible();
|
|
await expect(dialog).toContainText("Request a tool");
|
|
await expect(dialog).toContainText("zzxqwv nonexistent capability");
|
|
});
|
|
});
|