This commit is contained in:
lee-at-zoo-corp
2025-03-28 17:07:25 -04:00
parent 62a18dd2b3
commit 992fec6afb
3 changed files with 25 additions and 35 deletions

View File

@ -112,10 +112,7 @@ export class CmdBarFixture {
* and assumes we are past the `pickCommand` step.
*/
progressCmdBar = async (shouldFuzzProgressMethod = true) => {
// FIXME: Progressing the command bar is a race condition. We have an async useEffect that reports the final state via useCalculateKclExpression. If this does not run quickly enough, it will not "fail" the continue because you can press continue if the state is not ready. E2E tests do not know this.
// Wait 1250ms to assume the await executeAst of the KCL input field is finished
await this.page.waitForTimeout(1250)
if (shouldFuzzProgressMethod || Math.random() > 0.5) {
await this.page.waitForTimeout(2000)
const arrowButton = this.page.getByRole('button', {
name: 'arrow right Continue',
})
@ -126,9 +123,6 @@ export class CmdBarFixture {
.getByRole('button', { name: 'checkmark Submit command' })
.click()
}
} else {
await this.page.keyboard.press('Enter')
}
}
// Added data-testid to the command bar buttons

View File

@ -103,18 +103,16 @@ export class ElectronZoo {
return resolve(undefined)
}
if (Date.now() - timeA > 10000) {
if (Date.now() - timeA > 3000) {
return resolve(undefined)
}
setTimeout(checkDisconnected, 0)
setTimeout(checkDisconnected, 1)
}
checkDisconnected()
})
})
await this.context.tracing.stopChunk({ path: 'trace.zip' })
// Only after cleanup we're ready.
this.available = true
}
@ -156,7 +154,6 @@ export class ElectronZoo {
this.page = await this.electron.firstWindow()
this.context = this.electron.context()
await this.context.tracing.start({ screenshots: true, snapshots: true })
// We need to patch this because addInitScript will bind too late in our
// electron tests, never running. We need to call reload() after each call
@ -178,7 +175,8 @@ export class ElectronZoo {
}
}
await this.context.tracing.startChunk()
this.page = await this.electron.firstWindow()
this.context = this.electron.context()
// THIS IS ABSOLUTELY NECESSARY TO CHANGE THE PROJECT DIRECTORY BETWEEN
// TESTS BECAUSE OF THE ELECTRON INSTANCE REUSE.

View File

@ -1029,7 +1029,7 @@ openSketch = startSketchOn(XY)
})
await test.step(`Go through the command bar flow`, async () => {
await toolbar.offsetPlaneButton.click()
await expect.poll(() => page.getByText('Please select one').count()).toBe(2)
await expect.poll(() => page.getByText('Please select one').count()).toBe(1)
await cmdBar.expectState({
stage: 'arguments',
currentArgKey: 'plane',
@ -1091,7 +1091,6 @@ openSketch = startSketchOn(XY)
await test.step(`Go through the command bar flow`, async () => {
await toolbar.helixButton.click()
await expect.poll(() => page.getByText('AxisOrEdge').count()).toBe(2)
await cmdBar.expectState({
stage: 'arguments',
currentArgKey: 'mode',
@ -1107,7 +1106,7 @@ openSketch = startSketchOn(XY)
commandName: 'Helix',
})
await cmdBar.progressCmdBar()
await expect(page.getByText('Axis')).toBeVisible()
await expect.poll(() => page.getByText('Axis').count()).toBe(6)
await cmdBar.progressCmdBar()
await cmdBar.progressCmdBar()
await cmdBar.progressCmdBar()
@ -1240,19 +1239,18 @@ openSketch = startSketchOn(XY)
await test.step(`Go through the command bar flow`, async () => {
await toolbar.closePane('code')
await toolbar.helixButton.click()
await expect.poll(() => page.getByText('AxisOrEdge').count()).toBe(2)
await cmdBar.expectState({
stage: 'arguments',
currentArgKey: 'axisOrEdge',
currentArgKey: 'mode',
currentArgValue: '',
headerArguments: {
AngleStart: '',
AxisOrEdge: '',
Mode: '',
CounterClockWise: '',
Radius: '',
Revolutions: '',
},
highlightedHeaderArg: 'axisOrEdge',
highlightedHeaderArg: 'mode',
commandName: 'Helix',
})
await cmdBar.selectOption({ name: 'Edge' }).click()
@ -1267,8 +1265,6 @@ openSketch = startSketchOn(XY)
await cmdBar.progressCmdBar()
await page.keyboard.insertText('0')
await cmdBar.progressCmdBar()
// Skip over clockwise
await cmdBar.progressCmdBar()
await page.keyboard.insertText('1')
await cmdBar.progressCmdBar()
await page.keyboard.insertText('100')
@ -1277,7 +1273,7 @@ openSketch = startSketchOn(XY)
await cmdBar.expectState({
stage: 'review',
headerArguments: {
AxisOrEdge: 'Edge',
Mode: 'Edge',
Edge: `1 ${selectionType}`,
AngleStart: '0',
Revolutions: '20',
@ -1543,7 +1539,7 @@ extrude001 = extrude(profile001, length = 100)
if (!shouldPreselect) {
await test.step(`Go through the command bar flow without preselected sketches`, async () => {
await toolbar.loftButton.click()
await expect.poll(() => page.getByText('Please select one').count()).toBe(2)
await expect.poll(() => page.getByText('Please select one').count()).toBe(1)
await cmdBar.expectState({
stage: 'arguments',
currentArgKey: 'selection',
@ -1722,7 +1718,7 @@ sketch002 = startSketchOn(XZ)
await test.step(`Go through the command bar flow`, async () => {
await toolbar.sweepButton.click()
await expect.poll(() => page.getByText('Please select one').count()).toBe(2)
await expect.poll(() => page.getByText('Please select one').count()).toBe(1)
await cmdBar.expectState({
commandName: 'Sweep',
currentArgKey: 'target',
@ -1859,7 +1855,7 @@ sketch002 = startSketchOn(XZ)
await test.step(`Go through the command bar flow and fail validation with a toast`, async () => {
await toolbar.sweepButton.click()
await expect.poll(() => page.getByText('Please select one').count()).toBe(2)
await expect.poll(() => page.getByText('Please select one').count()).toBe(1)
await cmdBar.expectState({
commandName: 'Sweep',
currentArgKey: 'target',
@ -2076,7 +2072,7 @@ extrude001 = extrude(sketch001, length = -12)
await test.step(`Open fillet UI without selecting edges`, async () => {
await page.waitForTimeout(100)
await toolbar.filletButton.click()
await expect.poll(() => page.getByText('Please select one').count()).toBe(2)
await expect.poll(() => page.getByText('Please select one').count()).toBe(1)
await cmdBar.expectState({
stage: 'arguments',
currentArgKey: 'selection',
@ -2573,6 +2569,7 @@ extrude001 = extrude(sketch001, length = -12)
stage: 'arguments',
})
await cmdBar.progressCmdBar()
await page.waitForTimeout(1000)
await cmdBar.expectState({
commandName: 'Chamfer',
highlightedHeaderArg: 'length',
@ -2584,7 +2581,10 @@ extrude001 = extrude(sketch001, length = -12)
},
stage: 'arguments',
})
await cmdBar.argumentInput.focus()
await page.waitForTimeout(1000)
await cmdBar.progressCmdBar()
await page.waitForTimeout(1000)
await cmdBar.expectState({
commandName: 'Chamfer',
headerArguments: {
@ -2668,7 +2668,7 @@ extrude001 = extrude(sketch001, length = -12)
await test.step(`Open chamfer UI without selecting edges`, async () => {
await page.waitForTimeout(100)
await toolbar.chamferButton.click()
await expect.poll(() => page.getByText('Please select one').count()).toBe(2)
await expect.poll(() => page.getByText('Please select one').count()).toBe(1)
await cmdBar.expectState({
stage: 'arguments',
currentArgKey: 'selection',
@ -2978,7 +2978,7 @@ extrude001 = extrude(sketch001, length = 30)
if (!shouldPreselect) {
await test.step(`Go through the command bar flow without preselected faces`, async () => {
await toolbar.shellButton.click()
await expect.poll(() => page.getByText('Please select one').count()).toBe(2)
await expect.poll(() => page.getByText('Please select one').count()).toBe(1)
await cmdBar.expectState({
stage: 'arguments',
currentArgKey: 'selection',
@ -3119,7 +3119,7 @@ extrude001 = extrude(sketch001, length = 40)
await test.step(`Go through the command bar flow, selecting a wall and keeping default thickness`, async () => {
await toolbar.shellButton.click()
await expect.poll(() => page.getByText('Please select one').count()).toBe(2)
await expect.poll(() => page.getByText('Please select one').count()).toBe(1)
await cmdBar.expectState({
stage: 'arguments',
currentArgKey: 'selection',
@ -3131,7 +3131,7 @@ extrude001 = extrude(sketch001, length = 40)
highlightedHeaderArg: 'selection',
commandName: 'Shell',
})
await expect.poll(() => page.getByText('Please select one').count()).toBe(2)
await expect.poll(() => page.getByText('Please select one').count()).toBe(1)
await clickOnCap()
await page.keyboard.down('Shift')
await clickOnWall()
@ -3271,11 +3271,9 @@ extrude002 = extrude(sketch002, length = 50)
})
await expect.poll(() => page.getByText('Please select one').count()).toBe(1)
await clickOnCap()
await page.waitForTimeout(500)
await page.waitForTimeout(1000)
await cmdBar.progressCmdBar()
await page.waitForTimeout(500)
await cmdBar.progressCmdBar()
await page.waitForTimeout(500)
await cmdBar.expectState({
stage: 'review',
headerArguments: {
@ -3426,7 +3424,7 @@ sweep001 = sweep(sketch001, path = sketch002)
await test.step(`Go through the Shell flow and fail validation with a toast`, async () => {
await toolbar.shellButton.click()
await expect.poll(() => page.getByText('Please select one').count()).toBe(2)
await expect.poll(() => page.getByText('Please select one').count()).toBe(1)
await cmdBar.expectState({
stage: 'arguments',
currentArgKey: 'selection',