From 37a1208924f9cb737fb745cb3da012c4e16cf4fe Mon Sep 17 00:00:00 2001 From: Kurt Hutten Date: Thu, 22 Aug 2024 16:13:08 +1000 Subject: [PATCH] Fix existing: Extrude from command bar selects extrude line after (#3547) * Fix existing: Extrude from command bar selects extrude line after #3545 * remove as --------- Co-authored-by: Frank Noirot Co-authored-by: Jess Frazelle --- e2e/playwright/command-bar-tests.spec.ts | 69 +++++++++---------- .../CommandBar/CommandBarKclInput.tsx | 11 +-- 2 files changed, 36 insertions(+), 44 deletions(-) diff --git a/e2e/playwright/command-bar-tests.spec.ts b/e2e/playwright/command-bar-tests.spec.ts index 745eb874f..55b5a5eee 100644 --- a/e2e/playwright/command-bar-tests.spec.ts +++ b/e2e/playwright/command-bar-tests.spec.ts @@ -12,50 +12,47 @@ test.afterEach(async ({ page }, testInfo) => { }) test.describe('Command bar tests', () => { - // TODO fixme: enter is not working in the command bar - test.fixme( - 'Extrude from command bar selects extrude line after', - async ({ page }) => { - await page.addInitScript(async () => { - localStorage.setItem( - 'persistCode', - `const sketch001 = startSketchOn('XY') + test('Extrude from command bar selects extrude line after', async ({ + page, + }) => { + await page.addInitScript(async () => { + localStorage.setItem( + 'persistCode', + `const sketch001 = startSketchOn('XY') |> startProfileAt([-10, -10], %) |> line([20, 0], %) |> line([0, 20], %) |> xLine(-20, %) |> close(%) ` - ) - }) - - const u = await getUtils(page) - await page.setViewportSize({ width: 1200, height: 500 }) - - await u.waitForAuthSkipAppStart() - - await u.openDebugPanel() - await u.expectCmdLog('[data-message-type="execution-done"]') - await u.closeDebugPanel() - - // Click the line of code for xLine. - await page.getByText(`close(%)`).click() // TODO remove this and reinstate // await topHorzSegmentClick() - await page.waitForTimeout(100) - - await page.getByRole('button', { name: 'Extrude' }).click() - await page.waitForTimeout(200) - await page.keyboard.press('Enter') - await page.waitForTimeout(200) - await page.keyboard.press('Enter') - await page.waitForTimeout(200) - await expect(page.locator('.cm-activeLine')).toHaveText( - `const extrude001 = extrude(${KCL_DEFAULT_LENGTH}, sketch001)` ) - } - ) + }) - // TODO fixme: enter is not working in the command bar - test.fixme('Fillet from command bar', async ({ page }) => { + const u = await getUtils(page) + await page.setViewportSize({ width: 1200, height: 500 }) + + await u.waitForAuthSkipAppStart() + + await u.openDebugPanel() + await u.expectCmdLog('[data-message-type="execution-done"]') + await u.closeDebugPanel() + + // Click the line of code for xLine. + await page.getByText(`close(%)`).click() // TODO remove this and reinstate // await topHorzSegmentClick() + await page.waitForTimeout(100) + + await page.getByRole('button', { name: 'Extrude' }).click() + await page.waitForTimeout(200) + await page.keyboard.press('Enter') + await page.waitForTimeout(200) + await page.keyboard.press('Enter') + await page.waitForTimeout(200) + await expect(page.locator('.cm-activeLine')).toHaveText( + `const extrude001 = extrude(${KCL_DEFAULT_LENGTH}, sketch001)` + ) + }) + + test('Fillet from command bar', async ({ page }) => { await page.addInitScript(async () => { localStorage.setItem( 'persistCode', diff --git a/src/components/CommandBar/CommandBarKclInput.tsx b/src/components/CommandBar/CommandBarKclInput.tsx index b15c3627c..25e69c4b9 100644 --- a/src/components/CommandBar/CommandBarKclInput.tsx +++ b/src/components/CommandBar/CommandBarKclInput.tsx @@ -1,6 +1,5 @@ import { Completion } from '@codemirror/autocomplete' import { EditorView, ViewUpdate } from '@codemirror/view' -import { EditorState } from '@codemirror/state' import { CustomIcon } from 'components/CustomIcon' import { useCommandsContext } from 'hooks/useCommandsContext' import { useSettingsAuthContext } from 'hooks/useSettingsAuthContext' @@ -84,17 +83,13 @@ function CommandBarKclInput({ if (event.key === 'Backspace' && value === '') { event.preventDefault() stepBack() + } else if (event.key === 'Enter') { + event.preventDefault() + handleSubmit() } }, }), varMentions(varMentionData), - EditorState.transactionFilter.of((tr) => { - if (tr.newDoc.lines > 1) { - handleSubmit() - return [] - } - return tr - }), EditorView.updateListener.of((vu: ViewUpdate) => { if (vu.docChanged) { setValue(vu.state.doc.toString())