Skip to content

Commit

Permalink
test: failing dblclick test
Browse files Browse the repository at this point in the history
  • Loading branch information
OrKoN committed Jan 28, 2025
1 parent d940776 commit 3dab944
Show file tree
Hide file tree
Showing 2 changed files with 156 additions and 0 deletions.
76 changes: 76 additions & 0 deletions tests/input/__snapshots__/test_input.ambr
Original file line number Diff line number Diff line change
Expand Up @@ -951,6 +951,82 @@
'type': 'success',
})
# ---
# name: test_input_performActionsEmitsDblClicks
dict({
'result': dict({
'type': 'array',
'value': list([
dict({
'type': 'object',
'value': list([
list([
'event',
dict({
'type': 'string',
'value': 'dblclick',
}),
]),
list([
'button',
dict({
'type': 'number',
'value': 0,
}),
]),
list([
'buttons',
dict({
'type': 'number',
'value': 0,
}),
]),
list([
'clickCount',
dict({
'type': 'number',
'value': 2,
}),
]),
]),
}),
dict({
'type': 'object',
'value': list([
list([
'event',
dict({
'type': 'string',
'value': 'dblclick',
}),
]),
list([
'button',
dict({
'type': 'number',
'value': 0,
}),
]),
list([
'buttons',
dict({
'type': 'number',
'value': 0,
}),
]),
list([
'clickCount',
dict({
'type': 'number',
'value': 2,
}),
]),
]),
}),
]),
}),
'type': 'success',
})
# ---
# name: test_input_performActionsEmitsDragging
dict({
'result': dict({
Expand Down
80 changes: 80 additions & 0 deletions tests/input/test_input.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,21 @@
</script>
"""

DBL_CLICK_SCRIPT = """
<div style="height: 2000px; width: 10px"></div>
<script>
var allEvents = [];
window.addEventListener("dblclick", (event) => {
allEvents.push({
event: "dblclick",
button: event.button,
buttons: event.buttons,
clickCount: event.detail,
});
});
</script>
"""

DRAG_SCRIPT = """
<div
style="height: 100px; width: 100px; background-color: red"
Expand Down Expand Up @@ -210,6 +225,71 @@ async def test_input_performActionsEmitsKeyboardEvents(websocket, context_id,
assert result == snapshot(exclude=props("realm"))


@pytest.mark.asyncio
async def test_input_performActionsEmitsDblClicks(websocket, context_id,
html, activate_main_tab,
query_selector,
snapshot):
await goto_url(websocket, context_id, html(DBL_CLICK_SCRIPT))
await activate_main_tab()
await reset_mouse(websocket, context_id)

target_element = await query_selector('div')

await execute_command(
websocket, {
"method": "input.performActions",
"params": {
"context": context_id,
"actions": [
{"type":"pointer",
"id":"__puppeteer_mouse",
"actions":[
{"type":"pointerMove",
"x": 0,
"y": 0,
"origin": {
"type": "element",
"element": target_element
}},
{"type":"pointerDown","button":0},
{"type":"pointerUp","button":0},
{"type":"pointerDown","button":0},
{"type":"pointerUp","button":0}
]}]
}
})

await execute_command(
websocket, {
"method": "input.performActions",
"params": {
"context": context_id,
"actions": [
{"type":"pointer",
"id":"__puppeteer_mouse",
"actions":[
{"type":"pointerMove",
"x": 0,
"y": 0,
"origin": {
"type": "element",
"element": target_element
}},
{"type":"pointerDown","button":0},
{"type":"pointerUp","button":0},
{"type":"pointerDown","button":0},
{"type":"pointerUp","button":0}
]}]
}
})

result = await get_events(websocket, context_id)

assert result == snapshot(exclude=props("realm"))



@pytest.mark.asyncio
async def test_input_performActionsEmitsDragging(websocket, context_id, html,
query_selector, snapshot,
Expand Down

0 comments on commit 3dab944

Please sign in to comment.