test: unflake "should highlight locators with custom testId" (#19236)

This commit is contained in:
Dmitry Gozman 2022-12-02 17:32:29 -08:00 committed by GitHub
parent 291ad6e618
commit c547416e24
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -415,29 +415,19 @@ it.describe('pause', () => {
});
it('should highlight locators with custom testId', async ({ page, playwright, recorderPageGetter }) => {
await page.setContent('<div id=target1>click me</div><div data-custom-id=foo id=target2>and me</div>');
await page.setContent('<div data-custom-id=foo id=target>and me</div>');
const scriptPromise = (async () => {
await page.pause();
await page.getByText('click me').click();
playwright.selectors.setTestIdAttribute('data-custom-id');
await page.getByTestId('foo').click();
})();
const recorderPage = await recorderPageGetter();
const box1Promise = waitForTestLog<Box>(page, 'Highlight box for test: ');
await recorderPage.click('[title="Step over (F10)"]');
const div1Box1 = roundBox(await page.locator('x-pw-highlight').boundingBox());
const div1Box2 = roundBox(await page.locator('#target1').boundingBox());
expect(div1Box1).toEqual(div1Box2);
await recorderPage.click('[title="Step over (F10)"]');
let div2Box1: Box;
await expect.poll(async () => {
div2Box1 = await page.locator('x-pw-highlight').boundingBox();
return div2Box1;
}).toBeTruthy();
div2Box1 = roundBox(div2Box1);
const div2Box2 = roundBox(await page.locator('#target2').boundingBox());
expect(div2Box1).toEqual(div2Box2);
const box2 = roundBox(await page.locator('#target').boundingBox());
const box1 = roundBox(await box1Promise);
expect(box1).toEqual(box2);
await recorderPage.click('[title="Resume (F8)"]');
await scriptPromise;