test(sw): align storybook inventory checks with approved changes
This commit is contained in:
1 parent
522ecbd193
commit
20ed2f2afb
3 files changed
+64
-25
No files matched your search
@@ -5,26 +5,22 @@ import { execFileSync } from 'node:child_process'
|
||||
import path from 'node:path'
|
||||
import http from 'node:http'
|
||||
import { parse } from '@babel/parser'
|
||||
import { swStoryEntries, retainedInventory, inventorySignature, retiredDropdownIds, integratedChangedFiles, integratedStoryIds, retiredPropertyPanelIds, retiredUnusedDemoIds, movedHomeMenuIds, retiredHomeMenuCompareIds, movedToPopupIds } from './storybook-inventory.mjs'
|
||||
import { swStoryEntries, retainedInventory, inventorySignature, retiredDropdownIds, integratedChangedFiles, integratedStoryIds, retiredPropertyPanelIds, retiredUnusedDemoIds, movedHomeMenuIds, retiredHomeMenuCompareIds, movedToPopupIds, approvedMainCommit, homeMenuSidebarIds, withApprovedEntryChanges, approvedHeaderDeclarations, movedHeaderDeclarations } from './storybook-inventory.mjs'
|
||||
import { loadPlaywright } from './playwright-runtime.mjs'
|
||||
|
||||
const out = path.resolve(process.argv[2] ?? 'docs/sw/storybook-overview-qa')
|
||||
await mkdir(out, { recursive: true })
|
||||
// 2026-10-20 (test alignment): 50bf5bd and its before-index.json stay the baseline. The checks below accept only the
|
||||
// approved changes after it (storybook-inventory.mjs and the ledgers here) and the approved main merge 553e4df.
|
||||
const report = { baseCommit: '50bf5bda8e956a4973b923d64131f2f2285bd38c', approvedMainCommit: '553e4df4a865aaf6514b1c2b86cb2e3e9a658e5f', checks: [], errors: [], sizes: [] }
|
||||
// approved changes after it and the approved main merge, both recorded in storybook-inventory.mjs.
|
||||
const report = { baseCommit: '50bf5bda8e956a4973b923d64131f2f2285bd38c', approvedMainCommit, checks: [], errors: [], sizes: [] }
|
||||
const check = (name, ok, data) => { report.checks.push({ name, status: ok ? 'PASS' : 'FAIL', data }); console.log(ok ? 'PASS' : 'FAIL', name) }
|
||||
const before = JSON.parse(await readFile(path.join(out, 'before-index.json'), 'utf8'))
|
||||
const index = JSON.parse(await readFile('storybook-static/index.json', 'utf8'))
|
||||
const after = swStoryEntries(index)
|
||||
await writeFile(path.join(out, 'after-index.json'), JSON.stringify(after, null, 2) + '\n')
|
||||
// 2b0e1a2 sidebar simplification: these two keep their ID and direct URL with the verification tag.
|
||||
const verificationTaggedIds = ['sw-header--window-move-motion', 'sw-header--k-guide']
|
||||
const removedHeaderIds = [...retiredPropertyPanelIds, ...retiredUnusedDemoIds, ...movedToPopupIds]
|
||||
// 170a5c2 home menu merge: the sidebar Story sw-header--home-menu plus the moved sw-header--home-menu-* Stories.
|
||||
const addedHeaderIds = [...integratedStoryIds.filter(id => id.startsWith('sw-header--')), 'sw-header--home-menu', ...Object.values(movedHomeMenuIds).filter(id => !retiredHomeMenuCompareIds.includes(id))]
|
||||
const expectedRetained = retainedInventory(before).filter(entry => !removedHeaderIds.includes(entry.id))
|
||||
.map(entry => verificationTaggedIds.includes(entry.id) ? { ...entry, tags: [...entry.tags, 'verification'] } : entry)
|
||||
const addedHeaderIds = [...integratedStoryIds.filter(id => id.startsWith('sw-header--')), ...homeMenuSidebarIds, ...Object.values(movedHomeMenuIds).filter(id => !retiredHomeMenuCompareIds.includes(id))]
|
||||
const expectedRetained = retainedInventory(before).filter(entry => !removedHeaderIds.includes(entry.id)).map(withApprovedEntryChanges)
|
||||
const inventory = { expected: expectedRetained.length + addedHeaderIds.length, actual: after.length, missingAdded: addedHeaderIds.filter(id => !after.some(e => e.id === id)), movedToPopup: movedToPopupIds.map(id => index.entries[id]?.title ?? null) }
|
||||
check(`${inventory.expected} SW/Header Story IDs: the 24 retained at 50bf5bd (names, tags) minus approved retirements and the Popup move, plus approved additions`,
|
||||
after.length === inventory.expected && inventory.missingAdded.length === 0 && inventory.movedToPopup.every(title => title === 'SW/Popup')
|
||||
@@ -39,8 +35,7 @@ const retiredExports = ['LayerDropdown','ColorDropdown','LineStyleDropdown','Tex
|
||||
// retirement, or the Popup move compared in its new file. All others stay byte-identical to 50bf5bd.
|
||||
const gitStories = (commit, file) => stories(execFileSync('git', ['show', `${commit}:${file}`], { encoding: 'utf8' }))
|
||||
const storyId = name => `sw-header--${name.replace(/([a-z0-9])([A-Z])/g, '$1-$2').toLowerCase()}`
|
||||
const approvedDeclarations = { ResponsiveMore: '170a5c23aed10f8fc65e5b20e9b94bd3c1ff1227', WindowMoveMotion: '2b0e1a2262002aedb01c29c5d18ffae1219bf3ef', KGuide: '2b0e1a2262002aedb01c29c5d18ffae1219bf3ef' } // measured More section; verification tag
|
||||
const movedDeclarations = { PropertyPanelCompare: ['src/sw/sw-property-panel.stories.tsx', '2b0e1a2262002aedb01c29c5d18ffae1219bf3ef'] }
|
||||
const approvedDeclarations = approvedHeaderDeclarations, movedDeclarations = movedHeaderDeclarations
|
||||
const movedNow = Object.fromEntries(await Promise.all(Object.entries(movedDeclarations).map(async ([name, [file]]) => [name, stories(await readFile(file, 'utf8'))[name]])))
|
||||
const declarationIssues = Object.keys(oldStories).filter(k => k !== 'Overview' && !retiredExports.includes(k)).filter(k => {
|
||||
if (movedDeclarations[k]) return !!newStories[k] || movedNow[k] !== gitStories(movedDeclarations[k][1], movedDeclarations[k][0])[k]
|
||||
|
||||
Reference in new issue
Block a user