mirror of
https://github.com/paperclipai/paperclip.git
synced 2026-12-03 20:09:33 +01:00
Measure when users see a reply to their onboarding chat input (#23574)
This commit is contained in:
1 parent
2b65b97cae
commit
b0f682b66b
17 files changed
+367
-7
No files matched your search
@@ -324,6 +324,59 @@ test.describe("Chat launch after onboarding wizard", () => {
|
||||
await page.screenshot({ path: test.info().outputPath("onboarding-chat.png"), fullPage: true });
|
||||
});
|
||||
|
||||
test.describe("browser analytics", () => {
|
||||
test.use({ serviceWorkers: "block" });
|
||||
|
||||
for (const input of ["composer", "welcome answer"] as const) {
|
||||
test(`measures the first displayed reply to the onboarding ${input}`, async ({ page, baseURL }) => {
|
||||
test.setTimeout(180_000);
|
||||
await installLaunchIntercepts(page, baseURL, true);
|
||||
await page.route("**/api/auth/get-session", async route => {
|
||||
const response = await route.fetch();
|
||||
const session = await response.json();
|
||||
await route.fulfill({ response, json: { ...session, browserAnalytics: {
|
||||
token: "test", apiHost: "/analytics-fixture", uiHost: null, environment: "test",
|
||||
stackId: "test", replayEnabled: false,
|
||||
} } });
|
||||
});
|
||||
const captures: { actor: string; properties: Record<string, string> }[] = [];
|
||||
await page.exposeFunction("recordChatDisplay", (actor: string, properties: Record<string, string>) => {
|
||||
captures.push({ actor, properties });
|
||||
});
|
||||
await page.route("**/analytics-fixture/static/array.js", route => route.fulfill({
|
||||
contentType: "text/javascript",
|
||||
body: `window.posthog = { init() {}, register() {}, group() {}, reset() {}, identify(id) { this.actor = id; },
|
||||
capture(event, properties) { if (event === 'agent_chat_reply_displayed') window.recordChatDisplay(this.actor, properties); } };`,
|
||||
}));
|
||||
await runOnboardingWizard(page, `E2E-ChatDisplay-${Date.now()}`);
|
||||
await expect(page).toHaveURL(/\/chats\/[^/]+$/);
|
||||
const choices = page.getByTestId("task-chat-composer-takeover");
|
||||
const sent = page.waitForRequest(req => req.url().endsWith("/api/onboarding/telemetry")
|
||||
&& req.postDataJSON()?.event === "agent_chat_message_sent");
|
||||
if (input === "composer") {
|
||||
await choices.getByRole("button", { name: /^Dismiss / }).click();
|
||||
const editor = page.getByTestId("task-chat-composer-input").locator('[contenteditable="true"]');
|
||||
await editor.fill("build a website");
|
||||
await page.getByTestId("task-chat-composer-send").click();
|
||||
} else {
|
||||
await choices.getByRole("radio", { name: "Interview me about my goals" }).click();
|
||||
expect(captures).toHaveLength(0);
|
||||
await choices.getByRole("button", { name: /send|submit|continue/i }).click();
|
||||
}
|
||||
const reply = input === "composer" ? typedFixtureReply : choiceReplies.interview;
|
||||
const { chatId, messageId } = (await sent).postDataJSON();
|
||||
expect(chatId).toBeTruthy();
|
||||
expect(messageId).toBeTruthy();
|
||||
await expect(page.getByText(reply, { exact: true })).toBeVisible({ timeout: 30_000 });
|
||||
await expect.poll(() => captures).toEqual([{ actor: "local-board",
|
||||
properties: { surface: "onboarding_chat", reply_kind: "response_to_user", chat_id: chatId, message_id: messageId } }]);
|
||||
await page.reload();
|
||||
await expect(page.getByText(reply, { exact: true })).toBeVisible();
|
||||
expect(captures).toHaveLength(1);
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
test("warms the welcome during review, then animates it before showing the real choice card", async ({ page, baseURL }) => {
|
||||
test.setTimeout(180_000);
|
||||
await installLaunchIntercepts(page, baseURL, true);
|
||||
|
||||
Reference in new issue
Block a user