test: unflake contextmenu recorder test (#31749)

This commit is contained in:
Max Schmitt 2024-07-26 12:43:05 +02:00 committed by GitHub
parent b214941a01
commit 6988194c97
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 34 additions and 15 deletions

View File

@ -230,6 +230,9 @@ class RecordActionTool implements RecorderTool {
// So we check the hovered element instead, and if it is a range input, we skip click handling
if (isRangeInput(this._hoveredElement))
return;
// Right clicks are handled by 'contextmenu' event if its auxclick
if (event.button === 2 && event.type === 'auxclick')
return;
if (this._shouldIgnoreMouseEvent(event))
return;
if (this._actionInProgress(event))

View File

@ -559,7 +559,7 @@ await page.GetByLabel("Coun\\"try").ClickAsync();`);
]);
});
test('should consume contextmenu events, despite a custom context menu', async ({ page, openRecorder }) => {
test('should consume contextmenu events, despite a custom context menu', async ({ page, openRecorder, browserName, platform }) => {
const recorder = await openRecorder();
await recorder.setContentAndWait(`
@ -597,20 +597,36 @@ await page.GetByLabel("Coun\\"try").ClickAsync();`);
recorder.trustedClick({ button: 'right' }),
]);
expect(message.text()).toBe('right-clicked');
expect(await page.evaluate('log')).toEqual([
// hover
'button: pointermove',
'button: mousemove',
// trusted right click
'button: pointerup',
'button: pointermove',
'button: mousemove',
'button: pointerdown',
'button: mousedown',
'button: contextmenu',
'menu: pointerup',
'menu: mouseup'
]);
if (browserName === 'chromium' && platform === 'win32') {
expect(await page.evaluate('log')).toEqual([
// hover
'button: pointermove',
'button: mousemove',
// trusted right click
'button: pointermove',
'button: mousemove',
'button: pointerdown',
'button: mousedown',
'button: pointerup',
'button: mouseup',
'button: contextmenu',
]);
} else {
expect(await page.evaluate('log')).toEqual([
// hover
'button: pointermove',
'button: mousemove',
// trusted right click
'button: pointerup',
'button: pointermove',
'button: mousemove',
'button: pointerdown',
'button: mousedown',
'button: contextmenu',
'menu: pointerup',
'menu: mouseup',
]);
}
});
test('should assert value', async ({ openRecorder }) => {