Update all test instances of var name with number index after merge with main

This commit is contained in:
Frank Noirot
2024-02-21 14:10:57 -05:00
parent ac43530feb
commit 8c4b63b523
12 changed files with 38 additions and 35 deletions

View File

@ -65,7 +65,7 @@ test('Basic sketch', async ({ page }) => {
await page.mouse.click(700, 200) await page.mouse.click(700, 200)
await expect(page.locator('.cm-content')).toHaveText( await expect(page.locator('.cm-content')).toHaveText(
`const part001 = startSketchOn('-XZ')` `const part = startSketchOn('-XZ')`
) )
await page.waitForTimeout(300) // TODO detect animation ending, or disable animation await page.waitForTimeout(300) // TODO detect animation ending, or disable animation
@ -74,7 +74,7 @@ test('Basic sketch', async ({ page }) => {
await page.mouse.click(startXPx + PUR * 10, 500 - PUR * 10) await page.mouse.click(startXPx + PUR * 10, 500 - PUR * 10)
const startAt = '[23.74, -32.03]' const startAt = '[23.74, -32.03]'
await expect(page.locator('.cm-content')) await expect(page.locator('.cm-content'))
.toHaveText(`const part001 = startSketchOn('-XZ') .toHaveText(`const part = startSketchOn('-XZ')
|> startProfileAt(${startAt}, %)`) |> startProfileAt(${startAt}, %)`)
await page.waitForTimeout(100) await page.waitForTimeout(100)
@ -84,19 +84,19 @@ test('Basic sketch', async ({ page }) => {
const num = 23.97 const num = 23.97
await expect(page.locator('.cm-content')) await expect(page.locator('.cm-content'))
.toHaveText(`const part001 = startSketchOn('-XZ') .toHaveText(`const part = startSketchOn('-XZ')
|> startProfileAt(${startAt}, %) |> startProfileAt(${startAt}, %)
|> line([${num}, 0], %)`) |> line([${num}, 0], %)`)
await page.mouse.click(startXPx + PUR * 20, 500 - PUR * 20) await page.mouse.click(startXPx + PUR * 20, 500 - PUR * 20)
await expect(page.locator('.cm-content')) await expect(page.locator('.cm-content'))
.toHaveText(`const part001 = startSketchOn('-XZ') .toHaveText(`const part = startSketchOn('-XZ')
|> startProfileAt(${startAt}, %) |> startProfileAt(${startAt}, %)
|> line([${num}, 0], %) |> line([${num}, 0], %)
|> line([0, ${num}], %)`) |> line([0, ${num}], %)`)
await page.mouse.click(startXPx, 500 - PUR * 20) await page.mouse.click(startXPx, 500 - PUR * 20)
await expect(page.locator('.cm-content')) await expect(page.locator('.cm-content'))
.toHaveText(`const part001 = startSketchOn('-XZ') .toHaveText(`const part = startSketchOn('-XZ')
|> startProfileAt(${startAt}, %) |> startProfileAt(${startAt}, %)
|> line([${num}, 0], %) |> line([${num}, 0], %)
|> line([0, ${num}], %) |> line([0, ${num}], %)
@ -121,11 +121,11 @@ test('Basic sketch', async ({ page }) => {
await page.getByRole('button', { name: 'Equal Length' }).click() await page.getByRole('button', { name: 'Equal Length' }).click()
await expect(page.locator('.cm-content')) await expect(page.locator('.cm-content'))
.toHaveText(`const part001 = startSketchOn('-XZ') .toHaveText(`const part = startSketchOn('-XZ')
|> startProfileAt(${startAt}, %) |> startProfileAt(${startAt}, %)
|> line({ to: [${num}, 0], tag: 'seg01' }, %) |> line({ to: [${num}, 0], tag: 'seg' }, %)
|> line([0, ${num}], %) |> line([0, ${num}], %)
|> angledLine([180, segLen('seg01', %)], %)`) |> angledLine([180, segLen('seg', %)], %)`)
}) })
test('if you write invalid kcl you get inlined errors', async ({ page }) => { test('if you write invalid kcl you get inlined errors', async ({ page }) => {
@ -200,7 +200,7 @@ test('executes on load', async ({ page, context }) => {
await context.addInitScript(async () => { await context.addInitScript(async () => {
localStorage.setItem( localStorage.setItem(
'persistCode', 'persistCode',
`const part001 = startSketchOn('-XZ') `const part = startSketchOn('-XZ')
|> startProfileAt([-6.95, 4.98], %) |> startProfileAt([-6.95, 4.98], %)
|> line([25.1, 0.41], %) |> line([25.1, 0.41], %)
|> line([0.73, -14.93], %) |> line([0.73, -14.93], %)
@ -214,16 +214,16 @@ test('executes on load', async ({ page, context }) => {
// expand variables section // expand variables section
await page.getByText('Variables').click() await page.getByText('Variables').click()
// can find part001 in the variables summary (pretty-json-container, makes sure we're not looking in the code editor) // can find part in the variables summary (pretty-json-container, makes sure we're not looking in the code editor)
// part001 only shows up in the variables summary if it's been executed // part only shows up in the variables summary if it's been executed
await page.waitForFunction(() => { await page.waitForFunction(() => {
const variablesElement = document.querySelector( const variablesElement = document.querySelector(
'.pretty-json-container' '.pretty-json-container'
) as HTMLDivElement ) as HTMLDivElement
return variablesElement.innerHTML.includes('part001') return variablesElement.innerHTML.includes('part')
}) })
await expect( await expect(
page.locator('.pretty-json-container >> text=part001') page.locator('.pretty-json-container >> text=part')
).toBeVisible() ).toBeVisible()
}) })
@ -308,7 +308,7 @@ test('Can create sketches on all planes and their back sides', async ({
plane = 'XY', plane = 'XY',
rounded = false, rounded = false,
otherThing = '1' otherThing = '1'
) => `const part001 = startSketchOn('${plane}') ) => `const part = startSketchOn('${plane}')
|> startProfileAt([28.9${otherThing}, -39${rounded ? '' : '.01'}], %)` |> startProfileAt([28.9${otherThing}, -39${rounded ? '' : '.01'}], %)`
await TestSinglePlane({ await TestSinglePlane({
viewCmd: camPos, viewCmd: camPos,
@ -357,7 +357,7 @@ test('Auto complete works', async ({ page }) => {
// and arrowing down to an option // and arrowing down to an option
await page.click('.cm-content') await page.click('.cm-content')
await page.keyboard.type('const part001 = start') await page.keyboard.type('const part = start')
// expect there to be three auto complete options // expect there to be three auto complete options
await expect(page.locator('.cm-completionLabel')).toHaveCount(3) await expect(page.locator('.cm-completionLabel')).toHaveCount(3)
@ -383,7 +383,7 @@ test('Auto complete works', async ({ page }) => {
await page.keyboard.type('(5, %)') await page.keyboard.type('(5, %)')
await expect(page.locator('.cm-content')) await expect(page.locator('.cm-content'))
.toHaveText(`const part001 = startSketchOn('XY') .toHaveText(`const part = startSketchOn('XY')
|> startProfileAt([0,0], %) |> startProfileAt([0,0], %)
|> xLine(5, %)`) |> xLine(5, %)`)
}) })
@ -463,7 +463,7 @@ test('Selections work on fresh and edited sketch', async ({ page }) => {
await page.mouse.click(startXPx + PUR * 10, 500 - PUR * 10) await page.mouse.click(startXPx + PUR * 10, 500 - PUR * 10)
const startAt = '[23.74, -32.03]' const startAt = '[23.74, -32.03]'
await expect(page.locator('.cm-content')) await expect(page.locator('.cm-content'))
.toHaveText(`const part001 = startSketchOn('-XZ') .toHaveText(`const part = startSketchOn('-XZ')
|> startProfileAt(${startAt}, %)`) |> startProfileAt(${startAt}, %)`)
await u.closeDebugPanel() await u.closeDebugPanel()
@ -473,19 +473,19 @@ test('Selections work on fresh and edited sketch', async ({ page }) => {
const num = 23.97 const num = 23.97
const num2 = '47.71' const num2 = '47.71'
await expect(page.locator('.cm-content')) await expect(page.locator('.cm-content'))
.toHaveText(`const part001 = startSketchOn('-XZ') .toHaveText(`const part = startSketchOn('-XZ')
|> startProfileAt(${startAt}, %) |> startProfileAt(${startAt}, %)
|> line([${num}, 0], %)`) |> line([${num}, 0], %)`)
await page.mouse.click(startXPx + PUR * 20, 500 - PUR * 20) await page.mouse.click(startXPx + PUR * 20, 500 - PUR * 20)
await expect(page.locator('.cm-content')) await expect(page.locator('.cm-content'))
.toHaveText(`const part001 = startSketchOn('-XZ') .toHaveText(`const part = startSketchOn('-XZ')
|> startProfileAt(${startAt}, %) |> startProfileAt(${startAt}, %)
|> line([${num}, 0], %) |> line([${num}, 0], %)
|> line([0, ${num}], %)`) |> line([0, ${num}], %)`)
await page.mouse.click(startXPx, 500 - PUR * 20) await page.mouse.click(startXPx, 500 - PUR * 20)
await expect(page.locator('.cm-content')) await expect(page.locator('.cm-content'))
.toHaveText(`const part001 = startSketchOn('-XZ') .toHaveText(`const part = startSketchOn('-XZ')
|> startProfileAt(${startAt}, %) |> startProfileAt(${startAt}, %)
|> line([${num}, 0], %) |> line([${num}, 0], %)
|> line([0, ${num}], %) |> line([0, ${num}], %)
@ -639,7 +639,7 @@ test('Can extrude from the command bar', async ({ page, context }) => {
'persistCode', 'persistCode',
` `
const distance = sqrt(20) const distance = sqrt(20)
const part001 = startSketchOn('-XZ') const part = startSketchOn('-XZ')
|> startProfileAt([-6.95, 4.98], %) |> startProfileAt([-6.95, 4.98], %)
|> line([25.1, 0.41], %) |> line([25.1, 0.41], %)
|> line([0.73, -14.93], %) |> line([0.73, -14.93], %)
@ -699,7 +699,7 @@ test('Can extrude from the command bar', async ({ page, context }) => {
await expect(page.locator('.cm-content')).toHaveText( await expect(page.locator('.cm-content')).toHaveText(
`const distance = sqrt(20) `const distance = sqrt(20)
const distance001 = 5 + 7 const distance001 = 5 + 7
const part001 = startSketchOn('-XZ') const part = startSketchOn('-XZ')
|> startProfileAt([-6.95, 4.98], %) |> startProfileAt([-6.95, 4.98], %)
|> line([25.1, 0.41], %) |> line([25.1, 0.41], %)
|> line([0.73, -14.93], %) |> line([0.73, -14.93], %)
@ -730,7 +730,7 @@ test('Can add multiple sketches', async ({ page }) => {
await page.mouse.click(700, 200) await page.mouse.click(700, 200)
await expect(page.locator('.cm-content')).toHaveText( await expect(page.locator('.cm-content')).toHaveText(
`const part001 = startSketchOn('-XZ')` `const part = startSketchOn('-XZ')`
) )
await page.waitForTimeout(500) // TODO detect animation ending, or disable animation await page.waitForTimeout(500) // TODO detect animation ending, or disable animation
@ -739,7 +739,7 @@ test('Can add multiple sketches', async ({ page }) => {
await page.mouse.click(startXPx + PUR * 10, 500 - PUR * 10) await page.mouse.click(startXPx + PUR * 10, 500 - PUR * 10)
const startAt = '[23.74, -32.03]' const startAt = '[23.74, -32.03]'
await expect(page.locator('.cm-content')) await expect(page.locator('.cm-content'))
.toHaveText(`const part001 = startSketchOn('-XZ') .toHaveText(`const part = startSketchOn('-XZ')
|> startProfileAt(${startAt}, %)`) |> startProfileAt(${startAt}, %)`)
await page.waitForTimeout(100) await page.waitForTimeout(100)
@ -749,18 +749,18 @@ test('Can add multiple sketches', async ({ page }) => {
const num = 23.97 const num = 23.97
await expect(page.locator('.cm-content')) await expect(page.locator('.cm-content'))
.toHaveText(`const part001 = startSketchOn('-XZ') .toHaveText(`const part = startSketchOn('-XZ')
|> startProfileAt(${startAt}, %) |> startProfileAt(${startAt}, %)
|> line([${num}, 0], %)`) |> line([${num}, 0], %)`)
await page.mouse.click(startXPx + PUR * 20, 500 - PUR * 20) await page.mouse.click(startXPx + PUR * 20, 500 - PUR * 20)
await expect(page.locator('.cm-content')) await expect(page.locator('.cm-content'))
.toHaveText(`const part001 = startSketchOn('-XZ') .toHaveText(`const part = startSketchOn('-XZ')
|> startProfileAt(${startAt}, %) |> startProfileAt(${startAt}, %)
|> line([${num}, 0], %) |> line([${num}, 0], %)
|> line([0, ${num}], %)`) |> line([0, ${num}], %)`)
await page.mouse.click(startXPx, 500 - PUR * 20) await page.mouse.click(startXPx, 500 - PUR * 20)
const finalCodeFirstSketch = `const part001 = startSketchOn('-XZ') const finalCodeFirstSketch = `const part = startSketchOn('-XZ')
|> startProfileAt(${startAt}, %) |> startProfileAt(${startAt}, %)
|> line([${num}, 0], %) |> line([${num}, 0], %)
|> line([0, ${num}], %) |> line([0, ${num}], %)
@ -776,7 +776,7 @@ test('Can add multiple sketches', async ({ page }) => {
await u.updateCamPosition([0, 100, 100]) await u.updateCamPosition([0, 100, 100])
// start a new sketch // start a second, new sketch
await u.clearCommandLogs() await u.clearCommandLogs()
await page.getByRole('button', { name: 'Start Sketch' }).click() await page.getByRole('button', { name: 'Start Sketch' }).click()
await page.waitForTimeout(100) await page.waitForTimeout(100)
@ -787,11 +787,14 @@ test('Can add multiple sketches', async ({ page }) => {
await page.mouse.click(startXPx + PUR * 10, 500 - PUR * 10) await page.mouse.click(startXPx + PUR * 10, 500 - PUR * 10)
const startAt2 = '[23.61, -31.85]' const startAt2 = '[23.61, -31.85]'
// This second part should have "001" added to the
// default variable name "part" because it's the second part
await expect( await expect(
(await page.locator('.cm-content').innerText()).replace(/\s/g, '') (await page.locator('.cm-content').innerText()).replace(/\s/g, '')
).toBe( ).toBe(
`${finalCodeFirstSketch} `${finalCodeFirstSketch}
const part002 = startSketchOn('XY') const part001 = startSketchOn('XY')
|> startProfileAt(${startAt2}, %)`.replace(/\s/g, '') |> startProfileAt(${startAt2}, %)`.replace(/\s/g, '')
) )
await page.waitForTimeout(100) await page.waitForTimeout(100)
@ -805,7 +808,7 @@ const part002 = startSketchOn('XY')
(await page.locator('.cm-content').innerText()).replace(/\s/g, '') (await page.locator('.cm-content').innerText()).replace(/\s/g, '')
).toBe( ).toBe(
`${finalCodeFirstSketch} `${finalCodeFirstSketch}
const part002 = startSketchOn('XY') const part001 = startSketchOn('XY')
|> startProfileAt(${startAt2}, %) |> startProfileAt(${startAt2}, %)
|> line([${num2}, 0], %)`.replace(/\s/g, '') |> line([${num2}, 0], %)`.replace(/\s/g, '')
) )
@ -815,7 +818,7 @@ const part002 = startSketchOn('XY')
(await page.locator('.cm-content').innerText()).replace(/\s/g, '') (await page.locator('.cm-content').innerText()).replace(/\s/g, '')
).toBe( ).toBe(
`${finalCodeFirstSketch} `${finalCodeFirstSketch}
const part002 = startSketchOn('XY') const part001 = startSketchOn('XY')
|> startProfileAt(${startAt2}, %) |> startProfileAt(${startAt2}, %)
|> line([${num2}, 0], %) |> line([${num2}, 0], %)
|> line([0, ${num2}], %)`.replace(/\s/g, '') |> line([0, ${num2}], %)`.replace(/\s/g, '')
@ -825,7 +828,7 @@ const part002 = startSketchOn('XY')
(await page.locator('.cm-content').innerText()).replace(/\s/g, '') (await page.locator('.cm-content').innerText()).replace(/\s/g, '')
).toBe( ).toBe(
`${finalCodeFirstSketch} `${finalCodeFirstSketch}
const part002 = startSketchOn('XY') const part001 = startSketchOn('XY')
|> startProfileAt(${startAt2}, %) |> startProfileAt(${startAt2}, %)
|> line([${num2}, 0], %) |> line([${num2}, 0], %)
|> line([0, ${num2}], %) |> line([0, ${num2}], %)
@ -892,7 +895,7 @@ test("Various pipe expressions should and shouldn't allow edit and or extrude",
}: any) => { }: any) => {
localStorage.setItem( localStorage.setItem(
'persistCode', 'persistCode',
`const part001 = startSketchOn('-XZ') `const part = startSketchOn('-XZ')
${extrudeAndEditBlocked} ${extrudeAndEditBlocked}
|> line([25.96, 2.93], %) |> line([25.96, 2.93], %)
|> line([5.25, -5.72], %) |> line([5.25, -5.72], %)
@ -971,7 +974,7 @@ fn yohey = (pos) => {
await page.mouse.click(700, 200) await page.mouse.click(700, 200)
// expect main content to contain `part005` i.e. started a new sketch // expect main content to contain `part005` i.e. started a new sketch
await expect(page.locator('.cm-content')).toHaveText( await expect(page.locator('.cm-content')).toHaveText(
/part005 = startSketchOn\('-XZ'\)/ /part004 = startSketchOn\('-XZ'\)/
) )
}) })
@ -997,7 +1000,7 @@ test('Deselecting line tool should mean nothing happens on click', async ({
await page.mouse.click(700, 200) await page.mouse.click(700, 200)
await expect(page.locator('.cm-content')).toHaveText( await expect(page.locator('.cm-content')).toHaveText(
`const part001 = startSketchOn('-XZ')` `const part = startSketchOn('-XZ')`
) )
await page.waitForTimeout(300) await page.waitForTimeout(300)

Binary file not shown.

After

Width:  |  Height:  |  Size: 40 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 43 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 103 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 86 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 117 KiB