shift focs

This commit is contained in:
Ryan Rosello
2024-07-29 19:30:42 +10:00
parent bc77507af8
commit 6a4834989a
2 changed files with 51 additions and 18 deletions

View File

@ -157,7 +157,7 @@ jobs:
id: retry id: retry
if: always() if: always()
run: | run: |
yarn playwright test --project="Google Chrome" --workers=1 --grep=@focus --repeat-each=13 yarn playwright test --project="Google Chrome" --workers=1 --grep=@focus --repeat-each=10
# if [[ ! -f "test-results/.last-run.json" ]]; then # if [[ ! -f "test-results/.last-run.json" ]]; then
# # if no last run artifact, than run plawright normally # # if no last run artifact, than run plawright normally
# echo "run playwright normally" # echo "run playwright normally"
@ -277,7 +277,7 @@ jobs:
id: retry id: retry
if: always() if: always()
run: | run: |
yarn playwright test --project="webkit" --workers=1 --grep=@focus --repeat-each=13 yarn playwright test --project="webkit" --workers=1 --grep=@focus --repeat-each=10
# if [[ ! -f "test-results/.last-run.json" ]]; then # if [[ ! -f "test-results/.last-run.json" ]]; then
# # if no last run artifact, than run plawright normally # # if no last run artifact, than run plawright normally
# echo "run playwright normally" # echo "run playwright normally"

View File

@ -119,22 +119,45 @@ async function doBasicSketch(page: Page, openPanes: string[]) {
// click on "Start Sketch" button // click on "Start Sketch" button
await u.clearCommandLogs() await u.clearCommandLogs()
await page.getByRole('button', { name: 'Start Sketch' }).click() await page.getByRole('button', { name: 'Start Sketch' }).click()
await page.waitForTimeout(100) // await page.waitForTimeout(100)
await page.waitForTimeout(1_000)
// select a plane // select a plane
await page.mouse.click(700, 200) // const r = await page.locator('canvas[style*=display]').screenshot()
// console.log('>>>> R',r.length)
// await page.mouse.click(700, 200)
// const r2 = await page.locator('canvas[style*=display]').screenshot()
// console.log('>>>> R',r2.length)
// await page.waitForTimeout(1_000)
await clickAndWaitForCanvas(page.mouse.click(700, 200))
async function clickAndWaitForCanvas(action: any) {
let og = await page.locator('canvas[style*=display]').screenshot()
await action
let r = await page.locator('canvas[style*=display]').screenshot()
while (og.length === r.length) {
console.log('>>>> OG and R', og.length, r.length)
await page.waitForTimeout(300)
r = await page.locator('canvas[style*=display]').screenshot()
}
}
if (openPanes.includes('code')) { if (openPanes.includes('code')) {
await expect(u.codeLocator).toHaveText( await expect(u.codeLocator).toHaveText(
`const sketch001 = startSketchOn('XZ')` `const sketch001 = startSketchOn('XZ')`
) )
} }
await u.closeDebugPanel() // await u.closeDebugPanel()
await page.waitForTimeout(1000) // TODO detect animation ending, or disable animation // await page.waitForTimeout(1000) // TODO detect animation ending, or disable animation
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 clickAndWaitForCanvas(page.mouse.click(startXPx + PUR * 10, 500 - PUR * 10))
if (openPanes.includes('code')) { if (openPanes.includes('code')) {
await expect(u.codeLocator) await expect(u.codeLocator)
.toHaveText(`const sketch001 = startSketchOn('XZ') .toHaveText(`const sketch001 = startSketchOn('XZ')
@ -143,8 +166,11 @@ async function doBasicSketch(page: Page, openPanes: string[]) {
await page.waitForTimeout(500) await page.waitForTimeout(500)
} }
await page.mouse.click(startXPx + PUR * 20, 500 - PUR * 10) await clickAndWaitForCanvas(page.mouse.click(startXPx + PUR * 20, 500 - PUR * 10))
await page.waitForTimeout(500)
// await page.waitForTimeout(500)
// await page.waitForTimeout(1_000)
if (openPanes.includes('code')) { if (openPanes.includes('code')) {
await expect(u.codeLocator) await expect(u.codeLocator)
@ -155,7 +181,10 @@ async function doBasicSketch(page: Page, openPanes: string[]) {
await page.waitForTimeout(500) await page.waitForTimeout(500)
} }
await page.mouse.click(startXPx + PUR * 20, 500 - PUR * 20) await clickAndWaitForCanvas(page.mouse.click(startXPx + PUR * 20, 500 - PUR * 20))
// await page.waitForTimeout(1_000)
if (openPanes.includes('code')) { if (openPanes.includes('code')) {
await expect(u.codeLocator) await expect(u.codeLocator)
.toHaveText(`const sketch001 = startSketchOn('XZ') .toHaveText(`const sketch001 = startSketchOn('XZ')
@ -165,7 +194,10 @@ async function doBasicSketch(page: Page, openPanes: string[]) {
} else { } else {
await page.waitForTimeout(500) await page.waitForTimeout(500)
} }
await page.mouse.click(startXPx, 500 - PUR * 20)
await clickAndWaitForCanvas(page.mouse.click(startXPx, 500 - PUR * 20))
if (openPanes.includes('code')) { if (openPanes.includes('code')) {
await expect(u.codeLocator) await expect(u.codeLocator)
.toHaveText(`const sketch001 = startSketchOn('XZ') .toHaveText(`const sketch001 = startSketchOn('XZ')
@ -176,8 +208,7 @@ async function doBasicSketch(page: Page, openPanes: string[]) {
} }
// deselect line tool // deselect line tool
await page.getByRole('button', { name: 'Line', exact: true }).click() await clickAndWaitForCanvas(page.getByRole('button', { name: 'Line', exact: true }).click())
await page.waitForTimeout(500)
const line1 = await u.getSegmentBodyCoords(`[data-overlay-index="${0}"]`, 0) const line1 = await u.getSegmentBodyCoords(`[data-overlay-index="${0}"]`, 0)
if (openPanes.includes('code')) { if (openPanes.includes('code')) {
@ -187,8 +218,9 @@ async function doBasicSketch(page: Page, openPanes: string[]) {
).toBeLessThan(3) ).toBeLessThan(3)
} }
// click between first two clicks to get center of the line // click between first two clicks to get center of the line
await page.mouse.click(startXPx + PUR * 15, 500 - PUR * 10) await clickAndWaitForCanvas(page.mouse.click(startXPx + PUR * 15, 500 - PUR * 10))
await page.waitForTimeout(100)
if (openPanes.includes('code')) { if (openPanes.includes('code')) {
expect(await u.getGreatestPixDiff(line1, TEST_COLORS.BLUE)).toBeLessThan(3) expect(await u.getGreatestPixDiff(line1, TEST_COLORS.BLUE)).toBeLessThan(3)
await expect(await u.getGreatestPixDiff(line1, [0, 0, 255])).toBeLessThan(3) await expect(await u.getGreatestPixDiff(line1, [0, 0, 255])).toBeLessThan(3)
@ -197,7 +229,8 @@ async function doBasicSketch(page: Page, openPanes: string[]) {
// hold down shift // hold down shift
await page.keyboard.down('Shift') await page.keyboard.down('Shift')
// click between the latest two clicks to get center of the line // click between the latest two clicks to get center of the line
await page.mouse.click(startXPx + PUR * 10, 500 - PUR * 20) await clickAndWaitForCanvas(page.mouse.click(startXPx + PUR * 10, 500 - PUR * 20))
// selected two lines therefore there should be two cursors // selected two lines therefore there should be two cursors
if (openPanes.includes('code')) { if (openPanes.includes('code')) {
@ -1005,7 +1038,7 @@ test.describe('Editor tests', () => {
// Make sure there are two diagnostics // Make sure there are two diagnostics
await expect(page.locator('.cm-lint-marker-error')).toHaveCount(2) await expect(page.locator('.cm-lint-marker-error')).toHaveCount(2)
}) })
test('if your kcl gets an error from the engine it is inlined', { tag: '@focus' }, async ({ test('if your kcl gets an error from the engine it is inlined', async ({
page, page,
}) => { }) => {
const u = await getUtils(page) const u = await getUtils(page)
@ -2507,7 +2540,7 @@ test.describe('Onboarding tests', () => {
test.describe('Testing selections', () => { test.describe('Testing selections', () => {
test.setTimeout(90_000) test.setTimeout(90_000)
test('Selections work on fresh and edited sketch', async ({ page }) => { test('Selections work on fresh and edited sketch', { tag: '@focus' }, async ({ page }) => {
// tests mapping works on fresh sketch and edited sketch // tests mapping works on fresh sketch and edited sketch
// tests using hovers which is the same as selections, because if // tests using hovers which is the same as selections, because if
// source ranges are wrong, hovers won't work // source ranges are wrong, hovers won't work