feat(webui): expand long drafts and refine chat scrollbars (#6709)
* feat(webui): expand long drafts and refine chat scrollbars * test(webui): synchronize browser setup and isolate locale cases * test(webui): wait for the About fixture before measuring layout
This commit is contained in:
1 parent
db430df3f6
commit
cab49a1c66
20 files changed
+271
-59
No files matched your search
@@ -19,7 +19,8 @@ async function openThread(page: Page) {
|
||||
await page.route("**/api/commands", route => route.fulfill({ json: { commands: [] } }));
|
||||
await page.route("**/api/sessions/*/webui-thread?*", route => route.fulfill({ json: history }));
|
||||
await page.goto("/browser/fixture.html?case=thread-loading");
|
||||
await expect(page.getByRole("heading", { name: "Section 25", exact: true })).toBeVisible();
|
||||
// Let the lazy Markdown renderer settle before measuring transcript geometry.
|
||||
await page.getByRole("heading", { name: "Section 25", exact: true }).waitFor();
|
||||
await page.evaluate(() => document.fonts.ready);
|
||||
const input = page.getByRole("textbox", { name: "Message input", exact: true });
|
||||
await input.fill("Next steps:\n1. Check layout\n2. ");
|
||||
@@ -88,6 +89,52 @@ test("autosizing still grows, caps and shrinks the real input", async ({ page })
|
||||
await expect.poll(() => scroller.evaluate(node => node.scrollHeight - node.clientHeight - node.scrollTop)).toBeLessThanOrEqual(1);
|
||||
});
|
||||
|
||||
for (const viewport of [{ width: 1440, height: 900 }, { width: 390, height: 500 }]) {
|
||||
test(`overflowing drafts can be expanded and collapsed in place at ${viewport.width}px`, async ({ page }) => {
|
||||
await page.setViewportSize(viewport);
|
||||
const { input } = await openThread(page);
|
||||
const expand = page.getByRole("button", { name: "Expand editor" });
|
||||
const collapse = page.getByRole("button", { name: "Collapse editor" });
|
||||
const footer = page.locator(".thread-composer-footer");
|
||||
const selection = () => input.evaluate(node => {
|
||||
const { selectionStart, selectionEnd } = node as HTMLTextAreaElement;
|
||||
return [selectionStart, selectionEnd];
|
||||
});
|
||||
await expect(expand).not.toBeVisible();
|
||||
const draft = ["Which warnings should I fix?", ...Array.from({ length: 11 }, (_, i) => `Line ${i + 1}: build output`)].join("\n");
|
||||
await input.fill(draft);
|
||||
await expect(expand).toBeVisible();
|
||||
const smallHeight = await input.evaluate(node => node.clientHeight);
|
||||
const footerBounds = await footer.boundingBox();
|
||||
await input.press("Control+End");
|
||||
await expect.poll(() => input.evaluate(node => node.scrollTop)).toBeGreaterThan(0);
|
||||
expect(await footer.boundingBox()).toEqual(footerBounds);
|
||||
|
||||
await expand.click();
|
||||
await expect(collapse).toHaveAttribute("aria-expanded", "true");
|
||||
await expect(input).toBeFocused();
|
||||
await expect.poll(() => input.evaluate(node => node.clientHeight)).toBeGreaterThan(smallHeight + 24);
|
||||
expect(await selection()).toEqual([draft.length, draft.length]);
|
||||
const expandedFooter = (await footer.boundingBox())!;
|
||||
expect(expandedFooter.y + expandedFooter.height).toBeLessThanOrEqual(viewport.height);
|
||||
expect(await input.evaluate(node => node.scrollHeight)).toBe(await input.evaluate(node => node.clientHeight));
|
||||
await collapse.click();
|
||||
await expect(expand).toBeVisible();
|
||||
await expect.poll(() => input.evaluate(node => node.scrollHeight - node.clientHeight - node.scrollTop)).toBeLessThanOrEqual(1);
|
||||
|
||||
await expand.click();
|
||||
await input.press("Control+Home");
|
||||
await input.press("Shift+End");
|
||||
const firstLine = [0, draft.indexOf("\n")];
|
||||
expect(await selection()).toEqual(firstLine);
|
||||
await collapse.press("Enter");
|
||||
await expect(input).toBeFocused();
|
||||
await expect(input).toHaveValue(draft);
|
||||
expect(await selection()).toEqual(firstLine);
|
||||
await expect.poll(() => input.evaluate(node => node.clientHeight)).toBe(smallHeight);
|
||||
});
|
||||
}
|
||||
|
||||
test("Chromium IME composition and commit keep the transcript stationary", async ({ page }) => {
|
||||
const { input } = await openThread(page);
|
||||
const original = await input.inputValue();
|
||||
|
||||
Reference in new issue
Block a user