Skip to content

Commit 1e9a143

Browse files
test(dashboard): Split the conversation views e2e test by feature (#3617)
One dashboard e2e journey, "records loaded conversation views", walked through six separate features of the Conversation page. It was too long to finish reliably on a busy CI runner. - It is now one journey per feature, in both UIs. The image preview journey was the same in both UIs, so it moves to `conversation-attachments.spec.ts`. - The request budget now opens a finished Conversation. A running Conversation polls every 2 seconds, so on a slow load a poll could land inside the budget. No product change. Nothing to do for reviewers beyond the usual review. <!-- junior-request-attribution:start --> via @BYK. <!-- junior-request-attribution:end --> <!-- junior-session-footer:start --> <!-- junior-conversation-id:agent%3A4ff7beb14b0fc44330b5ad54fe9c3664 --> -- [View Session](https://junior-prod.sentry.dev/conversations/agent%3A4ff7beb14b0fc44330b5ad54fe9c3664) [[Sentry]](https://sentry.sentry.io/explore/conversations/agent%3A4ff7beb14b0fc44330b5ad54fe9c3664/?project=4510944073809921) <!-- junior-session-footer:end --> Co-authored-by: sentry-junior[bot] <264270552+sentry-junior[bot]@users.noreply.github.com> Co-authored-by: BYK <[email protected]>
1 parent 13aad59 commit 1e9a143

3 files changed

Lines changed: 195 additions & 216 deletions

File tree

‎packages/junior-dashboard/e2e/conversation-attachments.spec.ts‎

Lines changed: 105 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { readFile } from "node:fs/promises";
22
import { expect, test } from "./test";
3-
import { screenshot } from "./screenshot";
3+
import { desktop, mobile, screenshot } from "./screenshot";
44

55
const DASHBOARD_QA_CONVERSATION_ID = "internal:dashboard-qa";
66

@@ -90,3 +90,107 @@ test("downloads a large Slack file on request", async ({ page, dashboard }) => {
9090
expect(page.url()).toBe(conversationUrl);
9191
await screenshot(page, "conversation-pending-attachment");
9292
});
93+
94+
test("previews conversation images and pages through them", async ({
95+
page,
96+
dashboard,
97+
}) => {
98+
// The previews open on a phone, then each view takes its own shot.
99+
await page.setViewportSize(mobile);
100+
await page.goto(
101+
`${dashboard.baseURL}/conversations/${encodeURIComponent(DASHBOARD_QA_CONVERSATION_ID)}`,
102+
{ waitUntil: "networkidle" },
103+
);
104+
await expect(
105+
page.getByRole("heading", {
106+
name: "Dashboard QA edge cases",
107+
exact: true,
108+
}),
109+
).toBeVisible();
110+
const inputImage = page.getByRole("img", { name: "input-chart.png" });
111+
await inputImage.scrollIntoViewIfNeeded();
112+
await expect(inputImage).toBeVisible();
113+
await inputImage.click();
114+
const inputPreview = page.getByRole("dialog", { name: "input-chart.png" });
115+
await expect(inputPreview).toBeVisible();
116+
// The sent image is not part of the response, so it has no pager.
117+
await expect(
118+
inputPreview.getByRole("button", { name: "Next image" }),
119+
).toHaveCount(0);
120+
await inputPreview
121+
.getByRole("button", { name: "Close", exact: true })
122+
.click();
123+
const image = page
124+
.locator('a[href*="/attachments/qa-chart-png"]')
125+
.filter({ has: page.locator('img[alt="chart.png"]') })
126+
.first();
127+
await image.waitFor({ state: "visible" });
128+
// A resize keeps another scroll position, so center the image in each view.
129+
for (const view of [desktop, mobile]) {
130+
await page.setViewportSize(view);
131+
await image.evaluate((element) =>
132+
element.scrollIntoView({ block: "center", inline: "nearest" }),
133+
);
134+
await screenshot(page, "conversation-attachment", { view: view.name });
135+
}
136+
137+
await image.click();
138+
const preview = page.getByRole("dialog", { name: "chart.png" });
139+
await expect(preview).toBeVisible();
140+
await expect(preview.getByText("1 of 2")).toBeVisible();
141+
await screenshot(page, "conversation-attachment-modal");
142+
// The preview pages through the images of one response.
143+
await preview.getByRole("button", { name: "Next image" }).click();
144+
const detailPreview = page.getByRole("dialog", { name: "chart-detail.png" });
145+
await expect(detailPreview.getByText("2 of 2")).toBeVisible();
146+
await page.keyboard.press("ArrowRight");
147+
await expect(preview.getByText("1 of 2")).toBeVisible();
148+
149+
// Touch readers swipe to page and dismiss, and pinch to zoom. Real touch
150+
// input checks that the frame keeps a gesture after a finger leaves it.
151+
await page.setViewportSize(mobile);
152+
const touch = await page.context().newCDPSession(page);
153+
const pinch = (
154+
type: "touchStart" | "touchMove" | "touchEnd",
155+
points: { id: number; x: number; y: number }[],
156+
) => touch.send("Input.dispatchTouchEvent", { touchPoints: points, type });
157+
const swipe = async (
158+
from: { x: number; y: number },
159+
dx: number,
160+
dy: number,
161+
) => {
162+
await pinch("touchStart", [{ id: 1, ...from }]);
163+
for (const step of [0.25, 0.5, 0.75, 1]) {
164+
await pinch("touchMove", [
165+
{ id: 1, x: from.x + dx * step, y: from.y + dy * step },
166+
]);
167+
}
168+
await pinch("touchEnd", []);
169+
};
170+
await swipe({ x: 300, y: 450 }, -200, 0);
171+
await expect(detailPreview.getByText("2 of 2")).toBeVisible();
172+
await swipe({ x: 100, y: 450 }, 200, 0);
173+
await expect(preview.getByText("1 of 2")).toBeVisible();
174+
// A short swipe springs back, so the preview still pages.
175+
await swipe({ x: 200, y: 300 }, 0, 30);
176+
await page.keyboard.press("ArrowRight");
177+
await expect(detailPreview.getByText("2 of 2")).toBeVisible();
178+
await swipe({ x: 200, y: 300 }, 0, 250);
179+
await expect(detailPreview).toBeHidden();
180+
181+
await image.click();
182+
await expect(preview.getByText("1 of 2")).toBeVisible();
183+
await pinch("touchStart", [
184+
{ id: 1, x: 180, y: 450 },
185+
{ id: 2, x: 210, y: 450 },
186+
]);
187+
await pinch("touchMove", [
188+
{ id: 1, x: 120, y: 450 },
189+
{ id: 2, x: 300, y: 700 },
190+
]);
191+
await pinch("touchEnd", []);
192+
await touch.detach();
193+
await screenshot(page, "conversation-attachment-zoom");
194+
await page.keyboard.press("Escape");
195+
await expect(preview).toBeHidden();
196+
});

‎packages/junior-dashboard/e2e/conversations.spec.ts‎

Lines changed: 49 additions & 103 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,23 @@
1+
import type { Page } from "@playwright/test";
12
import { withRequestedMailbox } from "./harness";
23
import { expectRequestBudget } from "./request-budget";
34
import { expect, test } from "./test";
4-
import { desktop, mobile, screenshot } from "./screenshot";
5+
import { screenshot } from "./screenshot";
56

67
const ACTIVE_CONVERSATION_ID = "slack:CQA123:1770003600.000200";
7-
const DASHBOARD_QA_CONVERSATION_ID = "internal:dashboard-qa";
8+
const FINISHED_CONVERSATION_ID = "slack:CQA777:1770014400.000500";
9+
10+
async function openActiveConversation(page: Page, baseURL: string) {
11+
await page.goto(
12+
`${baseURL}/conversations/${encodeURIComponent(ACTIVE_CONVERSATION_ID)}`,
13+
);
14+
await expect(
15+
page.getByRole("heading", {
16+
name: "Investigate checkout latency",
17+
exact: true,
18+
}),
19+
).toBeVisible();
20+
}
821

922
test("records loaded conversation views", async ({ page, dashboard }) => {
1023
let releaseFeed: (() => void) | undefined;
@@ -30,22 +43,31 @@ test("records loaded conversation views", async ({ page, dashboard }) => {
3043
await expect(composer).toBeFocused();
3144
await screenshot(page, "conversation-create-focused");
3245

46+
// A running Conversation polls every 2 seconds, so a slow load would
47+
// count a poll. Measure a finished one, which does not poll its detail.
3348
await expectRequestBudget(
3449
page,
3550
async () => {
3651
await page.goto(
37-
`${dashboard.baseURL}/conversations/${encodeURIComponent(ACTIVE_CONVERSATION_ID)}`,
52+
`${dashboard.baseURL}/conversations/${encodeURIComponent(FINISHED_CONVERSATION_ID)}`,
3853
{ waitUntil: "networkidle" },
3954
);
4055
await expect(
4156
page.getByRole("heading", {
42-
name: "Investigate checkout latency",
57+
name: "Deployment investigation failed",
4358
exact: true,
4459
}),
4560
).toBeVisible();
4661
},
47-
{ requests: 10, serialRounds: 2 },
62+
{ requests: 9, serialRounds: 2 },
4863
);
64+
});
65+
66+
test("keeps the conversation list choice and width after a reload", async ({
67+
page,
68+
dashboard,
69+
}) => {
70+
await openActiveConversation(page, dashboard.baseURL);
4971
const conversationList = page.getByRole("navigation", {
5072
name: "Your conversations",
5173
});
@@ -84,6 +106,13 @@ test("records loaded conversation views", async ({ page, dashboard }) => {
84106
await expect(conversationList).toBeVisible();
85107
// The saved width rounds to whole pixels.
86108
await expect.poll(listSize).toBeCloseTo(resizedSize, 0);
109+
});
110+
111+
test("keeps the details panel width and usage after a reload", async ({
112+
page,
113+
dashboard,
114+
}) => {
115+
await openActiveConversation(page, dashboard.baseURL);
87116

88117
await page
89118
.getByRole("button", { name: "Conversation details", exact: true })
@@ -117,7 +146,21 @@ test("records loaded conversation views", async ({ page, dashboard }) => {
117146
await expect(modelBreakdown).toBeVisible();
118147
await usage.click();
119148
await expect(modelBreakdown).toBeHidden();
120-
// Turn context takes the details panel and gives it back on close.
149+
});
150+
151+
test("turn context takes the details panel and gives it back", async ({
152+
page,
153+
dashboard,
154+
}) => {
155+
await openActiveConversation(page, dashboard.baseURL);
156+
await page
157+
.getByRole("button", { name: "Conversation details", exact: true })
158+
.click();
159+
const details = page.getByRole("complementary", {
160+
name: "Conversation details",
161+
exact: true,
162+
});
163+
await expect(details).toBeVisible();
121164
const contextAction = page.getByRole("button", { name: "View turn context" });
122165
await contextAction.scrollIntoViewIfNeeded();
123166
await contextAction.focus();
@@ -170,103 +213,6 @@ test("records loaded conversation views", async ({ page, dashboard }) => {
170213
await expect(contextSheet).toBeHidden();
171214
await expect(contextAction).toBeFocused();
172215
await screenshot(page, "conversation-detail");
173-
174-
await page.goto(
175-
`${dashboard.baseURL}/conversations/${encodeURIComponent(DASHBOARD_QA_CONVERSATION_ID)}`,
176-
{ waitUntil: "networkidle" },
177-
);
178-
await expect(
179-
page.getByRole("heading", {
180-
name: "Dashboard QA edge cases",
181-
exact: true,
182-
}),
183-
).toBeVisible();
184-
const inputImage = page.getByRole("img", { name: "input-chart.png" });
185-
await inputImage.scrollIntoViewIfNeeded();
186-
await expect(inputImage).toBeVisible();
187-
await inputImage.click();
188-
const inputPreview = page.getByRole("dialog", { name: "input-chart.png" });
189-
await expect(inputPreview).toBeVisible();
190-
// The sent image is not part of the response, so it has no pager.
191-
await expect(
192-
inputPreview.getByRole("button", { name: "Next image" }),
193-
).toHaveCount(0);
194-
await inputPreview
195-
.getByRole("button", { name: "Close", exact: true })
196-
.click();
197-
const image = page
198-
.locator('a[href*="/attachments/qa-chart-png"]')
199-
.filter({ has: page.locator('img[alt="chart.png"]') })
200-
.first();
201-
await image.waitFor({ state: "visible" });
202-
// A resize keeps another scroll position, so center the image in each view.
203-
for (const view of [desktop, mobile]) {
204-
await page.setViewportSize(view);
205-
await image.evaluate((element) =>
206-
element.scrollIntoView({ block: "center", inline: "nearest" }),
207-
);
208-
await screenshot(page, "conversation-attachment", { view: view.name });
209-
}
210-
211-
await image.click();
212-
const preview = page.getByRole("dialog", { name: "chart.png" });
213-
await expect(preview).toBeVisible();
214-
await expect(preview.getByText("1 of 2")).toBeVisible();
215-
await screenshot(page, "conversation-attachment-modal");
216-
// The preview pages through the images of one response.
217-
await preview.getByRole("button", { name: "Next image" }).click();
218-
const detailPreview = page.getByRole("dialog", { name: "chart-detail.png" });
219-
await expect(detailPreview.getByText("2 of 2")).toBeVisible();
220-
await page.keyboard.press("ArrowRight");
221-
await expect(preview.getByText("1 of 2")).toBeVisible();
222-
223-
// Touch readers swipe to page and dismiss, and pinch to zoom. Real touch
224-
// input checks that the frame keeps a gesture after a finger leaves it.
225-
await page.setViewportSize(mobile);
226-
const touch = await page.context().newCDPSession(page);
227-
const pinch = (
228-
type: "touchStart" | "touchMove" | "touchEnd",
229-
points: { id: number; x: number; y: number }[],
230-
) => touch.send("Input.dispatchTouchEvent", { touchPoints: points, type });
231-
const swipe = async (
232-
from: { x: number; y: number },
233-
dx: number,
234-
dy: number,
235-
) => {
236-
await pinch("touchStart", [{ id: 1, ...from }]);
237-
for (const step of [0.25, 0.5, 0.75, 1]) {
238-
await pinch("touchMove", [
239-
{ id: 1, x: from.x + dx * step, y: from.y + dy * step },
240-
]);
241-
}
242-
await pinch("touchEnd", []);
243-
};
244-
await swipe({ x: 300, y: 450 }, -200, 0);
245-
await expect(detailPreview.getByText("2 of 2")).toBeVisible();
246-
await swipe({ x: 100, y: 450 }, 200, 0);
247-
await expect(preview.getByText("1 of 2")).toBeVisible();
248-
// A short swipe springs back, so the preview still pages.
249-
await swipe({ x: 200, y: 300 }, 0, 30);
250-
await page.keyboard.press("ArrowRight");
251-
await expect(detailPreview.getByText("2 of 2")).toBeVisible();
252-
await swipe({ x: 200, y: 300 }, 0, 250);
253-
await expect(detailPreview).toBeHidden();
254-
255-
await image.click();
256-
await expect(preview.getByText("1 of 2")).toBeVisible();
257-
await pinch("touchStart", [
258-
{ id: 1, x: 180, y: 450 },
259-
{ id: 2, x: 210, y: 450 },
260-
]);
261-
await pinch("touchMove", [
262-
{ id: 1, x: 120, y: 450 },
263-
{ id: 2, x: 300, y: 700 },
264-
]);
265-
await pinch("touchEnd", []);
266-
await touch.detach();
267-
await screenshot(page, "conversation-attachment-zoom");
268-
await page.keyboard.press("Escape");
269-
await expect(preview).toBeHidden();
270216
});
271217

272218
test("reuses the fresh conversation feed after window focus", async ({

0 commit comments

Comments
 (0)