diff --git a/.github/workflows/playwright.yml b/.github/workflows/playwright.yml index 77a82bbfe..f1023a4f7 100644 --- a/.github/workflows/playwright.yml +++ b/.github/workflows/playwright.yml @@ -157,7 +157,7 @@ jobs: id: retry if: always() 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 no last run artifact, than run plawright normally # echo "run playwright normally" @@ -277,7 +277,7 @@ jobs: id: retry if: always() 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 no last run artifact, than run plawright normally # echo "run playwright normally" diff --git a/e2e/playwright/flow-tests.spec.ts b/e2e/playwright/flow-tests.spec.ts index 77b531e49..dfa1cb78a 100644 --- a/e2e/playwright/flow-tests.spec.ts +++ b/e2e/playwright/flow-tests.spec.ts @@ -119,22 +119,45 @@ async function doBasicSketch(page: Page, openPanes: string[]) { // click on "Start Sketch" button await u.clearCommandLogs() await page.getByRole('button', { name: 'Start Sketch' }).click() - await page.waitForTimeout(100) + // await page.waitForTimeout(100) + await page.waitForTimeout(1_000) // 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')) { await expect(u.codeLocator).toHaveText( `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 - 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')) { await expect(u.codeLocator) .toHaveText(`const sketch001 = startSketchOn('XZ') @@ -143,8 +166,11 @@ async function doBasicSketch(page: Page, openPanes: string[]) { await page.waitForTimeout(500) } - await page.mouse.click(startXPx + PUR * 20, 500 - PUR * 10) - await page.waitForTimeout(500) + await clickAndWaitForCanvas(page.mouse.click(startXPx + PUR * 20, 500 - PUR * 10)) + + // await page.waitForTimeout(500) + // await page.waitForTimeout(1_000) + if (openPanes.includes('code')) { await expect(u.codeLocator) @@ -155,7 +181,10 @@ async function doBasicSketch(page: Page, openPanes: string[]) { 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')) { await expect(u.codeLocator) .toHaveText(`const sketch001 = startSketchOn('XZ') @@ -165,7 +194,10 @@ async function doBasicSketch(page: Page, openPanes: string[]) { } else { 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')) { await expect(u.codeLocator) .toHaveText(`const sketch001 = startSketchOn('XZ') @@ -176,8 +208,7 @@ async function doBasicSketch(page: Page, openPanes: string[]) { } // deselect line tool - await page.getByRole('button', { name: 'Line', exact: true }).click() - await page.waitForTimeout(500) + await clickAndWaitForCanvas(page.getByRole('button', { name: 'Line', exact: true }).click()) const line1 = await u.getSegmentBodyCoords(`[data-overlay-index="${0}"]`, 0) if (openPanes.includes('code')) { @@ -187,8 +218,9 @@ async function doBasicSketch(page: Page, openPanes: string[]) { ).toBeLessThan(3) } // click between first two clicks to get center of the line - await page.mouse.click(startXPx + PUR * 15, 500 - PUR * 10) - await page.waitForTimeout(100) + await clickAndWaitForCanvas(page.mouse.click(startXPx + PUR * 15, 500 - PUR * 10)) + + if (openPanes.includes('code')) { expect(await u.getGreatestPixDiff(line1, TEST_COLORS.BLUE)).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 await page.keyboard.down('Shift') // 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 if (openPanes.includes('code')) { @@ -1005,7 +1038,7 @@ test.describe('Editor tests', () => { // Make sure there are two diagnostics 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, }) => { const u = await getUtils(page) @@ -2507,7 +2540,7 @@ test.describe('Onboarding tests', () => { test.describe('Testing selections', () => { 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 using hovers which is the same as selections, because if // source ranges are wrong, hovers won't work