Skip to content

Commit

Permalink
chore: insight flapping (#22966)
Browse files Browse the repository at this point in the history
Fix flapping with belt and suspenders
  • Loading branch information
aspicer authored Jun 13, 2024
1 parent 5e0521e commit fc90806
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 8 deletions.
19 changes: 12 additions & 7 deletions .storybook/test-runner.ts
Original file line number Diff line number Diff line change
Expand Up @@ -155,25 +155,30 @@ async function expectStoryToMatchSnapshot(
await Promise.all(waitForSelector.map((selector) => page.waitForSelector(selector)))
}

await page.waitForTimeout(400) // Wait for effects to finish

// Wait for all images to load
await page.waitForFunction(() =>
Array.from(document.querySelectorAll('img')).every((i: HTMLImageElement) => i.complete)
)

// snapshot light theme
await page.evaluate(() => {
document.body.setAttribute('theme', 'light')
})

// Wait for all images to load
await page.waitForFunction(() => Array.from(document.images).every((i: HTMLImageElement) => i.complete))
await waitForPageReady(page)
await page.waitForLoadState('networkidle')
await page.waitForTimeout(2000)

await check(page, context, browser, 'light', storyContext.parameters?.testOptions?.snapshotTargetSelector)

// snapshot dark theme
await page.evaluate(() => {
document.body.setAttribute('theme', 'dark')
})

// Wait for all images to load
await page.waitForFunction(() => Array.from(document.images).every((i: HTMLImageElement) => i.complete))
await waitForPageReady(page)
await page.waitForLoadState('networkidle')
await page.waitForTimeout(100)

await check(page, context, browser, 'dark', storyContext.parameters?.testOptions?.snapshotTargetSelector)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ export function createInsightStory(
useStorybookMocks({
get: {
'/api/projects/:team_id/insights/': (_, __, ctx) => [
ctx.delay(100),
ctx.status(200),
ctx.json({
count: 1,
Expand Down

0 comments on commit fc90806

Please sign in to comment.