Skip to content

Commit 3840377

Browse files
franknoirotgithub-actions[bot]graphite-app[bot]
authored
Tests: update a bunch of tests to use stream-relative coordinates for scene interactions (#7966)
* Duplicate convertPagePositionToStream in utils for a standalone version of this function outside of scene fixture * Update coordinates in many tests to be stream-dependent * Little test tweak * lint * Fix plane sketching tests, make them less about code matching * Fix regex in snapping test * Tweak values in scale sketching test * Remove "sketching with offset planes" test, we have other tests for that * Tweak scalar values in snap to close tests * Fix lints * Re-run CI * Update snapshots * Update coordinates to be relative in camera movement web test * Update camera location in trackball test * Remove highlighted code expectation from gizmo test * Don't expect on the exact value of the circle in this test * Remove pixel checks from selection test Yay I'm using the selection in the status bar for a test! * Update e2e/playwright/sketch-tests.spec.ts Co-authored-by: graphite-app[bot] <96075541+graphite-app[bot]@users.noreply.github.com> --------- Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com> Co-authored-by: graphite-app[bot] <96075541+graphite-app[bot]@users.noreply.github.com>
1 parent ce457a1 commit 3840377

14 files changed

+386
-476
lines changed

e2e/playwright/can-create-sketches-on-all-planes-and-their-back-sides.spec.ts

Lines changed: 67 additions & 80 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import { uuidv4 } from '@src/lib/utils'
55
import type { HomePageFixture } from '@e2e/playwright/fixtures/homePageFixture'
66
import type { SceneFixture } from '@e2e/playwright/fixtures/sceneFixture'
77
import type { ToolbarFixture } from '@e2e/playwright/fixtures/toolbarFixture'
8-
import type { CmdBarFixture } from '@e2e/playwright/fixtures/cmdBarFixture'
8+
import type { EditorFixture } from '@e2e/playwright/fixtures/editorFixture'
99
import { getUtils } from '@e2e/playwright/test-utils'
1010
import { expect, test } from '@e2e/playwright/zoo-test'
1111

@@ -15,7 +15,7 @@ test.describe('Can create sketches on all planes and their back sides', () => {
1515
homePage: HomePageFixture,
1616
scene: SceneFixture,
1717
toolbar: ToolbarFixture,
18-
cmdBar: CmdBarFixture,
18+
editor: EditorFixture,
1919
plane: string,
2020
clickCoords: { x: number; y: number }
2121
) => {
@@ -52,43 +52,36 @@ test.describe('Can create sketches on all planes and their back sides', () => {
5252
},
5353
}
5454

55-
const code = `@settings(defaultLengthUnit = in)sketch001 = startSketchOn(${plane})profile001 = startProfile(sketch001, at = [0.91, -1.22])`
55+
const code = `@settings(defaultLengthUnit = in)sketch001 = startSketchOn(${plane})profile001 = startProfile(sketch001, at = [`
5656

57-
await u.openDebugPanel()
58-
59-
await u.clearCommandLogs()
60-
await page.getByRole('button', { name: 'Start Sketch' }).click()
61-
62-
await u.sendCustomCmd(camCommand)
63-
await page.waitForTimeout(100)
64-
await u.sendCustomCmd(updateCamCommand)
57+
await test.step(`Sketch on the ${plane} plane using custom camera commands to orient`, async () => {
58+
await u.openDebugPanel()
59+
await u.clearCommandLogs()
60+
await toolbar.startSketchBtn.click()
6561

66-
await u.closeDebugPanel()
62+
await u.sendCustomCmd(camCommand)
63+
await page.waitForTimeout(100)
64+
await u.sendCustomCmd(updateCamCommand)
6765

68-
await page.mouse.click(clickCoords.x, clickCoords.y)
69-
await page.waitForTimeout(600) // wait for animation
66+
await u.closeDebugPanel()
7067

71-
await toolbar.waitUntilSketchingReady()
72-
73-
await expect(
74-
page.getByRole('button', { name: 'line Line', exact: true })
75-
).toBeVisible()
68+
const resolvedCoords = await scene.convertPagePositionToStream(
69+
clickCoords.x,
70+
clickCoords.y
71+
)
72+
await page.mouse.click(resolvedCoords.x, resolvedCoords.y)
73+
await page.waitForTimeout(600) // wait for animation
7674

77-
await u.closeDebugPanel()
78-
await page.mouse.click(707, 393)
75+
await toolbar.waitUntilSketchingReady()
7976

80-
await expect(page.locator('.cm-content')).toHaveText(code)
77+
await u.closeDebugPanel()
78+
await expect(toolbar.lineBtn).toHaveAttribute('aria-pressed', 'true')
79+
})
8180

82-
await page
83-
.getByRole('button', { name: 'line Line', exact: true })
84-
.first()
85-
.click()
86-
await u.openAndClearDebugPanel()
87-
await page.getByRole('button', { name: 'Exit Sketch' }).click()
88-
await u.expectCmdLog('[data-message-type="execution-done"]')
81+
const lineCoords = await scene.convertPagePositionToStream(707, 393)
82+
await page.mouse.click(lineCoords.x, lineCoords.y)
8983

90-
await u.clearCommandLogs()
91-
await u.removeCurrentCode()
84+
await editor.expectEditor.toContain(code)
9285
}
9386

9487
const planeConfigs = [
@@ -125,13 +118,13 @@ test.describe('Can create sketches on all planes and their back sides', () => {
125118
]
126119

127120
for (const config of planeConfigs) {
128-
test(config.plane, async ({ page, homePage, scene, toolbar, cmdBar }) => {
121+
test(config.plane, async ({ page, homePage, scene, toolbar, editor }) => {
129122
await sketchOnPlaneAndBackSideTest(
130123
page,
131124
homePage,
132125
scene,
133126
toolbar,
134-
cmdBar,
127+
editor,
135128
config.plane,
136129
config.coords
137130
)
@@ -144,7 +137,7 @@ test.describe('Can create sketches on offset planes and their back sides', () =>
144137
homePage: HomePageFixture,
145138
scene: SceneFixture,
146139
toolbar: ToolbarFixture,
147-
cmdbar: CmdBarFixture,
140+
editor: EditorFixture,
148141
plane: string,
149142
clickCoords: { x: number; y: number }
150143
) => {
@@ -194,54 +187,48 @@ yzPlane = offsetPlane(YZ, offset = 0.05)
194187
.toLocaleLowerCase()
195188

196189
const codeLine1 = `sketch001 = startSketchOn(${prefix}${planeName}Plane)`
197-
const codeLine2 = `profile001 = startProfile(sketch001, at = [${0.91 + (plane[0] === '-' ? 0.01 : 0)}, -${1.21 + (plane[0] === '-' ? 0.01 : 0)}])`
198-
199-
await u.openDebugPanel()
200-
201-
await u.clearCommandLogs()
202-
await page.getByRole('button', { name: 'Start Sketch' }).click()
203-
204-
await u.sendCustomCmd(camCommand)
205-
await page.waitForTimeout(100)
206-
await u.sendCustomCmd(updateCamCommand)
207-
208-
await u.closeDebugPanel()
209-
210-
await toolbar.openFeatureTreePane()
211-
await toolbar.getDefaultPlaneVisibilityButton('XY').click()
212-
await toolbar.getDefaultPlaneVisibilityButton('XZ').click()
213-
await toolbar.getDefaultPlaneVisibilityButton('YZ').click()
214-
await expect(
215-
toolbar
216-
.getDefaultPlaneVisibilityButton('YZ')
217-
.locator('[aria-label="eye crossed out"]')
218-
).toBeVisible()
219-
220-
await page.mouse.click(clickCoords.x, clickCoords.y)
221-
await page.waitForTimeout(600) // wait for animation
222-
223-
await toolbar.waitUntilSketchingReady()
224-
225-
await expect(
226-
page.getByRole('button', { name: 'line Line', exact: true })
227-
).toBeVisible()
190+
const codeLine2 = 'profile001 = startProfile(sketch001, at = ['
191+
192+
await test.step(`Sketch on the ${plane} plane using custom camera commands to orient`, async () => {
193+
await u.openDebugPanel()
194+
195+
await u.clearCommandLogs()
196+
await toolbar.startSketchBtn.click()
197+
198+
await u.sendCustomCmd(camCommand)
199+
await page.waitForTimeout(100)
200+
await u.sendCustomCmd(updateCamCommand)
201+
202+
await u.closeDebugPanel()
203+
204+
// TODO: can we remove these feature tree checks? They seem out of place.
205+
await toolbar.openFeatureTreePane()
206+
await toolbar.getDefaultPlaneVisibilityButton('XY').click()
207+
await toolbar.getDefaultPlaneVisibilityButton('XZ').click()
208+
await toolbar.getDefaultPlaneVisibilityButton('YZ').click()
209+
await expect(
210+
toolbar
211+
.getDefaultPlaneVisibilityButton('YZ')
212+
.locator('[aria-label="eye crossed out"]')
213+
).toBeVisible()
214+
215+
const resolvedCoords = await scene.convertPagePositionToStream(
216+
clickCoords.x,
217+
clickCoords.y
218+
)
219+
await page.mouse.click(resolvedCoords.x, resolvedCoords.y)
220+
await page.waitForTimeout(600) // wait for animation
228221

229-
await u.closeDebugPanel()
230-
await page.mouse.click(707, 393)
222+
await toolbar.waitUntilSketchingReady()
231223

232-
await expect(page.locator('.cm-content')).toContainText(codeLine1)
233-
await expect(page.locator('.cm-content')).toContainText(codeLine2)
224+
await expect(toolbar.lineBtn).toHaveAttribute('aria-pressed', 'true')
225+
})
234226

235-
await page
236-
.getByRole('button', { name: 'line Line', exact: true })
237-
.first()
238-
.click()
239-
await u.openAndClearDebugPanel()
240-
await page.getByRole('button', { name: 'Exit Sketch' }).click()
241-
await u.expectCmdLog('[data-message-type="execution-done"]')
227+
const lineCoords = await scene.convertPagePositionToStream(707, 393)
228+
await page.mouse.click(lineCoords.x, lineCoords.y)
242229

243-
await u.clearCommandLogs()
244-
await u.removeCurrentCode()
230+
await editor.expectEditor.toContain(codeLine1)
231+
await editor.expectEditor.toContain(codeLine2)
245232
}
246233

247234
const planeConfigs = [
@@ -278,13 +265,13 @@ yzPlane = offsetPlane(YZ, offset = 0.05)
278265
]
279266

280267
for (const config of planeConfigs) {
281-
test(config.plane, async ({ page, homePage, scene, toolbar, cmdBar }) => {
268+
test(config.plane, async ({ page, homePage, scene, toolbar, editor }) => {
282269
await sketchOnPlaneAndBackSideTest(
283270
page,
284271
homePage,
285272
scene,
286273
toolbar,
287-
cmdBar,
274+
editor,
288275
config.plane,
289276
config.coords
290277
)

e2e/playwright/editor-tests.spec.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1420,6 +1420,7 @@ sketch001 = startSketchOn(XZ)
14201420
page,
14211421
homePage,
14221422
toolbar,
1423+
scene,
14231424
}) => {
14241425
await page.addInitScript(async () => {
14251426
localStorage.setItem(
@@ -1446,9 +1447,15 @@ sketch001 = startSketchOn(XZ)
14461447
await toolbar.editSketch(0)
14471448

14481449
await page.waitForTimeout(1000)
1450+
await toolbar.closePane('code')
14491451

14501452
// Click on the bottom segment that lies on the x axis
1451-
await page.mouse.click(width * 0.85, height / 2)
1453+
const clickCoords = await scene.convertPagePositionToStream(
1454+
0.85,
1455+
0.5,
1456+
'ratio'
1457+
)
1458+
await page.mouse.click(clickCoords.x, clickCoords.y)
14521459

14531460
await page.waitForTimeout(1000)
14541461

e2e/playwright/fixtures/toolbarFixture.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,8 @@ export class ToolbarFixture {
5151
/** User button for the user sidebar menu */
5252
userSidebarButton!: Locator
5353
signOutButton!: Locator
54+
/** Selection indicator text in the status bar */
55+
selectionStatus!: Locator
5456

5557
constructor(page: Page) {
5658
this.page = page
@@ -92,6 +94,8 @@ export class ToolbarFixture {
9294

9395
this.userSidebarButton = page.getByTestId('user-sidebar-toggle')
9496
this.signOutButton = page.getByTestId('user-sidebar-sign-out')
97+
98+
this.selectionStatus = page.getByTestId('selection-status')
9599
}
96100

97101
get logoLink() {

e2e/playwright/import-ui.spec.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,8 @@ sketch002 = startSketchOn(extrude001, face = seg01)`
8585

8686
await test.step('check the user is warned when sketching on a imported face', async () => {
8787
// Start sketch mode
88+
await toolbar.closePane('debug')
89+
await toolbar.closePane('code')
8890
await toolbar.startSketchPlaneSelection()
8991

9092
// Click on a face from the imported model

0 commit comments

Comments
 (0)