-
Notifications
You must be signed in to change notification settings - Fork 1.2k
test: add CDP method tests #1141
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
base: v3
Are you sure you want to change the base?
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.
Greptile Overview
Summary
Adds 28 comprehensive test cases for v3 CDP-based methods across 4 test files covering coordinate-based clicks, locator interactions, content extraction, and form control methods.
Key additions:
frame-get-location-and-click.spec.ts
: Tests CDP DOM geometry queries and coordinate-based clickinglocator-input-methods.spec.ts
: 7 tests covering fill, type, hover, visibility detection, and checkbox statelocator-content-methods.spec.ts
: 10 tests for textContent, innerText, innerHTML, and inputValue with edge cases for hidden content, empty elements, and script/style tagslocator-select-option.spec.ts
: 10 tests for single/multiple selection, optgroups, change events, and edge cases
All tests use data URIs for self-contained HTML fixtures and properly verify CDP protocol interactions. The tests directly validate the v3 implementation against expected behavior.
Confidence Score: 5/5
- This PR is safe to merge with no concerns - adds only test files with no production code changes
- All changes are isolated to test files that validate existing v3 CDP implementations. Tests are well-structured with proper setup/teardown, use self-contained data URI fixtures, and comprehensively cover edge cases. No production code is modified.
- No files require special attention
Important Files Changed
File Analysis
Filename | Score | Overview |
---|---|---|
packages/core/lib/v3/tests/frame-get-location-and-click.spec.ts | 5/5 | Tests coordinate-based clicking via CDP, covering Frame.getLocationForSelector and Page.click with proper state verification. |
packages/core/lib/v3/tests/locator-input-methods.spec.ts | 5/5 | Comprehensive tests for Locator input methods (fill, type, hover, isVisible, isChecked) with proper edge case coverage. |
packages/core/lib/v3/tests/locator-content-methods.spec.ts | 5/5 | Well-structured tests for content extraction methods (textContent, innerText, innerHTML, inputValue) with comprehensive edge cases. |
packages/core/lib/v3/tests/locator-select-option.spec.ts | 5/5 | Thorough tests for selectOption covering single/multiple selection, labels vs values, optgroups, and edge cases like empty values and disabled options. |
Sequence Diagram
sequenceDiagram
participant Test as Test Suite
participant V3 as V3 Instance
participant Page as CDP Page
participant Frame as CDP Frame
participant Locator as CDP Locator
participant Browser as Chrome/CDP
Test->>V3: new V3(config)
Test->>V3: init()
V3->>Page: create page
Note over Test,Browser: Coordinate-based Click Test
Test->>Page: goto(data:text/html,...)
Test->>Page: mainFrame()
Page->>Frame: getLocationForSelector("#btn")
Frame->>Browser: DOM.querySelector
Frame->>Browser: DOM.getBoxModel
Browser-->>Frame: {x, y, width, height}
Frame-->>Test: element bounds
Test->>Page: click(cx, cy)
Page->>Browser: Input.dispatchMouseEvent
Note over Test,Browser: Locator Input Tests
Test->>Frame: locator("#input")
Frame-->>Test: Locator instance
Test->>Locator: fill("text")
Locator->>Browser: Runtime.callFunctionOn
Browser-->>Locator: value set
Test->>Locator: inputValue()
Locator->>Browser: Runtime.callFunctionOn
Browser-->>Test: "text"
Note over Test,Browser: Content Extraction Tests
Test->>Locator: textContent()
Locator->>Browser: Runtime.callFunctionOn
Browser-->>Test: raw text
Test->>Locator: innerText()
Locator->>Browser: Runtime.callFunctionOn
Browser-->>Test: visible text
Note over Test,Browser: Select Option Tests
Test->>Locator: selectOption(["val1", "val2"])
Locator->>Browser: Runtime.callFunctionOn
Browser-->>Locator: selected values
Locator->>Browser: dispatchEvent("change")
Test->>V3: close()
4 files reviewed, no comments
Remove code coverage directories from .gitignore
Removed 'c8' from devDependencies.
Removed test and test:coverage scripts from package.json
Added prettier and eslint as dependencies.
1. frame-get-location-and-click.spec.ts (1 test)
Frame.getLocationForSelector()
to get element bounding boxPage.click()
coordinate-based clicking via CDP Input events2. locator-input-methods.spec.ts (7 tests)
3. locator-content-methods.spec.ts (10 tests)
4. locator-select-option.spec.ts (10 tests)