Skip to content

Commit

Permalink
Set default extrude distance expression to something more sensible, l…
Browse files Browse the repository at this point in the history
…ike `5` (#2351)

* Set default extrude distance expression to something more sensible, like 5

* A snapshot a day keeps the bugs away! 📷🐛 (OS: ubuntu)

* Rerun CI

* run CI

* A snapshot a day keeps the bugs away! 📷🐛 (OS: ubuntu)

* CI

* Use old 5 + 7 for highlight test it's touchy

* Same with sketch on face it seems to work better with 5 + 7 and that's fine

---------

Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
  • Loading branch information
franknoirot and github-actions[bot] authored May 17, 2024
1 parent 3b840e9 commit 1b87886
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 11 deletions.
11 changes: 6 additions & 5 deletions e2e/playwright/flow-tests.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import {
} from './storageStates'
import * as TOML from '@iarna/toml'
import { Coords2d } from 'lang/std/sketch'
import { KCL_DEFAULT_LENGTH } from 'lib/constants'

/*
debug helper: unfortunately we do rely on exact coord mouse clicks in a few places
Expand Down Expand Up @@ -1145,7 +1146,7 @@ test.describe('Command bar tests', () => {

// Assert we're back on the distance step
await expect(
page.getByRole('button', { name: 'Distance 12', exact: false })
page.getByRole('button', { name: 'Distance 5', exact: false })
).toBeDisabled()

await continueButton.click()
Expand All @@ -1156,7 +1157,7 @@ test.describe('Command bar tests', () => {
// Unfortunately this indentation seems to matter for the test
await expect(page.locator('.cm-content')).toHaveText(
`const distance = sqrt(20)
const distance001 = 5 + 7
const distance001 = ${KCL_DEFAULT_LENGTH}
const part001 = startSketchOn('-XZ')
|> startProfileAt([-6.95, 10.98], %)
|> line([25.1, 0.41], %)
Expand Down Expand Up @@ -1353,7 +1354,7 @@ test('ProgramMemory can be serialised', async ({ page }) => {

test('Hovering over 3d features highlights code', async ({ page }) => {
const u = getUtils(page)
await page.addInitScript(async () => {
await page.addInitScript(async (KCL_DEFAULT_LENGTH) => {
localStorage.setItem(
'persistCode',
`const part001 = startSketchOn('-XZ')
Expand All @@ -1378,7 +1379,7 @@ test('Hovering over 3d features highlights code', async ({ page }) => {
|> extrude(5 + 7, %)
`
)
})
}, KCL_DEFAULT_LENGTH)
await page.setViewportSize({ width: 1000, height: 500 })
await page.goto('/')
await u.waitForAuthSkipAppStart()
Expand Down Expand Up @@ -1957,6 +1958,6 @@ test('Extrude from command bar selects extrude line after', async ({
await page.keyboard.press('Enter')
await page.waitForTimeout(100)
await expect(page.locator('.cm-activeLine')).toHaveText(
` |> extrude(5 + 7, %)`
` |> extrude(${KCL_DEFAULT_LENGTH}, %)`
)
})
10 changes: 5 additions & 5 deletions e2e/playwright/snapshot-tests.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { getUtils } from './test-utils'
import { Models } from '@kittycad/lib'
import fsp from 'fs/promises'
import { spawn } from 'child_process'
import { APP_NAME } from 'lib/constants'
import { APP_NAME, KCL_DEFAULT_LENGTH } from 'lib/constants'
import JSZip from 'jszip'
import path from 'path'
import { TEST_SETTINGS, TEST_SETTINGS_KEY } from './storageStates'
Expand Down Expand Up @@ -718,24 +718,24 @@ test.describe('Client side scene scale should match engine scale', () => {

test('Sketch on face with none z-up', async ({ page, context }) => {
const u = getUtils(page)
await context.addInitScript(async () => {
await context.addInitScript(async (KCL_DEFAULT_LENGTH) => {
localStorage.setItem(
'persistCode',
`const part001 = startSketchOn('-XZ')
|> startProfileAt([1.4, 2.47], %)
|> line([9.31, 10.55], %, 'seg01')
|> line([11.91, -10.42], %)
|> close(%)
|> extrude(5 + 7, %)
|> extrude(${KCL_DEFAULT_LENGTH}, %)
const part002 = startSketchOn(part001, 'seg01')
|> startProfileAt([8, 8], %)
|> line([4.68, 3.05], %)
|> line([0, -7.79], %, 'seg02')
|> close(%)
|> extrude(5 + 7, %)
|> extrude(${KCL_DEFAULT_LENGTH}, %)
`
)
})
}, KCL_DEFAULT_LENGTH)

await page.setViewportSize({ width: 1200, height: 500 })
await page.goto('/')
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 2 additions & 1 deletion src/lib/commandBarConfigs/modelingCommandConfig.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { Models } from '@kittycad/lib'
import { CommandSetConfig, KclCommandValue } from 'lib/commandTypes'
import { KCL_DEFAULT_LENGTH } from 'lib/constants'
import { Selections } from 'lib/selections'
import { modelingMachine } from 'machines/modelingMachine'

Expand Down Expand Up @@ -135,7 +136,7 @@ export const modelingMachineConfig: CommandSetConfig<
// },
distance: {
inputType: 'kcl',
defaultValue: '5 + 7',
defaultValue: KCL_DEFAULT_LENGTH,
required: true,
},
},
Expand Down
2 changes: 2 additions & 0 deletions src/lib/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,3 +42,5 @@ export const RELEVANT_FILE_TYPES = [
] as const
/** The default name for a tutorial project */
export const ONBOARDING_PROJECT_NAME = 'Tutorial Project $nn'
/** The default KCL length expression */
export const KCL_DEFAULT_LENGTH = `5`

0 comments on commit 1b87886

Please sign in to comment.