Skip to content

feat: add Playwright page objects - #327

Merged
draedful merged 4 commits into
mainfrom
codex/add-playwright-page-objects
Aug 24, 2026
Merged

draedful merged 4 commits into
mainfrom
codex/add-playwright-page-objects

Conversation

@draedful

@draedful draedful commented Jul 17, 2026

Copy link
Copy Markdown
Collaborator

Summary

  • add a public @gravity-ui/graph/playwright subpath with page objects for graphs, blocks, connections, and camera controls
  • resolve graph instances from an application-owned Playwright locator through a namespaced DOM bridge, including cleanup on detach and root changes
  • keep @playwright/test optional for regular library consumers
  • add usage documentation and end-to-end coverage that imports the published subpath

Why

Graph entities are rendered on canvas, so application tests cannot reliably locate blocks and connections through DOM selectors. The new page objects provide stable, typed interactions in world coordinates without requiring applications to expose a global window.graph.

Developer impact

Existing package entry points remain unchanged. Consumers that use the new subpath should install @playwright/test as a development dependency and construct GraphPO with a locator containing exactly one graph.

Validation

  • tsc -p tsconfig.publish.json --noEmit
  • ESLint for the new page objects and bridge changes
  • npm test — 31 suites passed, 341 tests passed
  • npm run test:e2e -- e2e/tests/playwright-page-object.spec.ts — 2 tests passed
  • npm run build:publish

Summary by Sourcery

Add a public Playwright testing API for stable, typed interaction with canvas-rendered graphs.

New Features:

  • Expose typed Playwright page objects for interacting with canvas-rendered graphs, blocks, connections, and camera controls through a public package subpath.

Bug Fixes:

  • Add reliable graph-instance discovery with cleanup when graphs detach or move between root elements.

Enhancements:

  • Support world-coordinate interactions, state inspection, browser-side graph evaluation, and portable mouse gestures through the new page-object API.

Build:

  • Add the published Playwright runtime entry point and preserve optional Playwright support for regular library consumers.

CI:

  • Add an installed-package consumer contract covering public types, bundling, and end-to-end Playwright usage.

Documentation:

  • Document Playwright page-object setup and usage in English and Russian project documentation.

Tests:

  • Add unit coverage for graph DOM bridge lifecycle and end-to-end coverage for block, connection, and camera page objects.

Chores:

  • Adjust published type checking and Jest exclusions to validate the new package boundary.

@sourcery-ai

sourcery-ai Bot commented Jul 17, 2026

Copy link
Copy Markdown

Reviewer's Guide

Adds a new public Playwright testing subpath with graph-focused page objects, introduces a namespaced DOM bridge for resolving graph instances from application locators, wires the bridge into Graph attach/detach lifecycle, and documents and tests the new API.

File-Level Changes

Change Details Files
Introduce Playwright page objects and public testing entry point for interacting with canvas-rendered graphs, blocks, connections, and camera.
  • Add GraphPO as the main page object that discovers a single Graph instance via DOM symbols, exposes evaluation helpers, world-coordinate interactions, and camera access.
  • Add GraphBlockPO, GraphConnectionPO, and GraphCameraPO for block geometry and selection, connection curve interactions, and camera state/controls.
  • Define shared Playwright types for points, rectangles, mouse modifiers/buttons, and interaction options.
  • Export all Playwright page objects and types from a new src/playwright/index.ts and wire them into the package exports.
src/playwright/GraphPO.ts
src/playwright/GraphBlockPO.ts
src/playwright/GraphConnectionPO.ts
src/playwright/GraphCameraPO.ts
src/playwright/types.ts
src/playwright/index.ts
package.json
Implement a namespaced DOM bridge for graph instances and integrate it with Graph lifecycle, including migration from the legacy symbol.
  • Add graphInstance utilities that set and clear Graph instances on host DOM elements under both a new namespaced symbol and the legacy "graph" symbol.
  • Update Graph.attach to move the bridge when the root changes and to register via setGraphInstance instead of directly writing to Symbol.for("graph").
  • Update Graph.stop to clear the bridge on full detach.
  • Add Jest tests that verify registration on attach, cleanup on detach, and bridge movement when the root element changes.
src/utils/graphInstance.ts
src/graph.ts
src/graph.test.ts
Expose the Playwright subpath publicly, make @playwright/test an optional peer dependency, and adjust Jest configuration to ignore built artifacts.
  • Extend package.json exports and types to include the ./playwright subpath pointing to built Playwright index files.
  • Declare @playwright/test as a peer dependency with peerDependenciesMeta optional true so regular consumers are not forced to install it.
  • Update Jest config to ignore the build directory in testPathIgnorePatterns.
package.json
jest.config.ts
Add documentation and end-to-end tests that exercise the new Playwright page objects via the published subpath.
  • Document Playwright testing setup, GraphPO usage, page object capabilities, and evaluate() escape hatch in docs/testing/playwright.md, and link it from both README files.
  • Add an e2e Playwright spec that imports GraphPO from the new subpath, initializes a sample graph via an existing harness, and validates block, connection, and camera interactions.
docs/testing/playwright.md
README.md
README-ru.md
e2e/tests/playwright-page-object.spec.ts

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@gravity-ui-bot

Copy link
Copy Markdown
Contributor

Preview is ready.

@draedful
draedful force-pushed the codex/add-playwright-page-objects branch from 738b2a2 to eef4b2e Compare August 21, 2026 16:12
@draedful
draedful marked this pull request as ready for review August 24, 2026 18:33
@draedful
draedful requested a review from Antamansid as a code owner August 24, 2026 18:33

@sourcery-ai sourcery-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry @draedful, your pull request is larger than the review limit of 150000 diff characters

@draedful

Copy link
Copy Markdown
Collaborator Author

@sourcery-ai review

@sourcery-ai

sourcery-ai Bot commented Aug 24, 2026

Copy link
Copy Markdown

Sorry @draedful, your pull request is larger than the review limit of 150000 diff characters

@draedful
draedful merged commit 31a9797 into main Aug 24, 2026
7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants