mirror of
https://github.com/l0ng-ai/openidea.git
synced 2026-11-24 08:03:19 +00:00
The e2e TypeScript project was never type checked: its tsconfig didn't inherit the app's settings, so @/ imports didn't resolve and hundreds of diagnostics went unnoticed. e2e/tsconfig.json now extends the root config (plus Node/Vite types and ES2024), pnpm typecheck runs tsrs -p e2e, and the remaining real type errors in the specs and fixtures are fixed; the code-style docs list the new project. Co-authored-by: Mr0Bread <55754540+Mr0Bread@users.noreply.github.com>
81 lines
3.9 KiB
TypeScript
81 lines
3.9 KiB
TypeScript
import { readFileSync } from "node:fs";
|
|
import type * as EditorBackend from "../src/editor/core/backend";
|
|
import { expect, test } from "./fixtures";
|
|
|
|
const xml = readFileSync(
|
|
process.env.OPENIDEA_ICLS_FIXTURE ?? "src/platform/__fixtures__/colorSchemes/monokai-php.icls",
|
|
"utf8",
|
|
);
|
|
|
|
test("imported PHP colours stay separate from Java and preserve regular text on a dark background", async ({
|
|
workbench: page,
|
|
}, info) => {
|
|
await page.evaluate(async (xml) => {
|
|
// Load the workbench modules in the browser's Vite realm.
|
|
const iclsPath = "/src/platform/icls.ts";
|
|
const projectPath = "/src/platform/project.ts";
|
|
const backendPath = "/src/editor/core/backend.ts";
|
|
const contributionsPath = "/src/workbench/contributions.ts";
|
|
const { parseIcls } = await import(iclsPath);
|
|
const { useProject } = await import(projectPath);
|
|
const { docBackend }: typeof EditorBackend = await import(backendPath);
|
|
const { editorService } = await import(contributionsPath);
|
|
const previous = useProject.getState().settings ?? {};
|
|
useProject.setState({
|
|
settings: {
|
|
...previous,
|
|
editor: {
|
|
...previous.editor,
|
|
colorScheme: "custom-php",
|
|
customSchemes: { "custom-php": parseIcls(xml).scheme },
|
|
semanticHighlighting: false,
|
|
},
|
|
},
|
|
});
|
|
const backend = docBackend();
|
|
if (!("files" in backend) || !(backend.files instanceof Map)) throw new Error("Expected the in-memory backend");
|
|
const open = backend.open.bind(backend);
|
|
backend.open = async (path) => {
|
|
const result = await open(path);
|
|
return path.endsWith(".php") ? { ...result, language: "php", uiMode: "PHP" } : result;
|
|
};
|
|
backend.files.set(
|
|
"/dev/acme-api/palette.php",
|
|
"<?php\n/** Plain PHP documentation */\nclass Palette extends BasePalette {\n var $name = 'Palette';\n function example($value) {\n return $this->name == 10;\n }\n}\n",
|
|
);
|
|
await editorService().openFile("/dev/acme-api/palette.php");
|
|
}, xml);
|
|
const php = page.locator('.cm-editor[data-language="PHP"]');
|
|
await expect(php).toBeVisible();
|
|
await expect(php).toHaveCSS("background-color", "rgb(0, 0, 0)");
|
|
const token = (text: string) =>
|
|
php
|
|
.locator(".cm-content span")
|
|
.filter({ hasText: text })
|
|
.filter({ hasNot: php.locator("span span") });
|
|
await expect(token("$name").first()).toHaveCSS("color", "rgb(72, 216, 238)");
|
|
await expect(token("'Palette'")).toHaveCSS("color", "rgb(255, 231, 146)");
|
|
await expect(token("'Palette'")).toHaveCSS("font-weight", "400");
|
|
await expect(token("class").first()).toHaveCSS("color", "rgb(249, 38, 114)");
|
|
await expect(token("Plain PHP documentation").first()).toHaveCSS("font-style", "normal");
|
|
await expect(token("BasePalette")).toHaveCSS("color", "rgb(174, 129, 255)");
|
|
await expect(token(";").first()).toHaveCSS("color", "rgb(255, 255, 255)");
|
|
await expect(token("example")).toHaveCSS("color", "rgb(141, 225, 45)");
|
|
await expect(token("$name").first()).toHaveCSS("font-weight", "700");
|
|
await page.evaluate(async () => {
|
|
const backendPath = "/src/editor/core/backend.ts";
|
|
const contributionsPath = "/src/workbench/contributions.ts";
|
|
const { docBackend } = await import(backendPath);
|
|
const { editorService } = await import(contributionsPath);
|
|
docBackend().files.set("/dev/acme-api/Palette.java", 'class Palette { String name = "Palette"; }');
|
|
await editorService().openFile("/dev/acme-api/Palette.java");
|
|
});
|
|
const java = page.locator('.cm-editor[data-language="Java"]');
|
|
await expect(java).toBeVisible();
|
|
await expect(java.locator(".cm-content span").filter({ hasText: '"Palette"' })).toHaveCSS("font-weight", "700");
|
|
await page.getByRole("tab", { name: "palette.php", exact: true }).click();
|
|
await expect(php).toBeVisible();
|
|
await expect(token("'Palette'")).toHaveCSS("font-weight", "400");
|
|
await php.screenshot({ path: info.outputPath("php-import.png"), animations: "disabled" });
|
|
});
|