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