Migrate code within JS

This commit is contained in:
Adam Chalmers
2024-08-08 18:13:05 -05:00
parent 8e1dd4a84e
commit 5c547efb4f
11 changed files with 59 additions and 58 deletions

View File

@ -648,7 +648,7 @@ test.describe('Editor tests', () => {
`const sketch001 = startSketchOn('XZ')
|> startProfileAt([4.61, -14.01], %)
|> line([12.73, -0.09], %)
|> tangentialArcTo([24.95, -5.38], %)
|> tangentialArcTo([24.95, -5.38], false, %)
|> close(%)`
)
})
@ -701,7 +701,7 @@ test.describe('Editor tests', () => {
// expect the code to have changed
await expect(page.locator('.cm-content')).toHaveText(
`const sketch001 = startSketchOn('XZ') |> startProfileAt([4.61, -14.01], %) |> line([12.73, -0.09], %) |> tangentialArcTo([24.95, -5.38], %) |> close(%)const extrude001 = extrude(5, sketch001)`
`const sketch001 = startSketchOn('XZ') |> startProfileAt([4.61, -14.01], %) |> line([12.73, -0.09], %) |> tangentialArcTo([24.95, -5.38], false, %) |> close(%)const extrude001 = extrude(5, sketch001)`
)
// Now hit undo
@ -714,7 +714,7 @@ test.describe('Editor tests', () => {
.toHaveText(`const sketch001 = startSketchOn('XZ')
|> startProfileAt([4.61, -14.01], %)
|> line([12.73, -0.09], %)
|> tangentialArcTo([24.95, -5.38], %)
|> tangentialArcTo([24.95, -5.38], false, %)
|> close(%)`)
})
@ -728,7 +728,7 @@ test.describe('Editor tests', () => {
`const sketch001 = startSketchOn('XZ')
|> startProfileAt([4.61, -14.01], %)
|> line([12.73, -0.09], %)
|> tangentialArcTo([24.95, -5.38], %)
|> tangentialArcTo([24.95, -5.38], false, %)
|> close(%)
|> extrude(5, %)`
)
@ -819,7 +819,7 @@ test.describe('Editor tests', () => {
.toHaveText(`const sketch001 = startSketchOn('XZ')
|> startProfileAt([7.12, -16.82], %)
|> line([15.4, -2.74], %)
|> tangentialArcTo([24.95, -5.38], %)
|> tangentialArcTo([24.95, -5.38], false, %)
|> line([2.65, -2.69], %)
|> close(%)
|> extrude(5, %)`)
@ -833,7 +833,7 @@ test.describe('Editor tests', () => {
.toHaveText(`const sketch001 = startSketchOn('XZ')
|> startProfileAt([7.12, -16.82], %)
|> line([15.4, -2.74], %)
|> tangentialArcTo([24.95, -5.38], %)
|> tangentialArcTo([24.95, -5.38], false, %)
|> close(%)
|> extrude(5, %)`)
@ -846,7 +846,7 @@ test.describe('Editor tests', () => {
.toHaveText(`const sketch001 = startSketchOn('XZ')
|> startProfileAt([7.12, -16.82], %)
|> line([12.73, -0.09], %)
|> tangentialArcTo([24.95, -5.38], %)
|> tangentialArcTo([24.95, -5.38], false, %)
|> close(%)
|> extrude(5, %)`)
@ -860,7 +860,7 @@ test.describe('Editor tests', () => {
.toHaveText(`const sketch001 = startSketchOn('XZ')
|> startProfileAt([4.61, -14.01], %)
|> line([12.73, -0.09], %)
|> tangentialArcTo([24.95, -5.38], %)
|> tangentialArcTo([24.95, -5.38], false, %)
|> close(%)
|> extrude(5, %)`)
})

View File

@ -61,7 +61,7 @@ test.describe('Sketch tests', () => {
const part002 = startSketchOn('-XZ')
${startProfileAt3}
|> xLine(width / 4, %)
|> tangentialArcTo([width / 2, 0], %)
|> tangentialArcTo([width / 2, 0], false, %)
|> xLine(-width / 4 + wireRadius, %)
|> yLine(wireOffset, %)
|> arc({
@ -115,7 +115,7 @@ test.describe('Sketch tests', () => {
`const sketch001 = startSketchOn('XZ')
|> startProfileAt([4.61, -14.01], %)
|> line([12.73, -0.09], %)
|> tangentialArcTo([24.95, -5.38], %)`
|> tangentialArcTo([24.95, -5.38], false, %)`
)
})
@ -125,7 +125,7 @@ test.describe('Sketch tests', () => {
await expect(async () => {
await page.mouse.click(700, 200)
await page.getByText('tangentialArcTo([24.95, -5.38], %)').click()
await page.getByText('tangentialArcTo([24.95, -5.38], false, %)').click()
await expect(
page.getByRole('button', { name: 'Edit Sketch' })
).toBeEnabled({ timeout: 1000 })
@ -134,7 +134,7 @@ test.describe('Sketch tests', () => {
await page.waitForTimeout(600) // wait for animation
await page.getByText('tangentialArcTo([24.95, -5.38], %)').click()
await page.getByText('tangentialArcTo([24.95, -5.38], false, %)').click()
await page.keyboard.press('End')
await page.keyboard.down('Shift')
await page.keyboard.press('ArrowUp')
@ -192,7 +192,7 @@ test.describe('Sketch tests', () => {
`const sketch001 = startSketchOn('XZ')
|> startProfileAt([4.61, -14.01], %)
|> line([12.73, -0.09], %)
|> tangentialArcTo([24.95, -5.38], %)
|> tangentialArcTo([24.95, -5.38], false, %)
|> close(%)`
)
})
@ -234,7 +234,7 @@ test.describe('Sketch tests', () => {
.toHaveText(`const sketch001 = startSketchOn('XZ')
|> startProfileAt([4.61, -14.01], %)
|> line([12.73, -0.09], %)
|> tangentialArcTo([24.95, -5.38], %)
|> tangentialArcTo([24.95, -5.38], false, %)
|> close(%)`)
} else {
// Ensure we don't see the code.
@ -311,7 +311,7 @@ test.describe('Sketch tests', () => {
.toHaveText(`const sketch001 = startSketchOn('XZ')
|> startProfileAt([6.44, -12.07], %)
|> line([14.72, 1.97], %)
|> tangentialArcTo([24.95, -5.38], %)
|> tangentialArcTo([24.95, -5.38], false, %)
|> line([1.97, 2.06], %)
|> close(%)`)
}
@ -355,7 +355,7 @@ test.describe('Sketch tests', () => {
`const sketch001 = startSketchOn('XZ')
|> startProfileAt([4.61, -14.01], %)
|> line([12.73, -0.09], %)
|> tangentialArcTo([24.95, -5.38], %)
|> tangentialArcTo([24.95, -5.38], false, %)
|> close(%)
|> extrude(5, %)`
)
@ -442,7 +442,7 @@ test.describe('Sketch tests', () => {
.toHaveText(`const sketch001 = startSketchOn('XZ')
|> startProfileAt([7.12, -16.82], %)
|> line([15.4, -2.74], %)
|> tangentialArcTo([24.95, -5.38], %)
|> tangentialArcTo([24.95, -5.38], false, %)
|> line([2.65, -2.69], %)
|> close(%)
|> extrude(5, %)`)
@ -459,7 +459,7 @@ test.describe('Sketch tests', () => {
`const sketch001 = startSketchOn('XZ')
|> startProfileAt([4.61, -14.01], %)
|> line([12.73, -0.09], %)
|> tangentialArcTo([24.95, -5.38], %)
|> tangentialArcTo([24.95, -5.38], false, %)
|> close(%)
|> revolve({ axis: "X",}, %)`
)
@ -545,7 +545,7 @@ test.describe('Sketch tests', () => {
.toHaveText(`const sketch001 = startSketchOn('XZ')
|> startProfileAt([6.44, -12.07], %)
|> line([14.72, 1.97], %)
|> tangentialArcTo([24.95, -5.38], %)
|> tangentialArcTo([24.95, -5.38], false, %)
|> line([1.97, 2.06], %)
|> close(%)
|> revolve({ axis: "X" }, %)`)

View File

@ -570,7 +570,7 @@ test.describe(
await page.mouse.click(startXPx + PUR * 30, 500 - PUR * 20)
code += `
|> tangentialArcTo([21.7, -2.44], %)`
|> tangentialArcTo([21.7, -2.44], false, %)`
await expect(u.codeLocator).toHaveText(code)
// click tangential arc tool again to unequip it
@ -673,7 +673,7 @@ test.describe(
await page.mouse.click(startXPx + PUR * 30, 500 - PUR * 20)
code += `
|> tangentialArcTo([551.2, -62.01], %)`
|> tangentialArcTo([551.2, -62.01], false, %)`
await expect(u.codeLocator).toHaveText(code)
await page

View File

@ -82,7 +82,7 @@ export const TEST_CODE_GIZMO = `const part001 = startSketchOn('XZ')
intersectTag: a,
offset: 0
}, %)
|> tangentialArcTo([13.14 + 0, 13.14], %)
|> tangentialArcTo([13.14 + 0, 13.14], false, %)
|> close(%)
|> extrude(5 + 7, %)
`

View File

@ -200,7 +200,7 @@ test.describe('Testing segment overlays', () => {
intersectTag: a,
offset: 9
}, %)
|> tangentialArcTo([5 + 3.14 + 13, 20 + 3.14], %)
|> tangentialArcTo([5 + 3.14 + 13, 20 + 3.14], false, %)
`
)
})
@ -438,7 +438,7 @@ const part001 = startSketchOn('XZ')
intersectTag: a,
offset: 9
}, %)
|> tangentialArcTo([3.14 + 13, 3.14], %)
|> tangentialArcTo([3.14 + 13, 3.14], false, %)
`
)
localStorage.setItem('disableAxis', 'true')
@ -566,7 +566,7 @@ const part001 = startSketchOn('XZ')
intersectTag: a,
offset: 9
}, %)
|> tangentialArcTo([3.14 + 13, 1.14], %)
|> tangentialArcTo([3.14 + 13, 1.14], false, %)
`
)
localStorage.setItem('disableAxis', 'true')
@ -722,7 +722,7 @@ const part001 = startSketchOn('XZ')
intersectTag: a,
offset: 9
}, %)
|> tangentialArcTo([3.14 + 13, -3.14], %)
|> tangentialArcTo([3.14 + 13, -3.14], false, %)
`
)
localStorage.setItem('disableAxis', 'true')
@ -755,9 +755,9 @@ const part001 = startSketchOn('XZ')
await clickConstrained({
hoverPos: { x: tangentialArcTo.x, y: tangentialArcTo.y },
constraintType: 'xAbsolute',
expectBeforeUnconstrained: 'tangentialArcTo([3.14 + 13, -3.14], %)',
expectAfterUnconstrained: 'tangentialArcTo([16.14, -3.14], %)',
expectFinal: 'tangentialArcTo([xAbs001, -3.14], %)',
expectBeforeUnconstrained: 'tangentialArcTo([3.14 + 13, -3.14], false, %)',
expectAfterUnconstrained: 'tangentialArcTo([16.14, -3.14], false, %)',
expectFinal: 'tangentialArcTo([xAbs001, -3.14], false, %)',
ang: ang + 180,
steps: 6,
locator: '[data-overlay-toolbar-index="12"]',
@ -766,9 +766,9 @@ const part001 = startSketchOn('XZ')
await clickUnconstrained({
hoverPos: { x: tangentialArcTo.x, y: tangentialArcTo.y },
constraintType: 'yAbsolute',
expectBeforeUnconstrained: 'tangentialArcTo([xAbs001, -3.14], %)',
expectAfterUnconstrained: 'tangentialArcTo([xAbs001, yAbs001], %)',
expectFinal: 'tangentialArcTo([xAbs001, -3.14], %)',
expectBeforeUnconstrained: 'tangentialArcTo([xAbs001, -3.14], false, %)',
expectAfterUnconstrained: 'tangentialArcTo([xAbs001, yAbs001], false, %)',
expectFinal: 'tangentialArcTo([xAbs001, -3.14], false, %)',
ang: ang + 180,
steps: 10,
locator: '[data-overlay-toolbar-index="12"]',
@ -835,7 +835,7 @@ const part001 = startSketchOn('XZ')
intersectTag: a,
offset: 9
}, %)
|> tangentialArcTo([3.14 + 13, 1.14], %)
|> tangentialArcTo([3.14 + 13, 1.14], false, %)
`
)
localStorage.setItem('disableAxis', 'true')
@ -866,7 +866,7 @@ const part001 = startSketchOn('XZ')
let ang = await u.getAngle(`[data-overlay-index="${12}"]`)
await deleteSegmentSequence({
hoverPos: { x: segmentToDelete.x, y: segmentToDelete.y },
codeToBeDeleted: 'tangentialArcTo([3.14 + 13, 1.14], %)',
codeToBeDeleted: 'tangentialArcTo([3.14 + 13, 1.14], false, %)',
stdLibFnName: 'tangentialArcTo',
ang: ang + 180,
steps: 6,

View File

@ -476,7 +476,7 @@ const sketch002 = startSketchOn(launderExtrudeThroughVar, seg02)
intersectTag: a,
offset: 0
}, %)
|> tangentialArcTo([13.14 + 0, 13.14], %)
|> tangentialArcTo([13.14 + 0, 13.14], false, %)
|> close(%)
|> extrude(5 + 7, %)
`
@ -680,7 +680,7 @@ const extrude001 = extrude(10, sketch001)`
},
{
pos: [1107, 161],
expectedCode: 'tangentialArcTo([167.95, -28.85], %)',
expectedCode: 'tangentialArcTo([167.95, -28.85], false, %)',
},
] as const
await page.addInitScript(

View File

@ -584,7 +584,7 @@ describe('Testing removeSingleConstraintInfo', () => {
intersectTag: a,
offset: 0 + 0
}, %)
|> tangentialArcTo([3.14 + 0, 13.14 + 0], %)`
|> tangentialArcTo([3.14 + 0, 13.14 + 0], false, %)`
test.each([
[' line([3 + 0, 4], %)', 'arrayIndex', 1],
[
@ -626,7 +626,7 @@ describe('Testing removeSingleConstraintInfo', () => {
'objectProperty',
'offset',
],
['tangentialArcTo([3.14 + 0, 13.14], %)', 'arrayIndex', 1],
['tangentialArcTo([3.14 + 0, 13.14], false, %)', 'arrayIndex', 1],
])('stdlib fn: %s', async (expectedFinish, key, value) => {
const ast = parse(code)
if (err(ast)) throw ast

View File

@ -82,8 +82,8 @@ describe('Testing addFillet', () => {
|> line([60.04, -55.72], %)
|> line([1.29, -115.74], %)
|> line([-87.24, -47.08], %)
|> tangentialArcTo([56.15, -94.58], %)
|> tangentialArcTo([14.68, -104.52], %)
|> tangentialArcTo([56.15, -94.58], false, %)
|> tangentialArcTo([14.68, -104.52], false, %)
|> lineTo([profileStartX(%), profileStartY(%)], %)
|> close(%)
const extrude001 = extrude(50, sketch001)
@ -97,8 +97,8 @@ describe('Testing addFillet', () => {
|> line([60.04, -55.72], %, $seg01)
|> line([1.29, -115.74], %)
|> line([-87.24, -47.08], %)
|> tangentialArcTo([56.15, -94.58], %)
|> tangentialArcTo([14.68, -104.52], %)
|> tangentialArcTo([56.15, -94.58], false, %)
|> tangentialArcTo([14.68, -104.52], false, %)
|> lineTo([profileStartX(%), profileStartY(%)], %)
|> close(%)
const extrude001 = extrude(50, sketch001)
@ -125,8 +125,8 @@ const extrude001 = extrude(50, sketch001)
|> line([60.04, -55.72], %)
|> line([1.29, -115.74], %)
|> line([-87.24, -47.08], %, $seg01)
|> tangentialArcTo([56.15, -94.58], %)
|> tangentialArcTo([14.68, -104.52], %)
|> tangentialArcTo([56.15, -94.58], false, %)
|> tangentialArcTo([14.68, -104.52], false, %)
|> lineTo([profileStartX(%), profileStartY(%)], %)
|> close(%)
const extrude001 = extrude(50, sketch001)
@ -140,8 +140,8 @@ const extrude001 = extrude(50, sketch001)
|> line([60.04, -55.72], %, $seg02)
|> line([1.29, -115.74], %)
|> line([-87.24, -47.08], %, $seg01)
|> tangentialArcTo([56.15, -94.58], %)
|> tangentialArcTo([14.68, -104.52], %)
|> tangentialArcTo([56.15, -94.58], false, %)
|> tangentialArcTo([14.68, -104.52], false, %)
|> lineTo([profileStartX(%), profileStartY(%)], %)
|> close(%)
const extrude001 = extrude(50, sketch001)
@ -168,8 +168,8 @@ const extrude001 = extrude(50, sketch001)
|> line([60.04, -55.72], %)
|> line([1.29, -115.74], %)
|> line([-87.24, -47.08], %, $seg03)
|> tangentialArcTo([56.15, -94.58], %)
|> tangentialArcTo([14.68, -104.52], %)
|> tangentialArcTo([56.15, -94.58], false, %)
|> tangentialArcTo([14.68, -104.52], false, %)
|> lineTo([profileStartX(%), profileStartY(%)], %)
|> close(%)
const extrude001 = extrude(50, sketch001)
@ -183,8 +183,8 @@ const extrude001 = extrude(50, sketch001)
|> line([60.04, -55.72], %)
|> line([1.29, -115.74], %)
|> line([-87.24, -47.08], %, $seg03)
|> tangentialArcTo([56.15, -94.58], %)
|> tangentialArcTo([14.68, -104.52], %)
|> tangentialArcTo([56.15, -94.58], false, %)
|> tangentialArcTo([14.68, -104.52], false, %)
|> lineTo([profileStartX(%), profileStartY(%)], %)
|> close(%)
const extrude001 = extrude(50, sketch001)
@ -210,8 +210,8 @@ const extrude001 = extrude(50, sketch001)
|> line([60.04, -55.72], %)
|> line([1.29, -115.74], %)
|> line([-87.24, -47.08], %, $seg03)
|> tangentialArcTo([56.15, -94.58], %)
|> tangentialArcTo([14.68, -104.52], %)
|> tangentialArcTo([56.15, -94.58], false, %)
|> tangentialArcTo([14.68, -104.52], false, %)
|> lineTo([profileStartX(%), profileStartY(%)], %)
|> close(%)
const extrude001 = extrude(50, sketch001)
@ -225,8 +225,8 @@ const extrude001 = extrude(50, sketch001)
|> line([60.04, -55.72], %, $seg01)
|> line([1.29, -115.74], %)
|> line([-87.24, -47.08], %, $seg03)
|> tangentialArcTo([56.15, -94.58], %)
|> tangentialArcTo([14.68, -104.52], %)
|> tangentialArcTo([56.15, -94.58], false, %)
|> tangentialArcTo([14.68, -104.52], false, %)
|> lineTo([profileStartX(%), profileStartY(%)], %)
|> close(%)
const extrude001 = extrude(50, sketch001)

View File

@ -270,7 +270,7 @@ describe('testing getConstraintInfo', () => {
intersectTag: 'a',
offset: 0
}, %)
|> tangentialArcTo([3.14, 13.14], %)`
|> tangentialArcTo([3.14, 13.14], false, %)`
const ast = parse(code)
test.each([
[
@ -629,7 +629,7 @@ describe('testing getConstraintInfo', () => {
intersectTag: 'a',
offset: 0
}, %)
|> tangentialArcTo([3.14, 13.14], %)`
|> tangentialArcTo([3.14, 13.14], false, %)`
const ast = parse(code)
test.each([
[
@ -783,7 +783,7 @@ describe('testing getConstraintInfo', () => {
intersectTag: 'a',
offset: 0 + 0
}, %)
|> tangentialArcTo([3.14 + 0, 13.14 + 0], %)`
|> tangentialArcTo([3.14 + 0, 13.14 + 0], false, %)`
const ast = parse(code)
test.each([
[

View File

@ -811,6 +811,7 @@ export const tangentialArcTo: SketchLineHelper = {
}
const newLine = createCallExpression('tangentialArcTo', [
createArrayExpression([toX, toY]),
false,
createPipeSubstitution(),
])
if (pipe.type === 'PipeExpression') {

View File

@ -3152,7 +3152,7 @@ mod snapshot_tests {
a,
r#"const boxSketch = startSketchAt([0, 0])
|> line([0, 10], %)
|> tangentialArc([-5, 5], %)
|> tangentialArcTo([-5, 5], true, %)
|> line([5, -15], %)
|> extrude(10, %)
"#