cherry-pick(#33124): test: unflake ff debugger test
This commit is contained in:
parent
8ef381fc5f
commit
2ec0c86b93
|
@ -171,6 +171,13 @@ export class Recorder {
|
||||||
return this.page.locator('x-pw-tooltip').textContent();
|
return this.page.locator('x-pw-tooltip').textContent();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async waitForHighlightNoTooltip(action: () => Promise<void>): Promise<string> {
|
||||||
|
await this.page.$$eval('x-pw-highlight', els => els.forEach(e => e.remove()));
|
||||||
|
await action();
|
||||||
|
await this.page.locator('x-pw-highlight').waitFor();
|
||||||
|
return '';
|
||||||
|
}
|
||||||
|
|
||||||
async waitForActionPerformed(): Promise<{ hovered: string | null, active: string | null }> {
|
async waitForActionPerformed(): Promise<{ hovered: string | null, active: string | null }> {
|
||||||
let callback;
|
let callback;
|
||||||
const listener = async msg => {
|
const listener = async msg => {
|
||||||
|
@ -185,8 +192,8 @@ export class Recorder {
|
||||||
return new Promise(f => callback = f);
|
return new Promise(f => callback = f);
|
||||||
}
|
}
|
||||||
|
|
||||||
async hoverOverElement(selector: string, options?: { position?: { x: number, y: number }}): Promise<string> {
|
async hoverOverElement(selector: string, options?: { position?: { x: number, y: number }, omitTooltip?: boolean }): Promise<string> {
|
||||||
return this.waitForHighlight(async () => {
|
return (options?.omitTooltip ? this.waitForHighlightNoTooltip : this.waitForHighlight).call(this, async () => {
|
||||||
const box = await this.page.locator(selector).first().boundingBox();
|
const box = await this.page.locator(selector).first().boundingBox();
|
||||||
const offset = options?.position || { x: box.width / 2, y: box.height / 2 };
|
const offset = options?.position || { x: box.width / 2, y: box.height / 2 };
|
||||||
await this.page.mouse.move(box.x + offset.x, box.y + offset.y);
|
await this.page.mouse.move(box.x + offset.x, box.y + offset.y);
|
||||||
|
|
|
@ -15,7 +15,7 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import type { Page } from 'playwright-core';
|
import type { Page } from 'playwright-core';
|
||||||
import { test as it, expect } from './inspectorTest';
|
import { test as it, expect, Recorder } from './inspectorTest';
|
||||||
import { waitForTestLog } from '../../config/utils';
|
import { waitForTestLog } from '../../config/utils';
|
||||||
|
|
||||||
|
|
||||||
|
@ -491,7 +491,11 @@ it.describe('pause', () => {
|
||||||
await expect(recorderPage.getByRole('combobox', { name: 'Source chooser' })).toHaveValue(/pause\.spec\.ts/);
|
await expect(recorderPage.getByRole('combobox', { name: 'Source chooser' })).toHaveValue(/pause\.spec\.ts/);
|
||||||
await expect(recorderPage.locator('.source-line-paused')).toHaveText(/await page\.pause\(\)/);
|
await expect(recorderPage.locator('.source-line-paused')).toHaveText(/await page\.pause\(\)/);
|
||||||
await recorderPage.getByRole('button', { name: 'Record' }).click();
|
await recorderPage.getByRole('button', { name: 'Record' }).click();
|
||||||
await page.locator('body').click();
|
|
||||||
|
const recorder = new Recorder(page, recorderPage);
|
||||||
|
await recorder.hoverOverElement('body', { omitTooltip: true });
|
||||||
|
await recorder.trustedClick();
|
||||||
|
|
||||||
await expect(recorderPage.getByRole('combobox', { name: 'Source chooser' })).toHaveValue('javascript');
|
await expect(recorderPage.getByRole('combobox', { name: 'Source chooser' })).toHaveValue('javascript');
|
||||||
await expect(recorderPage.locator('.cm-wrapper')).toContainText(`await page.locator('body').click();`);
|
await expect(recorderPage.locator('.cm-wrapper')).toContainText(`await page.locator('body').click();`);
|
||||||
await recorderPage.getByRole('button', { name: 'Resume' }).click();
|
await recorderPage.getByRole('button', { name: 'Resume' }).click();
|
||||||
|
|
Loading…
Reference in New Issue