Fix up more tests with setting annotations
This commit is contained in:
@ -2,7 +2,7 @@ import { test, expect } from './zoo-test'
|
||||
import {
|
||||
orRunWhenFullSuiteEnabled,
|
||||
getUtils,
|
||||
executorInputPath,
|
||||
kclSamplesInputPath,
|
||||
} from './test-utils'
|
||||
import { join } from 'path'
|
||||
import { bracket } from 'lib/exampleKcl'
|
||||
@ -250,11 +250,11 @@ test(
|
||||
])
|
||||
await Promise.all([
|
||||
fsp.copyFile(
|
||||
executorInputPath('router-template-slate.kcl'),
|
||||
kclSamplesInputPath(['ball-bearing', 'main.kcl']),
|
||||
join(routerTemplateDir, 'main.kcl')
|
||||
),
|
||||
fsp.copyFile(
|
||||
executorInputPath('focusrite_scarlett_mounting_braket.kcl'),
|
||||
kclSamplesInputPath(['flange', 'main.kcl']),
|
||||
join(bracketDir, 'main.kcl')
|
||||
),
|
||||
])
|
||||
|
@ -4,6 +4,7 @@ import {
|
||||
getUtils,
|
||||
executorInputPath,
|
||||
getPlaywrightDownloadDir,
|
||||
kclSamplesInputPath,
|
||||
} from './test-utils'
|
||||
import fsp from 'fs/promises'
|
||||
|
||||
@ -20,11 +21,11 @@ test(
|
||||
await Promise.all([fsp.mkdir(bracketDir, { recursive: true })])
|
||||
await Promise.all([
|
||||
fsp.copyFile(
|
||||
executorInputPath('router-template-slate.kcl'),
|
||||
kclSamplesInputPath(['flange', 'main.kcl']),
|
||||
path.join(bracketDir, 'other.kcl')
|
||||
),
|
||||
fsp.copyFile(
|
||||
executorInputPath('focusrite_scarlett_mounting_braket.kcl'),
|
||||
kclSamplesInputPath(['ball-bearing', 'main.kcl']),
|
||||
path.join(bracketDir, 'main.kcl')
|
||||
),
|
||||
])
|
||||
|
@ -310,7 +310,9 @@ export async function expectPixelColor(
|
||||
.toBeTruthy()
|
||||
.catch((cause) => {
|
||||
throw new Error(
|
||||
`ExpectPixelColor: expecting ${colour} got ${finalValue}`,
|
||||
`ExpectPixelColor: point ${JSON.stringify(
|
||||
coords
|
||||
)} was expecting ${colour} but got ${finalValue}`,
|
||||
{ cause }
|
||||
)
|
||||
})
|
||||
|
@ -1,5 +1,5 @@
|
||||
import { test, expect } from './zoo-test'
|
||||
import { executorInputPath } from './test-utils'
|
||||
import { executorInputPath, kclSamplesInputPath } from './test-utils'
|
||||
import { join } from 'path'
|
||||
import fsp from 'fs/promises'
|
||||
|
||||
@ -11,7 +11,7 @@ test(
|
||||
const bracketDir = join(dir, 'bracket')
|
||||
await fsp.mkdir(bracketDir, { recursive: true })
|
||||
await fsp.copyFile(
|
||||
executorInputPath('focusrite_scarlett_mounting_braket.kcl'),
|
||||
kclSamplesInputPath(['flange', 'main.kcl']),
|
||||
join(bracketDir, 'main.kcl')
|
||||
)
|
||||
})
|
||||
@ -51,7 +51,7 @@ test(
|
||||
const bracketDir = join(dir, 'bracket')
|
||||
await fsp.mkdir(bracketDir, { recursive: true })
|
||||
await fsp.copyFile(
|
||||
executorInputPath('focusrite_scarlett_mounting_braket.kcl'),
|
||||
kclSamplesInputPath(['flange', 'main.kcl']),
|
||||
join(bracketDir, 'main.kcl')
|
||||
)
|
||||
})
|
||||
|
@ -8,6 +8,7 @@ import {
|
||||
createProject,
|
||||
getPlaywrightDownloadDir,
|
||||
orRunWhenFullSuiteEnabled,
|
||||
kclSamplesInputPath,
|
||||
} from './test-utils'
|
||||
import fsp from 'fs/promises'
|
||||
import fs from 'fs'
|
||||
@ -86,7 +87,7 @@ test(
|
||||
const bracketDir = path.join(dir, 'bracket')
|
||||
await fsp.mkdir(bracketDir, { recursive: true })
|
||||
await fsp.copyFile(
|
||||
executorInputPath('focusrite_scarlett_mounting_braket.kcl'),
|
||||
kclSamplesInputPath(['flange', 'main.kcl']),
|
||||
path.join(bracketDir, 'main.kcl')
|
||||
)
|
||||
})
|
||||
@ -123,7 +124,7 @@ test(
|
||||
const bracketDir = path.join(dir, 'bracket')
|
||||
await fsp.mkdir(bracketDir, { recursive: true })
|
||||
await fsp.copyFile(
|
||||
executorInputPath('focusrite_scarlett_mounting_braket.kcl'),
|
||||
kclSamplesInputPath(['flange', 'main.kcl']),
|
||||
path.join(bracketDir, 'main.kcl')
|
||||
)
|
||||
const errorDir = path.join(dir, 'broken-code')
|
||||
@ -212,7 +213,7 @@ test(
|
||||
const bracketDir = path.join(dir, 'bracket')
|
||||
await fsp.mkdir(bracketDir, { recursive: true })
|
||||
await fsp.copyFile(
|
||||
executorInputPath('focusrite_scarlett_mounting_braket.kcl'),
|
||||
kclSamplesInputPath(['flange', 'main.kcl']),
|
||||
path.join(bracketDir, 'main.kcl')
|
||||
)
|
||||
const emptyDir = path.join(dir, 'empty')
|
||||
@ -289,7 +290,7 @@ test(
|
||||
const bracketDir = path.join(dir, 'bracket')
|
||||
await fsp.mkdir(bracketDir, { recursive: true })
|
||||
await fsp.copyFile(
|
||||
executorInputPath('focusrite_scarlett_mounting_braket.kcl'),
|
||||
kclSamplesInputPath(['flange', 'main.kcl']),
|
||||
path.join(bracketDir, 'main.kcl')
|
||||
)
|
||||
|
||||
@ -355,7 +356,7 @@ test(
|
||||
const bracketDir = path.join(dir, 'bracket')
|
||||
await fsp.mkdir(bracketDir, { recursive: true })
|
||||
await fsp.copyFile(
|
||||
executorInputPath('focusrite_scarlett_mounting_braket.kcl'),
|
||||
kclSamplesInputPath(['flange', 'main.kcl']),
|
||||
path.join(bracketDir, 'main.kcl')
|
||||
)
|
||||
await fsp.copyFile(
|
||||
@ -474,7 +475,7 @@ test.describe('Can export from electron app', () => {
|
||||
const bracketDir = path.join(dir, 'bracket')
|
||||
await fsp.mkdir(bracketDir, { recursive: true })
|
||||
await fsp.copyFile(
|
||||
executorInputPath('focusrite_scarlett_mounting_braket.kcl'),
|
||||
kclSamplesInputPath(['flange', 'main.kcl']),
|
||||
path.join(bracketDir, 'main.kcl')
|
||||
)
|
||||
})
|
||||
|
@ -4,7 +4,7 @@ import path from 'path'
|
||||
import * as fsp from 'fs/promises'
|
||||
import {
|
||||
getUtils,
|
||||
executorInputPath,
|
||||
kclSamplesInputPath,
|
||||
TEST_COLORS,
|
||||
TestColor,
|
||||
orRunWhenFullSuiteEnabled,
|
||||
@ -582,7 +582,7 @@ extrude002 = extrude(profile002, length = 150)
|
||||
const bracketDir = path.join(dir, 'bracket')
|
||||
await fsp.mkdir(bracketDir, { recursive: true })
|
||||
await fsp.copyFile(
|
||||
executorInputPath('focusrite_scarlett_mounting_braket.kcl'),
|
||||
kclSamplesInputPath(['flange', 'main.kcl']),
|
||||
path.join(bracketDir, 'main.kcl')
|
||||
)
|
||||
})
|
||||
@ -632,12 +632,13 @@ extrude002 = extrude(profile002, length = 150)
|
||||
|
||||
await test.step(`Load an empty file`, async () => {
|
||||
await page.addInitScript(async () => {
|
||||
localStorage.setItem('persistCode', '')
|
||||
localStorage.setItem('persistCode', '@settings(defaultLengthUnit = in)')
|
||||
})
|
||||
await page.setBodyDimensions({ width: 1200, height: 500 })
|
||||
await homePage.goToModelingScene()
|
||||
await u.waitForPageLoad()
|
||||
await u.closeKclCodePanel()
|
||||
await page.waitForTimeout(20)
|
||||
})
|
||||
|
||||
await test.step(`Zoom out until you can't see the default planes`, async () => {
|
||||
@ -646,13 +647,14 @@ extrude002 = extrude(profile002, length = 150)
|
||||
timeout: 5000,
|
||||
message: 'Plane color is visible',
|
||||
})
|
||||
.toBeLessThanOrEqual(15)
|
||||
.toBeLessThanOrEqual(20)
|
||||
|
||||
let maxZoomOuts = 10
|
||||
let middlePixelIsBackgroundColor =
|
||||
(await middlePixelIsColor(bgColor)) < 10
|
||||
while (!middlePixelIsBackgroundColor && maxZoomOuts > 0) {
|
||||
await page.keyboard.down('Control')
|
||||
await page.waitForTimeout(20)
|
||||
await page.mouse.move(600, 460)
|
||||
await page.mouse.down({ button: 'right' })
|
||||
await page.mouse.move(600, 50, { steps: 20 })
|
||||
@ -660,7 +662,7 @@ extrude002 = extrude(profile002, length = 150)
|
||||
await page.keyboard.up('Control')
|
||||
await page.waitForTimeout(100)
|
||||
maxZoomOuts--
|
||||
middlePixelIsBackgroundColor = (await middlePixelIsColor(bgColor)) < 10
|
||||
middlePixelIsBackgroundColor = (await middlePixelIsColor(bgColor)) < 15
|
||||
}
|
||||
|
||||
expect(middlePixelIsBackgroundColor, {
|
||||
@ -678,13 +680,12 @@ extrude002 = extrude(profile002, length = 150)
|
||||
homePage,
|
||||
scene,
|
||||
toolbar,
|
||||
viewport,
|
||||
}) => {
|
||||
await context.folderSetupFn(async (dir) => {
|
||||
const legoDir = path.join(dir, 'lego')
|
||||
await fsp.mkdir(legoDir, { recursive: true })
|
||||
await fsp.copyFile(
|
||||
executorInputPath('lego.kcl'),
|
||||
kclSamplesInputPath(['ball-bearing', 'main.kcl']),
|
||||
path.join(legoDir, 'main.kcl')
|
||||
)
|
||||
})
|
||||
@ -697,11 +698,8 @@ extrude002 = extrude(profile002, length = 150)
|
||||
await scene.loadingIndicator.waitFor({ state: 'detached' })
|
||||
})
|
||||
await test.step(`The part should start loading quickly, not waiting until execution is complete`, async () => {
|
||||
await scene.expectPixelColor(
|
||||
[143, 143, 143],
|
||||
{ x: (viewport?.width ?? 1200) / 2, y: (viewport?.height ?? 500) / 2 },
|
||||
15
|
||||
)
|
||||
// TODO: use the viewport size to pick the center point, but the `viewport` fixutre's values were wrong.
|
||||
await scene.expectPixelColor([143, 143, 143], { x: 500, y: 250 }, 15)
|
||||
})
|
||||
})
|
||||
|
||||
|
@ -113,7 +113,8 @@ test.describe('Sketch tests', { tag: ['@skipWin'] }, () => {
|
||||
await page.addInitScript(async () => {
|
||||
localStorage.setItem(
|
||||
'persistCode',
|
||||
`sketch001 = startSketchOn(XZ)
|
||||
`@settings(defaultLengthUnit = in)
|
||||
sketch001 = startSketchOn(XZ)
|
||||
|> startProfileAt([2.61, -4.01], %)
|
||||
|> xLine(length = 8.73)
|
||||
|> tangentialArcTo([8.33, -1.31], %)`
|
||||
@ -159,7 +160,10 @@ test.describe('Sketch tests', { tag: ['@skipWin'] }, () => {
|
||||
await page.mouse.click(700, 200)
|
||||
|
||||
await expect.poll(u.normalisedEditorCode, { timeout: 1000 })
|
||||
.toBe(`sketch002 = startSketchOn(XZ)
|
||||
.toBe(`@settings(defaultLengthUnit = in)
|
||||
|
||||
|
||||
sketch002 = startSketchOn(XZ)
|
||||
sketch001 = startProfileAt([12.34, -12.34], sketch002)
|
||||
|> yLine(length = 12.34)
|
||||
|
||||
@ -789,7 +793,8 @@ sketch001 = startProfileAt([12.34, -12.34], sketch002)
|
||||
200
|
||||
)
|
||||
|
||||
let codeStr = 'sketch001 = startSketchOn(XY)'
|
||||
let codeStr =
|
||||
'@settings(defaultLengthUnit = in)sketch001 = startSketchOn(XY)'
|
||||
|
||||
await page.mouse.click(center.x, viewportSize.height * 0.55)
|
||||
await expect(u.codeLocator).toHaveText(codeStr)
|
||||
|
@ -1007,6 +1007,10 @@ export function executorInputPath(fileName: string): string {
|
||||
return path.join('rust', 'kcl-lib', 'e2e', 'executor', 'inputs', fileName)
|
||||
}
|
||||
|
||||
export function kclSamplesInputPath(samplePathSegments: string[]): string {
|
||||
return path.join('public', 'kcl-samples', ...samplePathSegments)
|
||||
}
|
||||
|
||||
export async function doAndWaitForImageDiff(
|
||||
page: Page,
|
||||
fn: () => Promise<unknown>,
|
||||
|
@ -8,6 +8,7 @@ import {
|
||||
tomlToSettings,
|
||||
TEST_COLORS,
|
||||
orRunWhenFullSuiteEnabled,
|
||||
kclSamplesInputPath,
|
||||
} from './test-utils'
|
||||
import { SettingsLevel } from 'lib/settings/settingsTypes'
|
||||
import { SETTINGS_FILE_NAME, PROJECT_SETTINGS_FILE_NAME } from 'lib/constants'
|
||||
@ -271,7 +272,7 @@ test.describe('Testing settings', () => {
|
||||
const bracketDir = join(dir, projectName)
|
||||
await fsp.mkdir(bracketDir, { recursive: true })
|
||||
await fsp.copyFile(
|
||||
executorInputPath('focusrite_scarlett_mounting_braket.kcl'),
|
||||
kclSamplesInputPath(['flange', 'main.kcl']),
|
||||
join(bracketDir, 'main.kcl')
|
||||
)
|
||||
}
|
||||
|
Reference in New Issue
Block a user