Skip to content

Commit 2ec0c86

Browse files
committed
cherry-pick(#33124): test: unflake ff debugger test
1 parent 8ef381f commit 2ec0c86

File tree

2 files changed

+15
-4
lines changed

2 files changed

+15
-4
lines changed

tests/library/inspector/inspectorTest.ts

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -171,6 +171,13 @@ export class Recorder {
171171
return this.page.locator('x-pw-tooltip').textContent();
172172
}
173173

174+
async waitForHighlightNoTooltip(action: () => Promise<void>): Promise<string> {
175+
await this.page.$$eval('x-pw-highlight', els => els.forEach(e => e.remove()));
176+
await action();
177+
await this.page.locator('x-pw-highlight').waitFor();
178+
return '';
179+
}
180+
174181
async waitForActionPerformed(): Promise<{ hovered: string | null, active: string | null }> {
175182
let callback;
176183
const listener = async msg => {
@@ -185,8 +192,8 @@ export class Recorder {
185192
return new Promise(f => callback = f);
186193
}
187194

188-
async hoverOverElement(selector: string, options?: { position?: { x: number, y: number }}): Promise<string> {
189-
return this.waitForHighlight(async () => {
195+
async hoverOverElement(selector: string, options?: { position?: { x: number, y: number }, omitTooltip?: boolean }): Promise<string> {
196+
return (options?.omitTooltip ? this.waitForHighlightNoTooltip : this.waitForHighlight).call(this, async () => {
190197
const box = await this.page.locator(selector).first().boundingBox();
191198
const offset = options?.position || { x: box.width / 2, y: box.height / 2 };
192199
await this.page.mouse.move(box.x + offset.x, box.y + offset.y);

tests/library/inspector/pause.spec.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
*/
1616

1717
import type { Page } from 'playwright-core';
18-
import { test as it, expect } from './inspectorTest';
18+
import { test as it, expect, Recorder } from './inspectorTest';
1919
import { waitForTestLog } from '../../config/utils';
2020

2121

@@ -491,7 +491,11 @@ it.describe('pause', () => {
491491
await expect(recorderPage.getByRole('combobox', { name: 'Source chooser' })).toHaveValue(/pause\.spec\.ts/);
492492
await expect(recorderPage.locator('.source-line-paused')).toHaveText(/await page\.pause\(\)/);
493493
await recorderPage.getByRole('button', { name: 'Record' }).click();
494-
await page.locator('body').click();
494+
495+
const recorder = new Recorder(page, recorderPage);
496+
await recorder.hoverOverElement('body', { omitTooltip: true });
497+
await recorder.trustedClick();
498+
495499
await expect(recorderPage.getByRole('combobox', { name: 'Source chooser' })).toHaveValue('javascript');
496500
await expect(recorderPage.locator('.cm-wrapper')).toContainText(`await page.locator('body').click();`);
497501
await recorderPage.getByRole('button', { name: 'Resume' }).click();

0 commit comments

Comments
 (0)