test hard code timeout 100x

This commit is contained in:
Ryan Rosello
2024-07-30 20:11:50 +10:00
parent 6df8e97782
commit c4db8b7c9a
2 changed files with 73 additions and 115 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=25 yarn playwright test --project="Google Chrome" --workers=1 --grep=@focus --repeat-each=100
# 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=25 yarn playwright test --project="webkit" --workers=1 --grep=@focus --repeat-each=100
# 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,45 +119,23 @@ 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
// const r = await page.locator('canvas[style*=display]').screenshot() await page.mouse.click(700, 200)
// 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( await page.waitForTimeout(500)
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')
@ -166,12 +144,8 @@ async function doBasicSketch(page: Page, openPanes: string[]) {
await page.waitForTimeout(500) await page.waitForTimeout(500)
} }
await clickAndWaitForCanvas( await page.mouse.click(startXPx + PUR * 20, 500 - PUR * 10)
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)
@ -182,12 +156,7 @@ async function doBasicSketch(page: Page, openPanes: string[]) {
await page.waitForTimeout(500) await page.waitForTimeout(500)
} }
await clickAndWaitForCanvas( await page.mouse.click(startXPx + PUR * 20, 500 - PUR * 20)
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')
@ -197,9 +166,7 @@ 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')
@ -210,9 +177,8 @@ async function doBasicSketch(page: Page, openPanes: string[]) {
} }
// deselect line tool // deselect line tool
await clickAndWaitForCanvas( await page.getByRole('button', { name: 'Line', exact: true }).click()
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')) {
@ -222,10 +188,8 @@ 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 clickAndWaitForCanvas( await page.mouse.click(startXPx + PUR * 15, 500 - PUR * 10)
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)
@ -234,9 +198,7 @@ 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 clickAndWaitForCanvas( await page.mouse.click(startXPx + PUR * 10, 500 - PUR * 20)
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')) {
@ -256,7 +218,7 @@ async function doBasicSketch(page: Page, openPanes: string[]) {
} }
test.describe('Basic sketch', () => { test.describe('Basic sketch', () => {
test('code pane open at start', async ({ page }) => { test('code pane open at start', { tag: '@focus' }, async ({ page }) => {
await doBasicSketch(page, ['code']) await doBasicSketch(page, ['code'])
}) })
@ -1044,7 +1006,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)
@ -2441,73 +2403,69 @@ test.describe('Onboarding tests', () => {
await expect(u.codeLocator).toHaveText(bracketNoNewLines) await expect(u.codeLocator).toHaveText(bracketNoNewLines)
}) })
test( test('Avatar text updates depending on image load success', async ({
'Avatar text updates depending on image load success', page,
async ({ page }) => { }) => {
// Override beforeEach test setup // Override beforeEach test setup
await page.addInitScript( await page.addInitScript(
async ({ settingsKey, settings }) => { async ({ settingsKey, settings }) => {
localStorage.setItem(settingsKey, settings) localStorage.setItem(settingsKey, settings)
}, },
{ {
settingsKey: TEST_SETTINGS_KEY, settingsKey: TEST_SETTINGS_KEY,
settings: TOML.stringify({ settings: TOML.stringify({
settings: TEST_SETTINGS_ONBOARDING_USER_MENU, settings: TEST_SETTINGS_ONBOARDING_USER_MENU,
}), }),
} }
) )
const u = await getUtils(page) const u = await getUtils(page)
await page.setViewportSize({ width: 1200, height: 500 }) await page.setViewportSize({ width: 1200, height: 500 })
await u.waitForAuthSkipAppStart() await u.waitForAuthSkipAppStart()
await page.waitForURL('**/file/**', { waitUntil: 'domcontentloaded' }) await page.waitForURL('**/file/**', { waitUntil: 'domcontentloaded' })
// Test that the text in this step is correct // Test that the text in this step is correct
const avatarLocator = await page const avatarLocator = await page
.getByTestId('user-sidebar-toggle') .getByTestId('user-sidebar-toggle')
.locator('img') .locator('img')
const onboardingOverlayLocator = await page const onboardingOverlayLocator = await page
.getByTestId('onboarding-content') .getByTestId('onboarding-content')
.locator('div') .locator('div')
.nth(1) .nth(1)
// Expect the avatar to be visible and for the text to reference it // Expect the avatar to be visible and for the text to reference it
await expect(avatarLocator).toBeVisible() await expect(avatarLocator).toBeVisible()
await expect(onboardingOverlayLocator).toBeVisible() await expect(onboardingOverlayLocator).toBeVisible()
await expect(onboardingOverlayLocator).toContainText('your avatar') await expect(onboardingOverlayLocator).toContainText('your avatar')
// This is to force the avatar to 404. // This is to force the avatar to 404.
// For our test image (only triggers locally. on CI, it's Kurt's / // For our test image (only triggers locally. on CI, it's Kurt's /
// gravatar image ) // gravatar image )
await page.route('/cat.jpg', async (route) => { await page.route('/cat.jpg', async (route) => {
await route.fulfill({ await route.fulfill({
status: 404, status: 404,
contentType: 'text/plain', contentType: 'text/plain',
body: 'Not Found!', body: 'Not Found!',
})
}) })
})
// 404 the CI avatar image // 404 the CI avatar image
await page.route( await page.route('https://lh3.googleusercontent.com/**', async (route) => {
'https://lh3.googleusercontent.com/**', await route.fulfill({
async (route) => { status: 404,
await route.fulfill({ contentType: 'text/plain',
status: 404, body: 'Not Found!',
contentType: 'text/plain', })
body: 'Not Found!', })
})
}
)
await page.reload({ waitUntil: 'domcontentloaded' }) await page.reload({ waitUntil: 'domcontentloaded' })
// Now expect the text to be different // Now expect the text to be different
await expect(avatarLocator).not.toBeVisible() await expect(avatarLocator).not.toBeVisible()
await expect(onboardingOverlayLocator).toBeVisible() await expect(onboardingOverlayLocator).toBeVisible()
await expect(onboardingOverlayLocator).toContainText('the menu button') await expect(onboardingOverlayLocator).toContainText('the menu button')
} })
)
test("Avatar text doesn't mention avatar when no avatar", async ({ test("Avatar text doesn't mention avatar when no avatar", async ({
page, page,