// Import a custom theme JSON in Settings > Appearance; its dark and light backgrounds apply. import assert from "node:assert/strict"; import path from "node:path"; import { mockTauri, outputDir, runSmoke, smokeUrl } from "../_harness/index.mjs"; const name = "appearance/themeImport"; await runSmoke(name, async ({ page }) => { const output = await outputDir(name); await mockTauri(page, { commands: test => ({ ...test.workspace({ root: "C:\\theme-import", files: { "a.md": "# Alpha\n" } }), plugins_snapshot: () => ({ plugins: [], issues: [] }), }), }); await page.goto(smokeUrl + "/?settingsWindow=true"); await page.getByRole("button", { name: "Appearance", exact: true }).click(); const theme = { schema: 1, id: "smoke", name: "Smoke theme", light: { bg: "#fefefe", text: "#222222", accent: "#334499" }, dark: { bg: "#181820", text: "#eeeeee", accent: "#aabbff" } }; const importTheme = () => page.locator('input[type=file][aria-label="Theme JSON file"]').setInputFiles({ name: "smoke.json", mimeType: "application/json", buffer: Buffer.from(JSON.stringify(theme)) }); const background = () => page.evaluate(() => getComputedStyle(document.documentElement).getPropertyValue("--rs-bg").trim()); await importTheme(); await page.waitForFunction(() => document.documentElement.dataset.palette === "custom:smoke"); assert.equal(await background(), "#181820"); // A custom theme now keeps one palette. A schema 1 file converts with the current mode (src/lib/theme/customThemes.ts:38, // src/lib/theme/AppearanceSettings.svelte:70), and the light/dark select became the Color theme menu (AppearanceSettings.svelte:20-31, :113). await page.getByRole("button", { name: "Color theme", exact: true }).click(); await page.getByRole("menuitemradio", { name: "RuneStone Light", exact: true }).click(); await page.waitForFunction(() => document.documentElement.dataset.palette !== "custom:smoke"); await importTheme(); await page.waitForFunction(() => document.documentElement.dataset.palette === "custom:smoke"); assert.equal(await background(), "#fefefe"); await page.screenshot({ path: path.join(output, "custom-theme-light.png") }); console.log("PASS: custom theme import applies its dark and light backgrounds"); }, { timeout: 15000 });