refactor(storybook): consolidate dropdown stories into composed controls

This commit is contained in:
shkim4 committed 2026-10-19 12:30:29 +09:00
1 parent c165753bbe
commit 9482d45f34
74 files changed
+38833 -283

No files matched your search

+9 -7
View File
@@ -2,6 +2,7 @@ import { createRequire } from 'node:module'
import { mkdir, readFile, writeFile } from 'node:fs/promises'
import path from 'node:path'
import http from 'node:http'
import { swStoryEntries, retainedInventory } from './storybook-inventory.mjs'
// Usage: node packages/sw/tests/detail-buttons.browser.mjs baseline|verify <evidence-dir> [base-url]
const mode = process.argv[2] ?? 'verify'
@@ -67,7 +68,7 @@ try {
check('preserve editable Input',await editing.isEditable()&&await editing.evaluate(e=>getComputedStyle(e).caretColor==='rgb(230, 4, 3)'))
} else {
const index = await (await fetch(`${base}/index.json`)).json()
const ids = Object.values(index.entries).filter(e => e.title === 'SW/Header' && e.type === 'story').map(e => e.id)
const ids = swStoryEntries(index).map(e => e.id)
report.storyIds = ids
if (mode === 'baseline') await writeFile(path.join(output, 'baseline-story-ids.json'), JSON.stringify(ids))
// These retained examples cover fixed-width and fluid headers after the two Args demos were retired.
@@ -82,7 +83,8 @@ try {
}
}
await page.setViewportSize({ width:1920,height:1000 })
await goto('text-dimension-style-dropdown')
await goto('composed-controls')
await page.locator('[data-composed-controls]').getByRole('button',{name:'문자스타일',exact:true}).click()
const original = page.getByRole('button',{name:'문자스타일 상세',exact:true}).first()
snapshots.textDefault = await original.evaluate(style)
if (!(await original.isDisabled())) { await original.hover(); snapshots.textHover = await original.evaluate(style) }
@@ -97,9 +99,9 @@ try {
const before=JSON.parse(await readFile(path.join(output,'baseline.json'),'utf8'))
for(const key of Object.keys(snapshots).filter(k=>!k.startsWith('text'))) check(`unchanged header ${key} (capture a current baseline for replacement fixtures)`,JSON.stringify(before[key])===JSON.stringify(snapshots[key]))
const oldIds=JSON.parse(await readFile(path.join(output,'baseline-story-ids.json'),'utf8'))
const retiredIds=['default','controls','responsive','text-stroke','dynamic-data'].map(id=>`sw-header--${id}`)
const retainedIds=oldIds.filter(id=>!retiredIds.includes(id))
check('retained stories remain; only the five approved demos are absent',ids.length===28&&retainedIds.every(id=>ids.includes(id))&&retiredIds.every(id=>!ids.includes(id)),{before:oldIds.length,after:ids.length})
const retiredIds=['default','controls','responsive','text-stroke','dynamic-data','layer-dropdown','color-dropdown','line-style-dropdown','text-dimension-style-dropdown'].map(id=>`sw-header--${id}`)
const retainedIds=retainedInventory(oldIds.map(id=>({id}))).map(e=>e.id)
check('retained stories remain; only approved retirements are absent',ids.length===24&&retainedIds.every(id=>ids.includes(id))&&retiredIds.every(id=>!ids.includes(id)),{before:oldIds.length,after:ids.length})
for(const id of ids){await goto(id.replace('sw-header--',''));check(`render ${id}`,!(await page.locator('.sb-errordisplay').isVisible()))}
await goto('composition')
const presets=['기본 전체','구성 A','구성 B (레이어·선스타일)','구성 C (로고만)','파일 목록 제거','레이어 제거','색상 제거','스타일 그룹 제거','여러 메뉴 제거','순서 변경','숨김 + 순서 변경']
@@ -117,8 +119,8 @@ try {
}
await page.setViewportSize({width:1920,height:1000})
// Real dropdown integration, separate from the shared-button specimen.
await goto('color-dropdown')
const host=page.locator('section').filter({has:page.getByRole('heading',{name:'선택 · 입력 · Callback 기록',exact:true})})
await goto('composed-controls')
const host=page.locator('.sw-composed-controls')
for(const [name,callback] of [['색상','onColorDetail'],['선스타일','onLineStyleDetail'],['문자스타일','onTextStyleDetail'],['치수스타일','onDimensionStyleDetail']]){
const trigger=host.getByRole('button',{name,exact:true});await trigger.click()
const detail=host.getByRole('button',{name:`${name} 상세`,exact:true});await detail.hover()