дзеркало
https://github.com/l0ng-ai/openidea.git
синхронізовано 2026-12-05 09:41:34 +02:00
65 рядки
2.8 KiB
TypeScript
65 рядки
2.8 KiB
TypeScript
import { expect, stubDesktop, test } from "./fixtures";
|
|
|
|
for (const theme of ["light", "dark"]) {
|
|
test(`color previews share a column and keep its width while scrolling (${theme})`, async ({ workbench: page }) => {
|
|
await stubDesktop(page);
|
|
await page.evaluate(async (theme) => {
|
|
const backendPath = "/src/editor/core/backend.ts";
|
|
const contributionsPath = "/src/workbench/contributions.ts";
|
|
const themePath = "/src/workbench/theme.ts";
|
|
const { docBackend } = await import(backendPath);
|
|
const { editorService } = await import(contributionsPath);
|
|
const { useThemeOverride } = await import(themePath);
|
|
useThemeOverride.setState({ theme });
|
|
const source = "/dev/acme-api/colors.html";
|
|
const classes = '<div class="bg-one bg-two bg-three bg-four">Colors</div>';
|
|
docBackend().files.set(
|
|
source,
|
|
[
|
|
'<div style="background: linear-gradient(#112233, #445566, #778899, #aabbcc, #ddeeff)">Colors</div>',
|
|
classes,
|
|
...Array.from({ length: 200 }, (_, i) => `<p>Line ${i}</p>`),
|
|
].join("\n"),
|
|
);
|
|
window.__ipc.handlers.window_is_fullscreen = () => false;
|
|
window.__ipc.handlers.lsp_document_colors = () =>
|
|
["bg-one", "bg-two", "bg-three", "bg-four"].map((name) => ({
|
|
server: 7,
|
|
range: {
|
|
start: { line: 1, col: classes.indexOf(name) },
|
|
end: { line: 1, col: classes.indexOf(name) + name.length },
|
|
},
|
|
red: 0.5,
|
|
green: 0.25,
|
|
blue: 1,
|
|
alpha: 1,
|
|
}));
|
|
await editorService().openFile(source);
|
|
}, theme);
|
|
const column = page.locator(".cm-gutter.cm-openidea-gutter-colors");
|
|
await expect(column).toHaveCount(1);
|
|
const literals = column.locator("span[title]");
|
|
const serverColors = column.locator('button[data-color-source^="lsp:"]');
|
|
await expect(literals).toHaveCount(4);
|
|
await expect(serverColors).toHaveCount(4);
|
|
expect((await literals.first().boundingBox())!.x).toBe((await serverColors.first().boundingBox())!.x);
|
|
const width = (await column.boundingBox())!.width;
|
|
expect(width).toBeGreaterThan(0);
|
|
const scroller = page.locator(".cm-scroller");
|
|
for (const size of [
|
|
{ width: 1400, height: 900 },
|
|
{ width: 800, height: 600 },
|
|
]) {
|
|
await page.setViewportSize(size);
|
|
await scroller.evaluate((el) => (el.scrollTop = el.scrollHeight));
|
|
await expect(literals).toHaveCount(0);
|
|
await expect(serverColors).toHaveCount(0);
|
|
await expect.poll(async () => (await column.boundingBox())!.width).toBe(width);
|
|
await scroller.evaluate((el) => (el.scrollTop = 0));
|
|
await expect(literals).toHaveCount(4);
|
|
await expect(serverColors).toHaveCount(4);
|
|
expect((await column.boundingBox())!.width).toBe(width);
|
|
}
|
|
});
|
|
}
|