-
Notifications
You must be signed in to change notification settings - Fork 1.3k
[test]: add tests for top level snapshot functions #1471
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[test]: add tests for top level snapshot functions #1471
Conversation
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No issues found across 2 files
Greptile SummaryExported three internal helper functions (
Confidence Score: 5/5
Important Files Changed
Sequence DiagramsequenceDiagram
participant Test as Test Suite
participant Capture as capture.ts
participant DomTree as domTree module
participant A11yTree as a11yTree module
participant Page as Page Mock
participant Session as CDP Session
Note over Test,Session: buildFrameContext Test
Test->>Page: asProtocolFrameTree()
Page-->>Test: frameTree structure
Test->>Capture: buildFrameContext(page)
Capture->>Page: mainFrameId(), listAllFrameIds()
Capture-->>Test: FrameContext with parentByFrame map
Note over Test,Session: buildSessionIndexes Test
Test->>Capture: buildSessionIndexes(page, frames, pierce)
loop for each unique session
Capture->>Page: getSessionForFrame(frameId)
Page-->>Capture: session
Capture->>DomTree: buildSessionDomIndex(session, pierce)
DomTree-->>Capture: SessionDomIndex
end
Capture-->>Test: Map<sessionId, SessionDomIndex>
Note over Test,Session: collectPerFrameMaps Test
Test->>Capture: collectPerFrameMaps(page, context, sessionToIndex, options, pierce)
loop for each frame
Capture->>Page: getSessionForFrame(frameId)
Capture->>Session: send("DOM.getFrameOwner", {frameId})
Session-->>Capture: {backendNodeId}
Capture->>A11yTree: a11yForFrame(session, frameId, options)
A11yTree-->>Capture: {outline, urlMap}
end
Capture-->>Test: {perFrameMaps, perFrameOutlines}
Note over Test,Session: captureHybridSnapshot Test (scoped)
Test->>Capture: captureHybridSnapshot(page, {focusSelector})
Capture->>DomTree: domMapsForSession(session, frameId, pierce)
DomTree-->>Capture: {tagNameMap, xpathMap, scrollableMap}
Capture->>A11yTree: a11yForFrame(session, frameId, options)
A11yTree-->>Capture: {outline, urlMap, scopeApplied: true}
Capture-->>Test: HybridSnapshot (early return)
Note over Test,Session: captureHybridSnapshot Test (full)
Test->>Capture: captureHybridSnapshot(page)
Capture->>Capture: buildFrameContext(page)
Capture->>Capture: buildSessionIndexes(page, frames, pierce)
Capture->>Capture: collectPerFrameMaps(...)
Capture->>Capture: mergeFramesIntoSnapshot(...)
Capture-->>Test: Complete HybridSnapshot with all frames
|
why
captureHybridSnapshot()and the functions that it depends onwhat changed
buildFrameContext(),buildSessionIndexes(), andcollectPerFrameMaps()so their orchestration logic can be tested directlysnapshot-capture-orchestration.test.ts, which holds tests for the following helpers:buildFrameContext()buildSessionIndexes()buildSessionDomIndex()call (deduping DOM.getDocument)collectPerFrameMaps()captureHybridSnapshot()test plan
Summary by cubic
Added unit tests for snapshot orchestration to improve coverage and prevent regressions. Exported buildFrameContext, buildSessionIndexes, and collectPerFrameMaps so their logic can be tested directly.
Written for commit 4785c7f. Summary will update automatically on new commits.