From 634bebcd5e8e7ade1a54f1d2aa1596487bf472ad Mon Sep 17 00:00:00 2001 From: Craig Jennings Date: Mon, 8 Jun 2026 22:08:47 -0500 Subject: test(theme-studio): make generate.py importable and test the templating The page generator's risky logic, the export-strip that inlines colormath.js and the placeholder substitution that fills in the sample and palette data, had no tests. A bug there ships a broken theme-studio.html the JS tests can't see, since they import colormath.js directly and never look at the assembled page. I pulled the strip into a strip_exports function and guarded the file write behind __main__, so importing generate.py builds the page in memory without writing it. test_generate.py asserts the strip removes export lines, preserves the body, and rstrips. It asserts the assembled page has every placeholder filled and carries the colormath body verbatim. And it guards that colormath.js keeps its export on a single line, since the line-based strip would leave a multi-line export's continuation behind. That was the exact failure that bit during the first integration. --- scripts/theme-studio/generate.py | 27 +++++++---- scripts/theme-studio/test_generate.py | 84 +++++++++++++++++++++++++++++++++++ 2 files changed, 102 insertions(+), 9 deletions(-) create mode 100644 scripts/theme-studio/test_generate.py diff --git a/scripts/theme-studio/generate.py b/scripts/theme-studio/generate.py index e2d72acd..e6926e04 100644 --- a/scripts/theme-studio/generate.py +++ b/scripts/theme-studio/generate.py @@ -1,13 +1,20 @@ import json, os HERE=os.path.dirname(os.path.abspath(__file__)) + +def strip_exports(src): + """Drop ES-module `export` lines so the body loads as a classic "), 1) + + +if __name__ == "__main__": + unittest.main() -- cgit v1.2.3