Skip to content

test(e2e): type-check E2E tests under strict - #391

Open
draedful wants to merge 2 commits into
v2from
test/v2-e2e-strict
Open

draedful wants to merge 2 commits into
v2from
test/v2-e2e-strict

Conversation

@draedful

@draedful draedful commented Oct 16, 2026 •

Copy link
Copy Markdown
Collaborator

Part of #367 (epic #353).

Summary

Until now, apps/e2e/tsconfig.json excluded tests, ran with "strict": false and skipped library checks, so the E2E specs were never type-checked. This PR includes tests/**/*.ts and enables "strict": true and "skipLibCheck": false. That surfaced 102 diagnostics, all in the specs, and they are now fixed without weakening any assertion.

Diagnostics at the v2 head with the new config: groups/collapsible-group.spec.ts 62, port-delegation.spec.ts 22, camera/camera-mouse-emulation.spec.ts 10, minimap/minimap-styling.spec.ts 2, evented-area.spec.ts 2, connection/connection.spec.ts 2, camera/camera-block-scale-level.spec.ts 1, block/block-geometry-batching.spec.ts 1.

Changes (all under apps/e2e/**)

  • window.GraphModule: replaced (window as any).GraphModule with the typed global from global.d.ts. This also fixes the draggable layer-prop errors.
  • React globals: window.React and window.ReactDOM in global.d.ts are typed as typeof import("react") and typeof import("react-dom/client") instead of any.
  • requireValue(value, description): new helper in page-objects/requireValue.ts. It narrows possibly-missing page state on the Node side and fails with a clear message. Existing expect(...).not.toBeNull() / toBeDefined() checks are kept, and the x! / (x as any) reads that followed them now go through the helper.
  • Guards inside page.evaluate: that code is serialized and runs in the browser, so it uses inline throw guards for missing ports, connections and blocks instead.
  • Collapsible group state: read as TCollapsibleGroup via getGroupState<TCollapsibleGroup>(). Every group in these suites is created with component: CollapsibleGroup, and a comment records this.
  • Collapse event detail: the group-collapse-change detail type is derived from GraphEventsDefinitions, and the as any on that event subscription is removed.
  • Root element: checked with instanceof HTMLDivElement, which is what the Graph constructor and attach expect. Both E2E pages use <div id="root">.
  • port-delegation.spec.ts: passes TBlock-complete updateEntities data (id, is, name, width, height plus the new x/y), with the same values as before. Anchors and selection are not passed.
  • Small typings: the mouse event detail in camera-mouse-emulation.spec.ts, and "vertical" as const for bezierConnectionDirection.

Older any usages that still compile under strict (for example the __eventLog window globals and GraphEventProbe internals) are left as they are.

Verification

  • pnpm --filter @gravity-ui/graph-e2e exec tsc -p tsconfig.json --noEmit: 0 errors (was 102).
  • pnpm run typecheck, pnpm run test:type-configs, pnpm test, pnpm run lint: all pass.
  • node scripts/strict-diagnostics.mjs: passes; apps/e2e has 0 diagnostics and the baseline is unchanged.
  • pnpm run test:e2e: 197 passed.

🤖 Generated with Claude Code

Summary by Sourcery

Type-check the complete E2E test suite under strict TypeScript settings and eliminate the resulting type errors.

Enhancements:

  • Enable strict TypeScript checking for all E2E tests, including library type checking.
  • Replace untyped E2E access patterns with typed globals, event data, group state, DOM elements, and explicit missing-value guards.

Tests:

  • Resolve all diagnostics surfaced by strict-checking the E2E test suite without weakening its assertions.

Include apps/e2e/tests in the E2E tsconfig and enable strict mode and
library checks. Fix the 102 resulting diagnostics without weakening
assertions: use the typed window.GraphModule, read collapsible group
state as TCollapsibleGroup, narrow missing page state with a
requireValue helper or inline guards inside page.evaluate, pass complete
TBlock data, and type event details and the React globals.

Part of #367.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@draedful
draedful requested a review from Antamansid as a code owner October 16, 2026 14:00
@sourcery-ai

sourcery-ai Bot commented Oct 16, 2026 •

Copy link
Copy Markdown

Reviewer's Guide

The PR brings the E2E project under strict TypeScript checking by including all specs, disabling library-check skipping, and fixing the resulting diagnostics through typed globals, explicit null guards, domain-specific generics, and narrow test-focused typing updates while preserving existing assertions and behavior.

File-Level Changes

Change Details Files
Enabled strict, complete type-checking for the E2E test suite.
  • Included test specs in the E2E TypeScript project.
  • Enabled strict mode and library checking.
  • Resolved all 102 diagnostics without weakening test assertions.
apps/e2e/tsconfig.json
Replaced unsafe browser and page-state assumptions with typed access and explicit runtime guards.
  • Used the typed window.GraphModule global instead of any casts.
  • Added typed React and ReactDOM globals.
  • Added requireValue for Node-side nullable state.
  • Added inline guards inside page.evaluate for missing browser-side entities.
  • Validated root elements as HTMLDivElement.
apps/e2e/global.d.ts
apps/e2e/page-objects/requireValue.ts
apps/e2e/tests/block/block-geometry-batching.spec.ts
apps/e2e/tests/camera/camera-block-scale-level.spec.ts
apps/e2e/tests/color-parsing.spec.ts
apps/e2e/tests/connection/bezier-hitbox.spec.ts
apps/e2e/tests/evented-area.spec.ts
apps/e2e/tests/groups/block-group-transfer.spec.ts
apps/e2e/tests/groups/collapsible-group.spec.ts
apps/e2e/tests/minimap/minimap-styling.spec.ts
apps/e2e/tests/port-delegation.spec.ts
Made collapsible-group and event assertions conform to the library's declared types.
  • Read group state as TCollapsibleGroup where suites construct CollapsibleGroup instances.
  • Derived collapse-event detail from GraphEventsDefinitions and removed event any casts.
  • Narrowed nullable rectangles and connection geometry before assertions.
apps/e2e/tests/groups/block-group-transfer.spec.ts
apps/e2e/tests/groups/collapsible-group.spec.ts
Added focused typing fixes for event payloads, entity updates, and literal configuration values.
  • Typed mouse event details used by camera emulation tests.
  • Passed complete TBlock-compatible update data while preserving existing values.
  • Marked the Bezier direction as a literal type.
apps/e2e/tests/camera/camera-mouse-emulation.spec.ts
apps/e2e/tests/connection/bezier-hitbox.spec.ts
apps/e2e/tests/port-delegation.spec.ts

Possibly linked issues


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.

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

Hey - I've found 1 issue

Prompt for AI Agents
Please address the comments from this code review:

## Individual Comments

### Comment 1
<location path="apps/e2e/tests/port-delegation.spec.ts" line_range="123" />
<code_context>
-      window.graph.updateEntities({ blocks: [{ id: "block-c", x: 300, y: 600 }] });
-    });
+    await page.evaluate(({ id, is, name, width, height }) => {
+      window.graph.updateEntities({ blocks: [{ id, is, name, width, height, x: 300, y: 600 }] });
+    }, BLOCKS[2]);

</code_context>
<issue_to_address>
**Unmoved delegated port passes**

When the block-c update does not change its position, `connection updates when delegate target block moves` compares the connection source to the target port’s current position at line 147; if the line 123 update leaves block-c in place, both values remain equal and the test passes.

Assert that the target port is at the expected position after the update, in addition to matching the connection source to it.
</issue_to_address>

Sourcery assessment

Approval pending. 1 finding to address first.

Blocking findings: apps/e2e/tests/port-delegation.spec.ts:123


Sourcery is free for open source - if you like our reviews please consider sharing them ✨

Comment thread apps/e2e/tests/port-delegation.spec.ts
The "connection updates when delegate target block moves" test only
compared the connection source with block-c's current port, so it also
passed when the update left block-c in place. Assert block-c's new
position and that its output port follows it.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

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

Sourcery assessment

Approved.

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