Skip to content

Commit

Permalink
test: add e2e
Browse files Browse the repository at this point in the history
  • Loading branch information
OrKoN committed Jan 27, 2025
1 parent 9f90bbb commit 53c7ba5
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/bidiMapper/modules/session/EventManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -247,12 +247,12 @@ export class EventManager extends EventEmitter<EventManagerEventsMap> {
if (userContextIds.length) {
const userContexts = await this.#userContextStorage.getUserContexts();
const knownUserContextIds = new Set(
userContexts.map(({userContext}) => userContext),
userContexts.map((userContext) => userContext.userContext),
);
for (const userContextId of userContextIds) {
if (knownUserContextIds.has(userContextId)) {
if (!knownUserContextIds.has(userContextId)) {
throw new NoSuchUserContextException(
`User context ${userContextId} not found.`,
`User context ${userContextId} not found`,
);
}
}
Expand Down
30 changes: 30 additions & 0 deletions tests/session/test_subscription.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,36 @@ async def test_subscribeWithoutContext_subscribesToEventsInAllContexts(
assert resp["params"]["context"] == context_id


@pytest.mark.asyncio
async def test_subscribeUserContext(
websocket, context_id, html):
result = await execute_command(
websocket, {
"method": "session.subscribe",
"params": {
"events": ["browsingContext.load"],
"userContexts": ["default"]
}
})
assert result == {'subscription': ANY_UUID}

# Navigate to some page.
await send_JSON_command(
websocket, {
"method": "browsingContext.navigate",
"params": {
"url": html("<h2>test</h2>"),
"wait": "complete",
"context": context_id
}
})

# Wait for `browsingContext.load` event.
resp = await read_JSON_message(websocket)
assert resp["method"] == "browsingContext.load"
assert resp["params"]["context"] == context_id


@pytest.mark.asyncio
async def test_subscribeWithContext_subscribesToEventsInGivenContext(
websocket, context_id, html):
Expand Down

0 comments on commit 53c7ba5

Please sign in to comment.