Skip to content

feat: add Playwright page objects#327

Draft
draedful wants to merge 1 commit into
mainfrom
codex/add-playwright-page-objects
Draft

feat: add Playwright page objects#327
draedful wants to merge 1 commit 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 entry point with page objects and a DOM graph instance bridge for canvas-rendered graphs.

New Features:

  • Expose a new @gravity-ui/graph/playwright subpath exporting page objects for graphs, blocks, connections, and camera interactions.
  • Introduce Playwright-based end-to-end tests that consume the published page object entry point.

Bug Fixes:

  • Ensure graph instances are registered on their root DOM elements, cleaned up on detach, and moved when reattached to a new root.

Enhancements:

  • Add a namespaced DOM symbol bridge for accessing graph instances from external tools while maintaining backward compatibility with the legacy key.
  • Update Jest configuration to ignore built artifacts and add Playwright testing documentation links in both English and Russian READMEs.

Build:

  • Expose the Playwright entry point in exports and typesVersions, and declare @playwright/test as an optional peer dependency.

Tests:

  • Add Jest coverage for the graph DOM instance bridge behavior and Playwright E2E tests for the public page objects.

@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.

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