Skip to content

Commit ede6465

Browse files
authored
Only update snapshots when there are failures (#7959)
1 parent 82be013 commit ede6465

File tree

3 files changed

+13
-10
lines changed

3 files changed

+13
-10
lines changed

.github/workflows/e2e-tests.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,7 @@ jobs:
165165
TARGET: web
166166

167167
- name: Update snapshots
168-
if: always()
168+
if: failure()
169169
run: npm run test:snapshots -- --last-failed --update-snapshots
170170
env:
171171
VITE_KITTYCAD_API_TOKEN: ${{ secrets.KITTYCAD_API_TOKEN_DEV }}

e2e/playwright/snapshot-tests.spec.ts

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ import {
1010
import { expect, test } from '@e2e/playwright/zoo-test'
1111
import { KCL_DEFAULT_LENGTH } from '@src/lib/constants'
1212

13+
const TEST_OVERLAY_TIMEOUT_MS = 1_500 // slightly longer than OVERLAY_TIMEOUT_MS in @src/components/ModelingMachineProvider
14+
1315
test.beforeEach(async ({ page, context }) => {
1416
// Make the user avatar image always 404
1517
// so we see the fallback menu icon for all snapshot tests
@@ -173,7 +175,7 @@ test(
173175
500 - pixelToUnitRatio * 10
174176
)
175177

176-
await page.waitForTimeout(1_500) // modeling machine timeout is 1s
178+
await page.waitForTimeout(TEST_OVERLAY_TIMEOUT_MS)
177179
await expect(page).toHaveScreenshot({
178180
maxDiffPixels: 100,
179181
mask: lowerRightMasks(page),
@@ -203,7 +205,7 @@ test(
203205
await page.waitForTimeout(500)
204206

205207
await endOfTangentMv()
206-
await page.waitForTimeout(1_500) // modeling machine timeout is 1s
208+
await page.waitForTimeout(TEST_OVERLAY_TIMEOUT_MS)
207209
await expect(page).toHaveScreenshot({
208210
maxDiffPixels: 100,
209211
mask: lowerRightMasks(page),
@@ -214,7 +216,7 @@ test(
214216
await page.waitForTimeout(500)
215217
await endOfTangentClk()
216218
await threePointArcMidPointMv()
217-
await page.waitForTimeout(1_500) // modeling machine timeout is 1s
219+
await page.waitForTimeout(TEST_OVERLAY_TIMEOUT_MS)
218220
await expect(page).toHaveScreenshot({
219221
maxDiffPixels: 100,
220222
mask: lowerRightMasks(page),
@@ -223,7 +225,7 @@ test(
223225
await page.waitForTimeout(100)
224226

225227
await threePointArcEndPointMv()
226-
await page.waitForTimeout(1_500) // modeling machine timeout is 1s
228+
await page.waitForTimeout(TEST_OVERLAY_TIMEOUT_MS)
227229
await expect(page).toHaveScreenshot({
228230
maxDiffPixels: 100,
229231
mask: lowerRightMasks(page),
@@ -243,7 +245,7 @@ test(
243245
await arcCenterClk()
244246

245247
await arcEndMv()
246-
await page.waitForTimeout(1_500) // modeling machine timeout is 1s
248+
await page.waitForTimeout(TEST_OVERLAY_TIMEOUT_MS)
247249
await expect(page).toHaveScreenshot({
248250
maxDiffPixels: 100,
249251
mask: lowerRightMasks(page),
@@ -289,7 +291,7 @@ test(
289291
500 - pixelToUnitRatio * 10,
290292
{ steps: 5 }
291293
)
292-
await page.waitForTimeout(1_500) // modeling machine timeout is 1s
294+
await page.waitForTimeout(TEST_OVERLAY_TIMEOUT_MS)
293295

294296
// Ensure the draft rectangle looks the same as it usually does
295297
await expect(page).toHaveScreenshot({
@@ -333,7 +335,7 @@ test(
333335
500 - pixelToUnitRatio * 10,
334336
{ steps: 5 }
335337
)
336-
await page.waitForTimeout(1_500) // modeling machine timeout is 1s
338+
await page.waitForTimeout(TEST_OVERLAY_TIMEOUT_MS)
337339

338340
// Ensure the draft circle looks the same as it usually does
339341
await expect(page).toHaveScreenshot({

src/components/ModelingMachineProvider.tsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,8 @@ import type { SidebarType } from '@src/components/ModelingSidebar/ModelingPanes'
106106
import { useNetworkContext } from '@src/hooks/useNetworkContext'
107107
import { resetCameraPosition } from '@src/lib/resetCameraPosition'
108108

109+
const OVERLAY_TIMEOUT_MS = 1_000
110+
109111
export const ModelingMachineContext = createContext(
110112
{} as {
111113
state: StateFrom<typeof modelingMachine>
@@ -200,8 +202,7 @@ export const ModelingMachineProvider = ({
200202
pathToNodeString,
201203
},
202204
})
203-
// overlay timeout is 1s
204-
}, 1000) as unknown as number
205+
}, OVERLAY_TIMEOUT_MS) as unknown as number
205206
return {
206207
...context.segmentHoverMap,
207208
[pathToNodeString]: timeoutId,

0 commit comments

Comments
 (0)