test: unflake various tests (#32014)

This commit is contained in:
Dmitry Gozman 2024-08-05 08:29:13 -07:00 committed by GitHub
parent 613ccb8d5b
commit 5c9ce6b9d9
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
5 changed files with 15 additions and 12 deletions

View file

@ -177,6 +177,7 @@ export class TestServer {
this._csp.clear();
this._extraHeaders.clear();
this._gzipRoutes.clear();
this._server.closeAllConnections();
const error = new Error('Static Server has been reset');
for (const subscriber of this._requestSubscribers.values())
subscriber[rejectSymbol].call(null, error);

View file

@ -260,8 +260,8 @@ it('should report google.com frame with headed', async ({ browserType, server })
it('ElementHandle.boundingBox() should work', async function({ page, browser, server }) {
await page.goto(server.PREFIX + '/dynamic-oopif.html');
await page.$eval('iframe', iframe => {
iframe.style.width = '500px';
iframe.style.height = '500px';
iframe.style.width = '520px';
iframe.style.height = '520px';
iframe.style.marginLeft = '42px';
iframe.style.marginTop = '17px';
});

View file

@ -80,7 +80,9 @@ it('should scroll display:contents into view', async ({ page, browserName, brows
`);
const div = await page.$('#target');
await div.scrollIntoViewIfNeeded();
expect(await page.$eval('#container', e => e.scrollTop)).toBe(350);
const scrollTop = await page.$eval('#container', e => e.scrollTop);
// On Android the value is not exact due to various scale conversions.
expect(Math.abs(scrollTop - 350)).toBeLessThan(1);
});
it('should work for visibility:hidden element', async ({ page }) => {

View file

@ -87,7 +87,9 @@ test('should work with a custom check', async ({ page, server }) => {
}
});
test('should work with locator.hover()', async ({ page, server }) => {
test('should work with locator.hover()', async ({ page, server, headless }) => {
test.skip(!headless, 'Stray hovers in headed mode');
await page.goto(server.PREFIX + '/input/handle-locator.html');
await page.addLocatorHandler(page.getByText('This interstitial covers the button'), async () => {

View file

@ -21,13 +21,15 @@ test.describe.configure({ mode: 'parallel', retries });
test('should show screenshots', async ({ runUITest }) => {
const { page } = await runUITest({
'a.test.ts': `
import { test } from '@playwright/test';
import { test, expect } from '@playwright/test';
test('test 1', async ({ page }) => {
await page.setContent('<div style="background: red; width: 100%; height: 100%"></div>');
await expect(page.locator('body')).toBeVisible();
await page.waitForTimeout(1000);
});
test('test 2', async ({ page }) => {
await page.setContent('<div style="background: blue; width: 100%; height: 100%"></div>');
await page.setContent('<div style="background: blue; width: 100%; height: 100%">hello</div>');
await expect(page.locator('body')).toHaveText('hello');
await page.waitForTimeout(1000);
});
`,
@ -36,14 +38,10 @@ test('should show screenshots', async ({ runUITest }) => {
await expect(page.getByTestId('status-line')).toHaveText('2/2 passed (100%)');
await page.getByText('test 1', { exact: true }).click();
await expect(
page.locator('.CodeMirror .source-line-running'),
).toContainText(`test('test 1', async ({ page }) => {`);
await expect(page.getByTestId('actions-tree')).toContainText('expect.toBeVisible');
await expect(page.locator('.film-strip-frame').first()).toBeVisible();
await page.getByText('test 2', { exact: true }).click();
await expect(
page.locator('.CodeMirror .source-line-running'),
).toContainText(`await page.waitForTimeout(1000);`);
await expect(page.getByTestId('actions-tree')).toContainText('expect.toHaveText');
await expect(page.locator('.film-strip-frame').first()).toBeVisible();
});