const assert = require("node:assert/strict"); const fs = require("node:fs"); const path = require("node:path"); const { test } = require("node:test"); const { loadTypeScript } = require("./load-typescript.cjs"); const root = path.resolve(__dirname, ".."); const popupTheme = loadTypeScript( "src/features/windowPopup/model/popupTheme.ts", ); test("SN의 5개 테마와 기존 dark 별칭을 WindowPopup 계약으로 제한", () => { for (const theme of ["white", "blue", "green", "red", "black"]) { assert.equal(popupTheme.resolveWindowPopupTheme(theme), theme); } assert.equal(popupTheme.resolveWindowPopupTheme("dark"), "black"); assert.equal(popupTheme.resolveWindowPopupTheme("unknown"), undefined); }); test("분석도구·SN 폼 컨트롤·페이징의 테마 계약 유지", () => { const analysisMenu = fs.readFileSync( path.join( root, "app/(map-layout)/map/components/analysisMenu/AnalysisPopupMenu.tsx", ), "utf8", ); const standardTableCss = fs.readFileSync( path.resolve( root, "../../packages/common/business_components/src/ui/standard_data_table/standard-data-table.css", ), "utf8", ); const popupCss = fs.readFileSync( path.join(root, "src/app/styles/components.css"), "utf8", ); const procSearchBar = fs.readFileSync( path.resolve( root, "../../packages/common/business_components/src/ui/map/searchBar/procSearchBar.tsx", ), "utf8", ); const buttonCss = fs.readFileSync( path.resolve( root, "../../packages/common/components/src/ui/button/button.css", ), "utf8", ); assert.doesNotMatch(analysisMenu, /bg-white/); assert.doesNotMatch(analysisMenu, /ring-\[#0279FA\]/); assert.match(analysisMenu, /bg-background text-label/); assert.match(analysisMenu, /ring-primary/); assert.match(standardTableCss, /background: var\(--background\) !important/); assert.match(standardTableCss, /color: var\(--foreground\) !important/); assert.doesNotMatch( popupCss, /\.standard-popup-layout button\[role="button"\]\.white/, ); assert.doesNotMatch(procSearchBar, /!bg-white/); assert.match(procSearchBar, /!bg-form/); assert.match(procSearchBar, /!text-foreground/); assert.match( popupCss, /\[data-theme="black"\][\s\S]*button\[role="combobox"\][\s\S]*background-color: var\(--form\) !important/, ); assert.match( popupCss, /button\[role="combobox"\]:disabled[\s\S]*background-color: var\(--field\) !important/, ); assert.match( popupCss, /input\[type="text"\][\s\S]*textarea[\s\S]*background-color: var\(--form\) !important/, ); assert.match( popupCss, /input\[readonly\][\s\S]*textarea\[readonly\][\s\S]*background-color: var\(--field\) !important/, ); assert.match( buttonCss, /button\[role="button"\]\.white[\s\S]*bg-\[rgba\(255,255,255,1\)\]/, ); });