mirror of
https://github.com/Kilo-Org/kilocode.git
synced 2026-09-24 16:02:55 +08:00
Merge pull request #6981 from Kilo-Org/fix/avatar-screenshot-flaky
fix: eliminate network dependency in avatar visual regression test
This commit is contained in:
@@ -33,10 +33,15 @@ export const WithCustomColors: Story = {
|
||||
args: { fallback: "KL", background: "#1a4d8f", foreground: "#ffffff" },
|
||||
}
|
||||
|
||||
// Inline data URI so the visual regression test never depends on network.
|
||||
// 32×32 avatar silhouette (blue circle, white head, light-blue shoulders).
|
||||
const AVATAR_DATA_URI =
|
||||
"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAYAAABzenr0AAAAq0lEQVR4nNXUyw2AIBBFUfuyO9u0Awtwqa5IjIDzeW8cIZml3CMGp2n0NS/7+WlMO2lhKgQJwxBpw9aiITxxGgKJUxBoXIMIfXvoFFIBmqvEBFSIIQCsWwABJIRlHzegh7Du4Y4zJxUBfYI0wLod4oQANGErRA3wxDUI1e8Yib8hqngLwIj3EE3AExEF6MZ/ASgIZvyOEONRCFO8LCbAHGdBoDACoYYlFPL8Bcdqxc2w0JfIAAAAAElFTkSuQmCC"
|
||||
|
||||
export const WithImage: Story = {
|
||||
args: {
|
||||
fallback: "OC",
|
||||
src: "https://avatars.githubusercontent.com/u/154330673?s=48",
|
||||
src: AVATAR_DATA_URI,
|
||||
},
|
||||
}
|
||||
|
||||
|
||||
@@ -45,6 +45,24 @@ async function disableAnimations(page: Page) {
|
||||
})
|
||||
}
|
||||
|
||||
// Wait for every <img> inside the story root to finish loading so screenshots
|
||||
// never capture an intermediate state with missing / half-loaded images.
|
||||
async function waitForImages(page: Page) {
|
||||
await page.evaluate(() => {
|
||||
const imgs = document.querySelectorAll<HTMLImageElement>("#storybook-root img")
|
||||
return Promise.all(
|
||||
Array.from(imgs).map(
|
||||
(img) =>
|
||||
img.complete ||
|
||||
new Promise<void>((resolve) => {
|
||||
img.addEventListener("load", () => resolve(), { once: true })
|
||||
img.addEventListener("error", () => resolve(), { once: true })
|
||||
}),
|
||||
),
|
||||
)
|
||||
})
|
||||
}
|
||||
|
||||
// Stories to skip from visual regression:
|
||||
// - Font/Favicon: inject into <head>, no visible content in #storybook-root
|
||||
// - Typewriter: uses JS setTimeout + Math.random(), inherently non-deterministic
|
||||
@@ -72,6 +90,7 @@ for (const story of stories) {
|
||||
await disableAnimations(page)
|
||||
// Wait for Kobalte/SolidJS to finish hydrating interactive components
|
||||
await page.waitForSelector("#storybook-root *", { state: "attached" })
|
||||
await waitForImages(page)
|
||||
|
||||
// Screenshot just the story content, not the full 1280x720 canvas.
|
||||
// Use [component, variant] path so snapshots are grouped per component dir.
|
||||
|
||||
+2
-2
@@ -1,3 +1,3 @@
|
||||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:79b80c13a1fa198f1602c85728a48467ac9b47c6430dadd6ff698f9c4d39980e
|
||||
size 809
|
||||
oid sha256:e8cc3385247e30289bec92001d1d76b315fa610501461bc95c55c38f24d9ffb5
|
||||
size 799
|
||||
|
||||
@@ -1070,6 +1070,7 @@ export class Worktree extends HeyApiClient {
|
||||
public diffSummary<ThrowOnError extends boolean = false>(
|
||||
parameters?: {
|
||||
directory?: string
|
||||
workspace?: string
|
||||
base?: string
|
||||
},
|
||||
options?: Options<never, ThrowOnError>,
|
||||
@@ -1080,6 +1081,7 @@ export class Worktree extends HeyApiClient {
|
||||
{
|
||||
args: [
|
||||
{ in: "query", key: "directory" },
|
||||
{ in: "query", key: "workspace" },
|
||||
{ in: "query", key: "base" },
|
||||
],
|
||||
},
|
||||
@@ -1100,6 +1102,7 @@ export class Worktree extends HeyApiClient {
|
||||
public diffFile<ThrowOnError extends boolean = false>(
|
||||
parameters: {
|
||||
directory?: string
|
||||
workspace?: string
|
||||
base?: string
|
||||
file: string
|
||||
},
|
||||
@@ -1111,6 +1114,7 @@ export class Worktree extends HeyApiClient {
|
||||
{
|
||||
args: [
|
||||
{ in: "query", key: "directory" },
|
||||
{ in: "query", key: "workspace" },
|
||||
{ in: "query", key: "base" },
|
||||
{ in: "query", key: "file" },
|
||||
],
|
||||
|
||||
@@ -2724,6 +2724,7 @@ export type WorktreeDiffSummaryData = {
|
||||
path?: never
|
||||
query?: {
|
||||
directory?: string
|
||||
workspace?: string
|
||||
/**
|
||||
* Base branch or ref to diff against
|
||||
*/
|
||||
@@ -2755,6 +2756,7 @@ export type WorktreeDiffFileData = {
|
||||
path?: never
|
||||
query: {
|
||||
directory?: string
|
||||
workspace?: string
|
||||
/**
|
||||
* Base branch or ref to diff against
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user