Compare commits

...

2 Commits

Author SHA1 Message Date
a5426abd29 fix unrelated test 2024-06-05 15:14:50 +10:00
bb69f21b40 cache playwright browsers 2024-06-05 14:47:51 +10:00
3 changed files with 36 additions and 29 deletions

View File

@ -46,6 +46,14 @@ jobs:
- uses: KittyCAD/action-install-cli@main - uses: KittyCAD/action-install-cli@main
- name: Install dependencies - name: Install dependencies
run: yarn run: yarn
- name: Cache Playwright Browsers
uses: actions/cache@v3
with:
path: |
~/.cache/ms-playwright
key: ${{ runner.os }}-playwright-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.os }}-playwright-
- name: Install Playwright Browsers - name: Install Playwright Browsers
run: yarn playwright install --with-deps run: yarn playwright install --with-deps
- name: Download Wasm Cache - name: Download Wasm Cache
@ -143,6 +151,14 @@ jobs:
cache: 'yarn' cache: 'yarn'
- name: Install dependencies - name: Install dependencies
run: yarn run: yarn
- name: Cache Playwright Browsers
uses: actions/cache@v3
with:
path: |
~/.cache/ms-playwright
key: ${{ runner.os }}-playwright-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.os }}-playwright-
- name: Install Playwright Browsers - name: Install Playwright Browsers
run: yarn playwright install --with-deps run: yarn playwright install --with-deps
- name: Download Wasm Cache - name: Download Wasm Cache

View File

@ -93,7 +93,7 @@ test('Basic sketch', async ({ page }) => {
// select a plane // select a plane
await page.mouse.click(700, 200) await page.mouse.click(700, 200)
await expect(page.locator('.cm-content')).toHaveText( await expect(u.codeLocator).toHaveText(
`const sketch001 = startSketchOn('XZ')` `const sketch001 = startSketchOn('XZ')`
) )
await u.closeDebugPanel() await u.closeDebugPanel()
@ -102,29 +102,25 @@ test('Basic sketch', async ({ page }) => {
const startXPx = 600 const startXPx = 600
await page.mouse.click(startXPx + PUR * 10, 500 - PUR * 10) await page.mouse.click(startXPx + PUR * 10, 500 - PUR * 10)
await expect(page.locator('.cm-content')) await expect(u.codeLocator).toHaveText(`const sketch001 = startSketchOn('XZ')
.toHaveText(`const sketch001 = startSketchOn('XZ')
|> startProfileAt(${commonPoints.startAt}, %)`) |> startProfileAt(${commonPoints.startAt}, %)`)
await page.waitForTimeout(100) await page.waitForTimeout(100)
await page.mouse.click(startXPx + PUR * 20, 500 - PUR * 10) await page.mouse.click(startXPx + PUR * 20, 500 - PUR * 10)
await page.waitForTimeout(100) await page.waitForTimeout(100)
await expect(page.locator('.cm-content')) await expect(u.codeLocator).toHaveText(`const sketch001 = startSketchOn('XZ')
.toHaveText(`const sketch001 = startSketchOn('XZ')
|> startProfileAt(${commonPoints.startAt}, %) |> startProfileAt(${commonPoints.startAt}, %)
|> line([${commonPoints.num1}, 0], %)`) |> line([${commonPoints.num1}, 0], %)`)
await page.mouse.click(startXPx + PUR * 20, 500 - PUR * 20) await page.mouse.click(startXPx + PUR * 20, 500 - PUR * 20)
await expect(page.locator('.cm-content')) await expect(u.codeLocator).toHaveText(`const sketch001 = startSketchOn('XZ')
.toHaveText(`const sketch001 = startSketchOn('XZ')
|> startProfileAt(${commonPoints.startAt}, %) |> startProfileAt(${commonPoints.startAt}, %)
|> line([${commonPoints.num1}, 0], %) |> line([${commonPoints.num1}, 0], %)
|> line([0, ${commonPoints.num1}], %)`) |> line([0, ${commonPoints.num1}], %)`)
await page.waitForTimeout(100) await page.waitForTimeout(100)
await page.mouse.click(startXPx, 500 - PUR * 20) await page.mouse.click(startXPx, 500 - PUR * 20)
await expect(page.locator('.cm-content')) await expect(u.codeLocator).toHaveText(`const sketch001 = startSketchOn('XZ')
.toHaveText(`const sketch001 = startSketchOn('XZ')
|> startProfileAt(${commonPoints.startAt}, %) |> startProfileAt(${commonPoints.startAt}, %)
|> line([${commonPoints.num1}, 0], %) |> line([${commonPoints.num1}, 0], %)
|> line([0, ${commonPoints.num1}], %) |> line([0, ${commonPoints.num1}], %)
@ -154,8 +150,7 @@ test('Basic sketch', async ({ page }) => {
await page.getByRole('button', { name: 'Constrain' }).click() await page.getByRole('button', { name: 'Constrain' }).click()
await page.getByRole('button', { name: 'Equal Length' }).click() await page.getByRole('button', { name: 'Equal Length' }).click()
await expect(page.locator('.cm-content')) await expect(u.codeLocator).toHaveText(`const sketch001 = startSketchOn('XZ')
.toHaveText(`const sketch001 = startSketchOn('XZ')
|> startProfileAt(${commonPoints.startAt}, %) |> startProfileAt(${commonPoints.startAt}, %)
|> line([${commonPoints.num1}, 0], %, 'seg01') |> line([${commonPoints.num1}, 0], %, 'seg01')
|> line([0, ${commonPoints.num1}], %) |> line([0, ${commonPoints.num1}], %)
@ -1533,7 +1528,7 @@ test('Can add multiple sketches', async ({ page }) => {
await u.openDebugPanel() await u.openDebugPanel()
const center = { x: viewportSize.width / 2, y: viewportSize.height / 2 } const center = { x: viewportSize.width / 2, y: viewportSize.height / 2 }
const { toSU, click00r, expectCodeToBe } = getMovementUtils({ center, page }) const { toSU, click00r } = getMovementUtils({ center, page })
await expect( await expect(
page.getByRole('button', { name: 'Start Sketch' }) page.getByRole('button', { name: 'Start Sketch' })
@ -1550,25 +1545,25 @@ test('Can add multiple sketches', async ({ page }) => {
let codeStr = "const sketch001 = startSketchOn('XY')" let codeStr = "const sketch001 = startSketchOn('XY')"
await page.mouse.click(center.x, viewportSize.height * 0.55) await page.mouse.click(center.x, viewportSize.height * 0.55)
await expectCodeToBe(codeStr) await expect(u.codeLocator).toHaveText(codeStr)
await u.closeDebugPanel() await u.closeDebugPanel()
await page.waitForTimeout(500) // TODO detect animation ending, or disable animation await page.waitForTimeout(500) // TODO detect animation ending, or disable animation
await click00r(0, 0) await click00r(0, 0)
codeStr += ` |> startProfileAt(${toSU([0, 0])}, %)` codeStr += ` |> startProfileAt(${toSU([0, 0])}, %)`
await expectCodeToBe(codeStr) await expect(u.codeLocator).toHaveText(codeStr)
await click00r(50, 0) await click00r(50, 0)
codeStr += ` |> line(${toSU([50, 0])}, %)` codeStr += ` |> line(${toSU([50, 0])}, %)`
await expectCodeToBe(codeStr) await expect(u.codeLocator).toHaveText(codeStr)
await click00r(0, 50) await click00r(0, 50)
codeStr += ` |> line(${toSU([0, 50])}, %)` codeStr += ` |> line(${toSU([0, 50])}, %)`
await expectCodeToBe(codeStr) await expect(u.codeLocator).toHaveText(codeStr)
await click00r(-50, 0) await click00r(-50, 0)
codeStr += ` |> line(${toSU([-50, 0])}, %)` codeStr += ` |> line(${toSU([-50, 0])}, %)`
await expectCodeToBe(codeStr) await expect(u.codeLocator).toHaveText(codeStr)
// exit the sketch, reset relative clicker // exit the sketch, reset relative clicker
click00r(undefined, undefined) click00r(undefined, undefined)
@ -1586,24 +1581,24 @@ test('Can add multiple sketches', async ({ page }) => {
await page.mouse.click(center.x + 30, center.y) await page.mouse.click(center.x + 30, center.y)
await page.waitForTimeout(500) // TODO detect animation ending, or disable animation await page.waitForTimeout(500) // TODO detect animation ending, or disable animation
codeStr += "const sketch002 = startSketchOn('XY')" codeStr += "const sketch002 = startSketchOn('XY')"
await expectCodeToBe(codeStr) await expect(u.codeLocator).toHaveText(codeStr)
await u.closeDebugPanel() await u.closeDebugPanel()
await click00r(30, 0) await click00r(30, 0)
codeStr += ` |> startProfileAt(${toSU([30, 0])}, %)` codeStr += ` |> startProfileAt(${toSU([30, 0])}, %)`
await expectCodeToBe(codeStr) await expect(u.codeLocator).toHaveText(codeStr)
await click00r(30, 0) await click00r(30, 0)
codeStr += ` |> line(${toSU([30 - 0.1 /* imprecision */, 0])}, %)` codeStr += ` |> line(${toSU([30 + 0.1 /* imprecision */, 0])}, %)`
await expectCodeToBe(codeStr) await expect(u.codeLocator).toHaveText(codeStr)
await click00r(0, 30) await click00r(0, 30)
codeStr += ` |> line(${toSU([0, 30])}, %)` codeStr += ` |> line(${toSU([0, 30])}, %)`
await expectCodeToBe(codeStr) await expect(u.codeLocator).toHaveText(codeStr)
await click00r(-30, 0) await click00r(-30, 0)
codeStr += ` |> line(${toSU([-30 + 0.1, 0])}, %)` codeStr += ` |> line(${toSU([-30 + 0.1, 0])}, %)`
await expectCodeToBe(codeStr) await expect(u.codeLocator).toHaveText(codeStr)
click00r(undefined, undefined) click00r(undefined, undefined)
await u.openAndClearDebugPanel() await u.openAndClearDebugPanel()

View File

@ -162,12 +162,7 @@ export const getMovementUtils = (opts: any) => {
return ret.then(() => [last.x, last.y]) return ret.then(() => [last.x, last.y])
} }
const expectCodeToBe = async (str: string) => { return { toSU, click00r }
await expect(opts.page.locator('.cm-content')).toHaveText(str)
await opts.page.waitForTimeout(100)
}
return { toSU, click00r, expectCodeToBe }
} }
export async function getUtils(page: Page) { export async function getUtils(page: Page) {
@ -228,6 +223,7 @@ export async function getUtils(page: Page) {
.locator(locator) .locator(locator)
.boundingBox() .boundingBox()
.then((box) => ({ ...box, x: box?.x || 0, y: box?.y || 0 })), .then((box) => ({ ...box, x: box?.x || 0, y: box?.y || 0 })),
codeLocator: page.locator('.cm-content'),
doAndWaitForCmd: async ( doAndWaitForCmd: async (
fn: () => Promise<void>, fn: () => Promise<void>,
commandType: string, commandType: string,