Remove seasonal styles and selectors, migrate retired browser preferences, and retain the original purple/green options and dark-mode controls. Preserve VIP and other theme features. Authorized for the independent FUC-XB test instance only.
28 lines
1.9 KiB
JavaScript
28 lines
1.9 KiB
JavaScript
import test from 'node:test';
|
|
import assert from 'node:assert/strict';
|
|
import {JSDOM} from '../../codex/output/fuc-theme/test-tools/node_modules/jsdom/lib/api.js';
|
|
import {getPalette,applyPalette} from '../../theme/Fuc/assets/palettes.mjs';
|
|
|
|
test('existing original preferences survive; retired seasons resolve to valid original preferences across reloads',()=>{
|
|
const dom=new JSDOM('<html><body></body></html>',{url:'http://xb.loc/'}),storage=dom.window.localStorage;
|
|
try{
|
|
for(const [saved,expected] of [['purple','purple'],['cyan','cyan'],['spring','cyan'],['summer','purple'],['autumn','purple'],['winter','purple']]){
|
|
storage.setItem('fuc_themeLight',saved);applyPalette(dom.window.document,storage);
|
|
assert.equal(storage.getItem('fuc_themeLight'),expected,saved+' saved migration');
|
|
assert.equal(getPalette(storage),expected);assert.equal(applyPalette(dom.window.document,storage),expected,'repeat initialization remains stable');
|
|
}
|
|
storage.setItem('fuc_themeLight','unknown');assert.equal(getPalette(storage),'purple');
|
|
}finally{dom.window.close();}
|
|
});
|
|
|
|
test('initialization removes stale seasonal root overrides without erasing unrelated mode or styles',()=>{
|
|
const dom=new JSDOM('<html data-color="dark" data-fuc-palette="winter" data-fuc-season="winter" style="--season-primary:#525bcf;--season-logo:hue-rotate(355deg);--other:keep"><body></body></html>',{url:'http://xb.loc/'});
|
|
try{
|
|
dom.window.localStorage.setItem('fuc_themeLight','winter');applyPalette(dom.window.document,dom.window.localStorage);
|
|
const root=dom.window.document.documentElement;
|
|
assert.equal(root.dataset.fucPalette,undefined);assert.equal(root.dataset.fucSeason,undefined);
|
|
assert.equal(root.style.getPropertyValue('--season-primary'),'');assert.equal(root.style.getPropertyValue('--season-logo'),'');
|
|
assert.equal(root.dataset.color,'dark');assert.equal(root.style.getPropertyValue('--other'),'keep');
|
|
}finally{dom.window.close();}
|
|
});
|