mirror of
https://github.com/Kilo-Org/kilocode.git
synced 2026-08-29 03:44:06 +08:00
fix: address review comments
- Add package.json to Storybook cache key (dep version changes invalidate cache) - Add res.ok check before parsing Storybook index JSON - Remove duplicate maxDiffPixelRatio (already in playwright.config.ts) - Use parseInt for PLAYWRIGHT_WORKERS to handle non-numeric values
This commit is contained in:
@@ -58,7 +58,7 @@ jobs:
|
||||
uses: actions/cache@v4
|
||||
with:
|
||||
path: packages/kilo-ui/storybook-static
|
||||
key: storybook-${{ hashFiles('packages/kilo-ui/src/**', 'packages/kilo-ui/.storybook/**', 'packages/ui/src/**') }}
|
||||
key: storybook-${{ hashFiles('packages/kilo-ui/src/**', 'packages/kilo-ui/.storybook/**', 'packages/ui/src/**', 'packages/kilo-ui/package.json') }}
|
||||
|
||||
- name: Build Storybook
|
||||
if: steps.storybook-cache.outputs.cache-hit != 'true'
|
||||
|
||||
@@ -9,7 +9,7 @@ export default defineConfig({
|
||||
// Number of parallel workers — defaults to half the CPU count locally,
|
||||
// override with PLAYWRIGHT_WORKERS env var or --workers CLI flag
|
||||
workers: process.env["PLAYWRIGHT_WORKERS"]
|
||||
? Number(process.env["PLAYWRIGHT_WORKERS"])
|
||||
? Number.parseInt(process.env["PLAYWRIGHT_WORKERS"]!, 10) || undefined
|
||||
: undefined,
|
||||
reporter: [["html", { open: "never" }], ["list"]],
|
||||
use: {
|
||||
|
||||
@@ -18,6 +18,7 @@ async function fetchStories(): Promise<Story[]> {
|
||||
const res = await fetch(`${STORYBOOK_URL}/index.json`).catch(() =>
|
||||
fetch(`${STORYBOOK_URL}/stories.json`),
|
||||
)
|
||||
if (!res.ok) throw new Error(`Storybook index fetch failed: ${res.status} ${res.statusText}`)
|
||||
const data = (await res.json()) as StoriesIndex
|
||||
const map = data.entries ?? data.stories ?? {}
|
||||
return Object.values(map).filter((s) => s.id && !s.id.endsWith("--docs"))
|
||||
@@ -68,8 +69,6 @@ for (const story of stories) {
|
||||
// Use [component, variant] path so snapshots are grouped per component dir.
|
||||
const [component, variant] = story.id.split("--")
|
||||
const root = page.locator("#storybook-root")
|
||||
await expect(root).toHaveScreenshot([component, `${variant}.png`], {
|
||||
maxDiffPixelRatio: 0.01,
|
||||
})
|
||||
await expect(root).toHaveScreenshot([component, `${variant}.png`])
|
||||
})
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user