perf(webui): reduce file activity layout work (#6587)
This commit is contained in:
1 parent
3404fe83e2
commit
94bfd3ff7d
6 files changed
+98
-17
No files matched your search
@@ -22,6 +22,15 @@ async function expectTokenColor(section: Locator, text: string, variable: string
|
||||
}, { text, variable })).toBe(true);
|
||||
}
|
||||
|
||||
async function expectExpandedDiff(section: Locator) {
|
||||
const wrapper = section.getByTestId("syntax-highlighted-diff-hunk");
|
||||
// Expansion updates the window and its spacers on the next animation frame.
|
||||
await expect.poll(() => wrapper.evaluate(node => {
|
||||
const rowHeight = Math.floor((parseFloat(getComputedStyle(node).lineHeight) + 2) * 64) / 64;
|
||||
return node.getBoundingClientRect().height >= 600 * rowHeight - 1;
|
||||
})).toBe(true);
|
||||
}
|
||||
|
||||
for (const dark of [false, true]) {
|
||||
for (const narrow of [false, true]) {
|
||||
test(`read-only diffs preserve source, colors and reading sizes: ${dark ? "dark" : "light"}, ${narrow ? "narrow" : "desktop"}`, async ({ page }) => {
|
||||
@@ -94,6 +103,7 @@ test("large diffs retain bounded expansion, release and truncated-file actions",
|
||||
await expect(long.locator("[data-code] [data-line]")).toHaveCount(160);
|
||||
await expect(long.locator("[data-code] [data-line]").last()).toHaveText('export const item160 = "第 160 行 — readable code";');
|
||||
await long.getByTestId("file-edit-diff-expand-lines").click();
|
||||
await expectExpandedDiff(long);
|
||||
const scroller = page.getByTestId("diff-fixture-scroller");
|
||||
const seen = new Set<number>();
|
||||
const height = await scroller.evaluate(node => node.scrollHeight);
|
||||
@@ -135,6 +145,7 @@ for (const file of ["worker.ts", "long-separated.ts"]) {
|
||||
await expect(section.locator("[data-code] [data-line]")).toHaveCount(160);
|
||||
await expectKeywordColor(section.locator("[data-code] [data-line]"));
|
||||
await section.getByTestId("file-edit-diff-expand-lines").click();
|
||||
await expectExpandedDiff(section);
|
||||
const scroller = page.getByTestId("diff-fixture-scroller");
|
||||
const seen = new Set<number>();
|
||||
const height = await scroller.evaluate(node => node.scrollHeight);
|
||||
@@ -180,6 +191,7 @@ for (const [file, renderedIndex, sourceLine, reverse] of [["long.ts", 58, 59, fa
|
||||
await section.getByTestId("file-edit-diff-toggle").click();
|
||||
await expectKeywordColor(section.locator("[data-code] [data-line]"));
|
||||
await section.getByTestId("file-edit-diff-expand-lines").click();
|
||||
await expectExpandedDiff(section);
|
||||
const scroller = page.getByTestId("diff-fixture-scroller");
|
||||
const height = await scroller.evaluate(node => node.scrollHeight);
|
||||
await section.getByTestId("syntax-highlighted-diff-hunk").evaluate((node, index) => {
|
||||
|
||||
Reference in new issue
Block a user