Files
cms-SiteForge/tests_js/workspace_guide_v827.test.cjs
浅念 8884e100f9 upgrade: adopt V8.31.1 (theme 1.3/1.4 redesigns, editor deep-canvas, guided launch, component library)
Overlay 190 upstream items (V8.22→8.31) preserving trade-pro theme,
registry tests, and design docs. Re-applied full patch set on identical
anchors (discovery/env_for/blocks.css/type-mapping/locale-override/
theme_color/frontend entries/test_theme_pro_v3 mods) plus compose pins.

Verified: theme suites 35/35; dual-baseline full run 415 passed vs
pristine 386+29 ours, FAILED-set diff EMPTY (same 10 Windows env fails).
Live: container 8.31.1-dev.1 healthy, hesupipe 192 entries intact,
trade-pro build 203 pages 0 errors.

Co-Authored-By: Claude Code <noreply@anthropic.com>
2026-10-26 09:43:17 +08:00

17 lines
2.5 KiB
JavaScript

const test=require('node:test');
const assert=require('node:assert/strict');
const {plan}=require('../app/static/workspace-guide.js');
const site={id:'s1',name:'Demo',mode:'new',domain:'',updated_at:'2026-01-01T00:00:00Z'};
const starter={id:'start',route:'/',source:'starter',status:'published',updated_at:'2026-01-01T00:00:00Z'};
const product={id:'p',route:'/p/',source:'manual',status:'published',updated_at:'2026-01-02T00:00:00Z'};
test('empty site is not a completed journey',()=>{const p=plan({site,entries:[starter]});assert.equal(p.next.id,'content');assert.equal(p.completed,1);assert.equal(p.hasBuild,false);assert.equal(p.live,false)});
test('manually edited starter homepage can count as content',()=>{const p=plan({site,entries:[{...starter,created_at:'2026-01-01T00:00:00Z',updated_at:'2026-01-02T00:00:00Z'}]});assert.equal(p.next.id,'build')});
test('a draft never counts as prepared content',()=>{const p=plan({site,entries:[starter,{...product,status:'draft'}]});assert.equal(p.next.id,'content')});
test('migration site goes to the import workflow',()=>{const p=plan({site:{...site,mode:'migration'},entries:[starter]});assert.equal(p.steps[1].view,'import')});
test('content without a build stays in the build step',()=>{const p=plan({site,entries:[starter,product]});assert.equal(p.next.id,'build');assert.equal(p.completed,2)});
test('completed static build does not mean online',()=>{const p=plan({site,entries:[starter,product],builds:[{status:'complete',created_at:'2026-01-03T00:00:00Z'}]});assert.equal(p.next.id,'review');assert.equal(p.live,false);assert.equal(p.completed,3)});
test('later edits mark build as requiring review',()=>{const p=plan({site,entries:[starter,{...product,updated_at:'2026-01-05T00:00:00Z'}],builds:[{status:'done',created_at:'2026-01-03T00:00:00Z'}]});assert.equal(p.next.id,'build');assert.equal(p.changedAfterBuild,true)});
test('running job cannot be treated as completed build',()=>{const p=plan({site,entries:[starter,product],jobs:[{state:'running'}]});assert.equal(p.anyRunning,true);assert.equal(p.steps[3].done,false)});
test('only a production deployment record is reported as deployed',()=>{const base={site,entries:[starter,product],builds:[{status:'done',created_at:'2026-01-03T00:00:00Z'}]};assert.equal(plan({...base,delivery:{history:[{target:'staging',release_id:'r'}]}}).live,false);assert.equal(plan({...base,delivery:{history:[{target:'production',release_id:'r'}]}}).live,true)});
test('no site returns safely empty model',()=>{const p=plan({});assert.equal(p.ready,false);assert.equal(p.next,null)});