Skip to content

Commit 82be013

Browse files
Ensure screenshot is taken after modeling machine timeout (#7956)
* Ensure screenshot is taken after modeling machine timeout * Update snapshots * Hard-code the platform for Windows * Fix invalid test ID * Update snapshots --------- Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
1 parent ffbc890 commit 82be013

File tree

31 files changed

+83
-53
lines changed

31 files changed

+83
-53
lines changed

Makefile

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,15 @@ export POWERSHELL := true
1111
endif
1212
endif
1313

14+
ifdef WINDOWS
15+
PLATFORM := Windows
16+
else
17+
PLATFORM := $(shell uname -s)
18+
ifeq ($(PLATFORM),Linux)
19+
export LINUX := true
20+
endif
21+
endif
22+
1423
ifdef WINDOWS
1524
CARGO ?= $(USERPROFILE)/.cargo/bin/cargo.exe
1625
WASM_PACK ?= $(USERPROFILE)/.cargo/bin/wasm-pack.exe
@@ -108,6 +117,12 @@ E2E_GREP ?=
108117
E2E_WORKERS ?=
109118
E2E_FAILURES ?= 1
110119

120+
ifdef LINUX
121+
E2E_MODE ?= changed
122+
else
123+
E2E_MODE ?= none
124+
endif
125+
111126
.PHONY: test
112127
test: test-unit test-e2e
113128

@@ -137,6 +152,17 @@ else
137152
npm run test:e2e:desktop -- --workers='100%'
138153
endif
139154

155+
.PHONY: test-snapshots
156+
test-snapshots: install build ## Run the snapshot tests
157+
ifndef LINUX
158+
@ echo "NOTE: Snapshots cannot be updated on $(PLATFORM)"
159+
endif
160+
ifdef E2E_GREP
161+
npm run test:snapshots -- --headed --update-snapshots=$(E2E_MODE) --grep="$(E2E_GREP)"
162+
else
163+
npm run test:snapshots -- --headed --update-snapshots=$(E2E_MODE)
164+
endif
165+
140166
###############################################################################
141167
# CLEAN
142168

e2e/playwright/fixtures/toolbarFixture.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -212,8 +212,8 @@ export class ToolbarFixture {
212212
}
213213
selectArc = async () => {
214214
await this.page.getByRole('button', { name: 'caret down arcs:' }).click()
215-
await expect(this.page.getByTestId('dropdown-arc')).toBeVisible()
216-
await this.page.getByTestId('dropdown-arc').click()
215+
await expect(this.page.getByTestId('dropdown-tangential-arc')).toBeVisible()
216+
await this.page.getByTestId('dropdown-tangential-arc').click()
217217
}
218218
selectThreePointArc = async () => {
219219
await this.page.getByRole('button', { name: 'caret down arcs:' }).click()

e2e/playwright/snapshot-tests.spec.ts

Lines changed: 54 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -129,13 +129,13 @@ test(
129129
async ({ page, scene, toolbar }) => {
130130
const u = await getUtils(page)
131131
await page.setViewportSize({ width: 1200, height: 500 })
132-
const PUR = 400 / 37.5 //pixeltoUnitRatio
133132
await u.waitForAuthSkipAppStart()
134133

135-
const startXPx = 600
134+
const startPixelX = 600
135+
const pixelToUnitRatio = 400 / 37.5
136136
const [endOfTangentClk, endOfTangentMv] = scene.makeMouseHelpers(
137-
startXPx + PUR * 30,
138-
500 - PUR * 20,
137+
startPixelX + pixelToUnitRatio * 30,
138+
500 - pixelToUnitRatio * 20,
139139
{ steps: 10 }
140140
)
141141
const [threePointArcMidPointClk, threePointArcMidPointMv] =
@@ -149,35 +149,41 @@ test(
149149
steps: 10,
150150
})
151151

152-
// click on "Start Sketch" button
152+
// Start a sketch
153153
await u.doAndWaitForImageDiff(
154154
() => page.getByRole('button', { name: 'Start Sketch' }).click(),
155155
200
156156
)
157157

158-
// select a plane
158+
// Select a plane
159159
await page.mouse.click(700, 200)
160-
161160
let code = `sketch001 = startSketchOn(XZ)`
162161
await expect(page.locator('.cm-content')).toHaveText(code)
163162

164-
await page.waitForTimeout(700) // TODO detect animation ending, or disable animation
165-
166-
await page.mouse.click(startXPx + PUR * 10, 500 - PUR * 10)
163+
await page.mouse.click(
164+
startPixelX + pixelToUnitRatio * 10,
165+
500 - pixelToUnitRatio * 10
166+
)
167167
code += `profile001 = startProfile(sketch001, at = [182.59, -246.32])`
168168
await expect(page.locator('.cm-content')).toHaveText(code)
169169
await page.waitForTimeout(100)
170170

171-
await page.mouse.move(startXPx + PUR * 20, 500 - PUR * 10)
171+
await page.mouse.move(
172+
startPixelX + pixelToUnitRatio * 20,
173+
500 - pixelToUnitRatio * 10
174+
)
172175

173-
await page.waitForTimeout(500)
176+
await page.waitForTimeout(1_500) // modeling machine timeout is 1s
174177
await expect(page).toHaveScreenshot({
175178
maxDiffPixels: 100,
176179
mask: lowerRightMasks(page),
177180
})
178181

179182
const lineEndClick = () =>
180-
page.mouse.click(startXPx + PUR * 20, 500 - PUR * 10)
183+
page.mouse.click(
184+
startPixelX + pixelToUnitRatio * 20,
185+
500 - pixelToUnitRatio * 10
186+
)
181187
await lineEndClick()
182188
await page.waitForTimeout(500)
183189

@@ -197,7 +203,7 @@ test(
197203
await page.waitForTimeout(500)
198204

199205
await endOfTangentMv()
200-
await page.waitForTimeout(500)
206+
await page.waitForTimeout(1_500) // modeling machine timeout is 1s
201207
await expect(page).toHaveScreenshot({
202208
maxDiffPixels: 100,
203209
mask: lowerRightMasks(page),
@@ -208,7 +214,7 @@ test(
208214
await page.waitForTimeout(500)
209215
await endOfTangentClk()
210216
await threePointArcMidPointMv()
211-
await page.waitForTimeout(500)
217+
await page.waitForTimeout(1_500) // modeling machine timeout is 1s
212218
await expect(page).toHaveScreenshot({
213219
maxDiffPixels: 100,
214220
mask: lowerRightMasks(page),
@@ -217,7 +223,7 @@ test(
217223
await page.waitForTimeout(100)
218224

219225
await threePointArcEndPointMv()
220-
await page.waitForTimeout(500)
226+
await page.waitForTimeout(1_500) // modeling machine timeout is 1s
221227
await expect(page).toHaveScreenshot({
222228
maxDiffPixels: 100,
223229
mask: lowerRightMasks(page),
@@ -237,7 +243,7 @@ test(
237243
await arcCenterClk()
238244

239245
await arcEndMv()
240-
await page.waitForTimeout(500)
246+
await page.waitForTimeout(1_500) // modeling machine timeout is 1s
241247
await expect(page).toHaveScreenshot({
242248
maxDiffPixels: 100,
243249
mask: lowerRightMasks(page),
@@ -252,42 +258,38 @@ test(
252258
async ({ page, context, cmdBar, scene }) => {
253259
const u = await getUtils(page)
254260
await page.setViewportSize({ width: 1200, height: 500 })
255-
const PUR = 400 / 37.5 //pixeltoUnitRatio
256-
257261
await u.waitForAuthSkipAppStart()
258262

259-
// click on "Start Sketch" button
263+
// Start a sketch
260264
await u.doAndWaitForImageDiff(
261265
() => page.getByRole('button', { name: 'Start Sketch' }).click(),
262266
200
263267
)
264268

265-
// select a plane
269+
// Select a plane
266270
await page.mouse.click(700, 200)
267-
268271
await expect(page.locator('.cm-content')).toHaveText(
269272
`sketch001 = startSketchOn(XZ)`
270273
)
271274

272-
// Wait for camera animation
273-
await page.waitForTimeout(2000)
274-
275-
const startXPx = 600
276-
277275
// Equip the rectangle tool
278-
const rectangleBtn = page.getByTestId('corner-rectangle')
279-
await rectangleBtn.click()
280-
await expect(rectangleBtn).toHaveAttribute('aria-pressed', 'true')
276+
await page.getByTestId('corner-rectangle').click()
281277

282278
// Draw the rectangle
279+
const startPixelX = 600
280+
const pixelToUnitRatio = 400 / 37.5
283281
const rectanglePointOne: [number, number] = [
284-
startXPx + PUR * 40,
285-
500 - PUR * 30,
282+
startPixelX + pixelToUnitRatio * 40,
283+
500 - pixelToUnitRatio * 30,
286284
]
287285
await page.mouse.move(...rectanglePointOne, { steps: 5 })
288-
await page.mouse.click(...rectanglePointOne, { delay: 50 })
289-
await page.mouse.move(startXPx + PUR * 10, 500 - PUR * 10, { steps: 5 })
290-
await page.waitForTimeout(800)
286+
await page.mouse.click(...rectanglePointOne, { delay: 500 })
287+
await page.mouse.move(
288+
startPixelX + pixelToUnitRatio * 10,
289+
500 - pixelToUnitRatio * 10,
290+
{ steps: 5 }
291+
)
292+
await page.waitForTimeout(1_500) // modeling machine timeout is 1s
291293

292294
// Ensure the draft rectangle looks the same as it usually does
293295
await expect(page).toHaveScreenshot({
@@ -302,36 +304,38 @@ test(
302304
async ({ page, context, cmdBar, scene }) => {
303305
const u = await getUtils(page)
304306
await page.setViewportSize({ width: 1200, height: 500 })
305-
const PUR = 400 / 37.5 //pixeltoUnitRatio
306-
307307
await u.waitForAuthSkipAppStart()
308308

309+
// Start a sketch
309310
await u.doAndWaitForImageDiff(
310311
() => page.getByRole('button', { name: 'Start Sketch' }).click(),
311312
200
312313
)
313314

314-
// select a plane
315+
// Select a plane
315316
await page.mouse.click(700, 200)
316-
317317
await expect(page.locator('.cm-content')).toHaveText(
318318
`sketch001 = startSketchOn(XZ)`
319319
)
320320

321-
// Wait for camera animation
322-
await page.waitForTimeout(2000)
323-
324-
const startXPx = 600
325-
326-
// Equip the rectangle tool
327-
// await page.getByRole('button', { name: 'line Line', exact: true }).click()
321+
// Equip the circle tool
328322
await page.getByTestId('circle-center').click()
329323

330-
// Draw the rectangle
331-
await page.mouse.click(startXPx + PUR * 20, 500 - PUR * 20)
332-
await page.mouse.move(startXPx + PUR * 10, 500 - PUR * 10, { steps: 5 })
324+
// Draw the circle
325+
const startPixelX = 600
326+
const pixelToUnitRatio = 400 / 37.5
327+
await page.mouse.click(
328+
startPixelX + pixelToUnitRatio * 20,
329+
500 - pixelToUnitRatio * 20
330+
)
331+
await page.mouse.move(
332+
startPixelX + pixelToUnitRatio * 10,
333+
500 - pixelToUnitRatio * 10,
334+
{ steps: 5 }
335+
)
336+
await page.waitForTimeout(1_500) // modeling machine timeout is 1s
333337

334-
// Ensure the draft rectangle looks the same as it usually does
338+
// Ensure the draft circle looks the same as it usually does
335339
await expect(page).toHaveScreenshot({
336340
maxDiffPixels: 100,
337341
mask: lowerRightMasks(page),
Loading
Loading
Loading
Loading
-210 Bytes
Loading
4.54 KB
Loading
-110 Bytes
Loading

0 commit comments

Comments
 (0)