diff --git a/e2e/playwright/fixtures/cmdBarFixture.ts b/e2e/playwright/fixtures/cmdBarFixture.ts index afab2a928..d5d38d843 100644 --- a/e2e/playwright/fixtures/cmdBarFixture.ts +++ b/e2e/playwright/fixtures/cmdBarFixture.ts @@ -187,6 +187,13 @@ export class CmdBarFixture { return this.page.getByRole('option', options) } + /** + * Select an optional argument from the command bar during review + */ + clickOptionalArgument = async (argName: string) => { + await this.page.getByTestId(`cmd-bar-add-optional-arg-${argName}`).click() + } + /** * Clicks the Create new variable button for kcl input */ diff --git a/e2e/playwright/point-click.spec.ts b/e2e/playwright/point-click.spec.ts index 9c1e32fba..72a4fb974 100644 --- a/e2e/playwright/point-click.spec.ts +++ b/e2e/playwright/point-click.spec.ts @@ -4923,4 +4923,154 @@ extrude001 = extrude(profile001 length = 1)` await editor.expectEditor.toContain(badCode, { shouldNormalise: true }) }) }) + + test('Point-and-click extrude with optional args', async ({ + context, + page, + homePage, + scene, + editor, + toolbar, + cmdBar, + }) => { + const squareProfileCode = `length001 = 100 +sketch001 = startSketchOn(XY) +profile001 = startProfile(sketch001, at = [0, 0]) + |> yLine(length = length001) + |> xLine(length = length001) + |> yLine(length = -length001) + |> line(endAbsolute = [profileStartX(%), profileStartY(%)]) + |> close() + ` + await context.addInitScript((initialCode) => { + localStorage.setItem('persistCode', initialCode) + }, squareProfileCode) + await homePage.goToModelingScene() + await scene.settled(cmdBar) + + await test.step('Select through code', async () => { + await editor.selectText('startProfile(sketch001, at = [0, 0])') + }) + + await test.step('Go through command bar flow', async () => { + await toolbar.extrudeButton.click() + await cmdBar.expectState({ + stage: 'arguments', + currentArgKey: 'sketches', + currentArgValue: '', + headerArguments: { + Profiles: '', + Length: '', + }, + highlightedHeaderArg: 'Profiles', + commandName: 'Extrude', + }) + await cmdBar.progressCmdBar() + await cmdBar.expectState({ + stage: 'arguments', + currentArgKey: 'length', + currentArgValue: '5', + headerArguments: { + Profiles: '1 profile', + Length: '', + }, + highlightedHeaderArg: 'length', + commandName: 'Extrude', + }) + await cmdBar.progressCmdBar() + await cmdBar.expectState({ + stage: 'review', + headerArguments: { + Profiles: '1 profile', + Length: '5', + }, + commandName: 'Extrude', + }) + await cmdBar.clickOptionalArgument('bidirectionalLength') + await cmdBar.expectState({ + stage: 'arguments', + currentArgKey: 'bidirectionalLength', + currentArgValue: '', + headerArguments: { + Profiles: '1 profile', + Length: '5', + BidirectionalLength: '', + }, + highlightedHeaderArg: 'bidirectionalLength', + commandName: 'Extrude', + }) + await page.keyboard.insertText('10') + await cmdBar.progressCmdBar() + await cmdBar.expectState({ + stage: 'review', + headerArguments: { + Profiles: '1 profile', + Length: '5', + BidirectionalLength: '10', + }, + commandName: 'Extrude', + }) + await cmdBar.submit() + }) + + await test.step('Check that the code has changed', async () => { + await scene.settled(cmdBar) + await editor.expectEditor.toContain( + `extrude001 = extrude(profile001, length = 5, bidirectionalLength = 10)`, + { shouldNormalise: true } + ) + }) + + await test.step('Go through the edit flow via feature tree', async () => { + await toolbar.openPane('feature-tree') + const op = await toolbar.getFeatureTreeOperation('Extrude', 0) + await op.dblclick() + await cmdBar.expectState({ + stage: 'arguments', + currentArgKey: 'length', + currentArgValue: '5', + headerArguments: { + Length: '5', + BidirectionalLength: '10', + }, + highlightedHeaderArg: 'length', + commandName: 'Extrude', + }) + await page.keyboard.insertText('10') + await cmdBar.progressCmdBar() + await page.getByRole('button', { name: 'BidirectionalLength' }).click() + await cmdBar.expectState({ + stage: 'arguments', + currentArgKey: 'bidirectionalLength', + currentArgValue: '10', + headerArguments: { + Length: '10', + BidirectionalLength: '10', + }, + highlightedHeaderArg: 'bidirectionalLength', + commandName: 'Extrude', + }) + await page.keyboard.insertText('20') + await cmdBar.progressCmdBar() + await cmdBar.expectState({ + stage: 'review', + headerArguments: { + Length: '10', + BidirectionalLength: '20', + }, + commandName: 'Extrude', + }) + await cmdBar.submit() + }) + + await test.step('Check that the code has changed again', async () => { + await scene.settled(cmdBar) + await toolbar.closePane('feature-tree') + await toolbar.openPane('code') + await editor.expectEditor.toContain( + `extrude001 = extrude(profile001, length = 10, bidirectionalLength = 20)`, + { shouldNormalise: true } + ) + }) + }) }) diff --git a/e2e/playwright/snapshot-tests.spec.ts-snapshots/Draft-segments-should-look-right-4-Google-Chrome-linux.png b/e2e/playwright/snapshot-tests.spec.ts-snapshots/Draft-segments-should-look-right-4-Google-Chrome-linux.png index 456945662..2b782ba28 100644 Binary files a/e2e/playwright/snapshot-tests.spec.ts-snapshots/Draft-segments-should-look-right-4-Google-Chrome-linux.png and b/e2e/playwright/snapshot-tests.spec.ts-snapshots/Draft-segments-should-look-right-4-Google-Chrome-linux.png differ diff --git a/src/components/CommandBar/CommandBarReview.tsx b/src/components/CommandBar/CommandBarReview.tsx index bc12e8918..0acdf14ce 100644 --- a/src/components/CommandBar/CommandBarReview.tsx +++ b/src/components/CommandBar/CommandBarReview.tsx @@ -102,7 +102,7 @@ function CommandBarReview({ stepBack }: { stepBack: () => void }) { ([argName, arg]) => { return (