diff options
| author | amankumarsingh77 <amankumarsingh7702@gmail.com> | 2026-07-28 20:32:57 +0530 |
|---|---|---|
| committer | Aman Kumar <145339995+amankumarsingh77@users.noreply.github.com> | 2026-08-02 19:12:46 +0530 |
| commit | 34e5cfdcbe29bbb5f2f46ba54eb67903abd9274d (patch) | |
| tree | f7b421652a7664d97362a308f4a1288cce2ef5b0 /test/cdp | |
| parent | 91a2fdeff796bae8e87d9146e2d540550f54dd74 (diff) | |
refactor(test): strip comment noise
Removes suite banners, section dividers, and test-id markers that restate
the test names. Keeps one-line notes for the deleted-binary fixture order,
the never-arriving event consumer, the absent-vs-undefined key distinction,
the unexpected-method-echo rationale, and the real-browser teardown and
Local State flush quirks.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Diffstat (limited to 'test/cdp')
| -rw-r--r-- | test/cdp/session-call-test.ts | 26 |
1 files changed, 6 insertions, 20 deletions
diff --git a/test/cdp/session-call-test.ts b/test/cdp/session-call-test.ts index 7b1386b..6a14e17 100644 --- a/test/cdp/session-call-test.ts +++ b/test/cdp/session-call-test.ts @@ -14,13 +14,6 @@ type RecordedCall = { readonly opts: RequestOpts | undefined; }; -/** - * A stub transport: no socket, no browser. `request()` looks up a canned - * Result by method name (defaulting to `ok({})` for methods the test doesn't - * care about — e.g. the six domain-enable calls switchTo fires as a side - * effect). Every call is recorded so tests can assert on exactly what the - * session sent, including the sessionId routing and the timeoutMs option. - */ const makeStubTransport = ( responses: Record<string, Result<unknown, CdpError>> = {}, ): { transport: CdpTransport; calls: RecordedCall[] } => { @@ -32,8 +25,7 @@ const makeStubTransport = ( calls.push({ method, params, opts }); return Promise.resolve(responses[method] ?? ok({})); }, - // No real events ever arrive; the session's background consumer just - // awaits forever. No timers involved, so it doesn't keep the process alive. + // No real events ever arrive, so the session's background consumer awaits forever — with no timers involved, it does not keep the process alive. events: (): AsyncIterable<CdpEvent> => (async function* (): AsyncGenerator<CdpEvent> { await new Promise<never>(() => {}); })(), @@ -84,8 +76,6 @@ describe("CdpSession.call / callOnTarget / callBrowser", () => { const r = await session.call("Target.getTargetInfo", {}); assert.equal(r.success, false); if (!r.success) { - // Must stay "timeout" — decodeResult must never run on a failed - // transport call and relabel it "invalid_response". assert.equal(r.error.kind, "timeout"); assert.equal(r.error.message, "socket dead"); } @@ -97,24 +87,21 @@ describe("CdpSession.call / callOnTarget / callBrowser", () => { }); const session = createCdpSession(transport); - // Establish an internal sessionId distinct from both null and the - // explicit sid used below, via the public switchTo() — no attachFirstPage - // bookkeeping required. const switched = await session.switchTo("target-1"); assert.equal(switched.success, true); - calls.length = 0; // discard switchTo's own requests (activate/attach/enable*6) + calls.length = 0; await session.call("Page.navigate", { url: "http://example.com" }); await session.callOnTarget("Page.navigate", { url: "http://example.com" }, "explicit-sid"); await session.callBrowser("Target.getTargets"); const navigateCalls = calls.filter((c) => c.method === "Page.navigate"); - assert.equal(navigateCalls[0]?.opts?.sessionId, "session-xyz"); // call() uses the active session - assert.equal(navigateCalls[1]?.opts?.sessionId, "explicit-sid"); // callOnTarget() uses the given sid, not the active one + assert.equal(navigateCalls[0]?.opts?.sessionId, "session-xyz"); + assert.equal(navigateCalls[1]?.opts?.sessionId, "explicit-sid"); const browserCall = calls.find((c) => c.method === "Target.getTargets"); - assert.equal(browserCall?.opts?.sessionId, null); // callBrowser() forces null even though a session is active + assert.equal(browserCall?.opts?.sessionId, null); }); test("opts.timeoutMs reaches the transport only when provided (exactOptionalPropertyTypes)", async () => { @@ -127,8 +114,7 @@ describe("CdpSession.call / callOnTarget / callBrowser", () => { await session.callBrowser("Target.getTargets"); const withoutTimeout = calls.filter((c) => c.method === "Target.getTargets")[1]; - // The key itself must be absent, not present-with-undefined — that's the - // distinction exactOptionalPropertyTypes exists to enforce at the call site. + // The key must be absent, not present-with-undefined — the distinction exactOptionalPropertyTypes enforces at the call site. assert.equal(withoutTimeout?.opts && "timeoutMs" in withoutTimeout.opts, false); }); }); |
