[PR #5644] [MERGED] feat(tooling): type-check the Playwright e2e specs in pnpm check #6864

Closed
opened 2026-10-23 04:14:24 +07:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/Pasta-Devs/Marinara-Engine/pull/5644
Author: @kolacheee
Created: 8/29/2026
Status: ✅ Merged
Merged: 8/29/2026
Merged by: @kolacheee

Base: staging ← Head: feat/e2e-type-lane


📝 Commits (1)

  • 8e26644 feat(tooling): type-check the Playwright e2e specs in pnpm check

📊 Changes

7 files changed (+150 additions, -92 deletions)

View changed files

📝 e2e/core-flows.e2e.ts (+88 -85)
➕ e2e/page-context-modules.d.ts (+38 -0)
📝 package.json (+4 -2)
📝 packages/client/src/lib/slash-commands.ts (+1 -1)
📝 packages/client/src/localization/locale-loader.ts (+2 -2)
📝 pnpm-lock.yaml (+3 -0)
📝 tsconfig.json (+14 -2)

📄 Description

Why

The root tsconfig has always included e2e/**/*.ts, but no check lane ever ran tsc on it — pnpm check runs only the three package lints. That let a plain runtime ReferenceError (a variable moved into a closure while still referenced outside it) pass pnpm check untouched and only surface when the test executed, during the #5642 work. This PR makes the specs type-checkable and wires the check into pnpm check, so that class of bug dies in CI.

Note: there is no linked issue for this — it came out of a follow-up task spun off from the #5642 investigation.

The interesting part: typing browser-context imports

The specs import app modules inside page.evaluate callbacks through dev-server URLs (import("/src/stores/ui.store.ts")). tsc cannot resolve those — and because rooted (/-prefixed) specifiers are classified as relative, ambient declare module blocks can never match them either (tried first; silently ignored). The working pattern, applied at all 58 call sites:

const module = (await import("/src/stores/ui.store.ts" as string)) as PageUiStoreModule;

as string widens the specifier so tsc skips resolution — it's erased at transpile, so the browser receives the literal unchanged (the repo already had TS casts inside evaluate callbacks passing CI, proving Playwright transpiles the callbacks before serializing them). The Page*Module aliases live in a new global e2e/page-context-modules.d.ts and type-query the real client sources, so the specs type-check against the actual app APIs and drift surfaces as a type error instead of at runtime. The one .tsx page import (GameSurface) keeps its existing structural cast rather than dragging the component tree into the program.

What the lane immediately caught

~50 genuine strictness misses, all fixed: wrong element types on evaluate callbacks (textarea/input selection APIs on HTMLElement | SVGElement), unchecked indexed access across measurement arrays, and a missing four-bounds guard in the home-hub layout assertions (now a real assertion with a useful message). The storedSchedule() chains use ! rather than ?. deliberately, preserving the exact throw-on-missing poll semantics of the untyped code (expect.poll fails immediately on a throw but soft-times-out on undefined).

Two client sources that the type queries pull into the root program were hardened one line each (slash-commands.ts, locale-loader.ts) for noUncheckedIndexedAccess, which the root project enables and the client project doesn't. A minimal ImportMeta interface merge covers the vite-specific import.meta.env/glob those sources use.

Wiring

  • check:e2e-types = tsc --noEmit -p tsconfig.json, with typescript@^5.9.3 (matching the workspaces) as a root devDependency.
  • Runs inside pnpm check between lint and build — verified build-independent (--traceResolution shows every @marinara-engine/shared import resolving to packages/shared/src, never dist), so it works on a fresh clone before anything is built.
  • The existing pull-request-checks workflow picks it up with zero CI changes; the lane adds ~3s.
  • Root lib bumped ES2022 → ES2023 to match the client project the type-queried sources normally compile under.

Validation

  • check:e2e-types exit 0; full pnpm check green.
  • A/B: reintroducing the motivating bug class (an out-of-scope variable reference) fails the lane with TS2304.
  • 11-test runtime sanity pass across every edit class — including the Korean-localization and GameSurface-combat tests as canaries for non-ASCII string literals — all green, --retries=0.
  • 3-reviewer adversarial pass verified: all 58 conversion sites well-formed, every retained structural cast checked against the real module exports, the vite /src ↔ packages/client/src correspondence exact, no behavior change in any "type-only" edit, and lockfile drift limited to the one devDependency. The same pass caught an encoding corruption in an intermediate version of this branch (PowerShell mojibake across the spec's non-ASCII literals) — the final commit was rebuilt byte-exactly via Node and the canary tests above prove it.
  • Manually verify: run pnpm check on a fresh checkout of this branch; optionally re-add a bogus void someUndeclaredName; line to e2e/core-flows.e2e.ts and confirm pnpm check:e2e-types rejects it.

Summary by CodeRabbit

  • Bug Fixes

    • Improved reliability when parsing empty slash-command arguments.
    • Preserved locale detection behavior across supported and unsupported paths.
    • Added clearer validation errors when widget layout bounds are missing.
  • Tests

    • Strengthened end-to-end coverage for selections, undo, imports, state, and widget layouts.
    • Added type checking for browser-context test modules and editor textareas.
  • Chores

    • Integrated end-to-end type checking into the standard validation workflow.

🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/Pasta-Devs/Marinara-Engine/pull/5644 **Author:** [@kolacheee](https://github.com/kolacheee) **Created:** 8/29/2026 **Status:** ✅ Merged **Merged:** 8/29/2026 **Merged by:** [@kolacheee](https://github.com/kolacheee) **Base:** `staging` ← **Head:** `feat/e2e-type-lane` --- ### 📝 Commits (1) - [`8e26644`](https://github.com/Pasta-Devs/Marinara-Engine/commit/8e266443ff1e78f3befb72fd0a72cad00e3c969d) feat(tooling): type-check the Playwright e2e specs in pnpm check ### 📊 Changes **7 files changed** (+150 additions, -92 deletions) <details> <summary>View changed files</summary> 📝 `e2e/core-flows.e2e.ts` (+88 -85) ➕ `e2e/page-context-modules.d.ts` (+38 -0) 📝 `package.json` (+4 -2) 📝 `packages/client/src/lib/slash-commands.ts` (+1 -1) 📝 `packages/client/src/localization/locale-loader.ts` (+2 -2) 📝 `pnpm-lock.yaml` (+3 -0) 📝 `tsconfig.json` (+14 -2) </details> ### 📄 Description ## Why The root tsconfig has always included `e2e/**/*.ts`, but no check lane ever ran tsc on it — `pnpm check` runs only the three package lints. That let a plain runtime `ReferenceError` (a variable moved into a closure while still referenced outside it) pass `pnpm check` untouched and only surface when the test executed, during the #5642 work. This PR makes the specs type-checkable and wires the check into `pnpm check`, so that class of bug dies in CI. Note: there is no linked issue for this — it came out of a follow-up task spun off from the #5642 investigation. ## The interesting part: typing browser-context imports The specs import app modules *inside `page.evaluate` callbacks* through dev-server URLs (`import("/src/stores/ui.store.ts")`). tsc cannot resolve those — and because rooted (`/`-prefixed) specifiers are classified as **relative**, ambient `declare module` blocks can never match them either (tried first; silently ignored). The working pattern, applied at all 58 call sites: ```ts const module = (await import("/src/stores/ui.store.ts" as string)) as PageUiStoreModule; ``` `as string` widens the specifier so tsc skips resolution — it's erased at transpile, so the browser receives the literal unchanged (the repo already had TS casts inside evaluate callbacks passing CI, proving Playwright transpiles the callbacks before serializing them). The `Page*Module` aliases live in a new global `e2e/page-context-modules.d.ts` and **type-query the real client sources**, so the specs type-check against the actual app APIs and drift surfaces as a type error instead of at runtime. The one `.tsx` page import (GameSurface) keeps its existing structural cast rather than dragging the component tree into the program. ## What the lane immediately caught ~50 genuine strictness misses, all fixed: wrong element types on `evaluate` callbacks (textarea/input selection APIs on `HTMLElement | SVGElement`), unchecked indexed access across measurement arrays, and a missing four-bounds guard in the home-hub layout assertions (now a real assertion with a useful message). The `storedSchedule()` chains use `!` rather than `?.` deliberately, preserving the exact throw-on-missing poll semantics of the untyped code (`expect.poll` fails immediately on a throw but soft-times-out on `undefined`). Two client sources that the type queries pull into the root program were hardened one line each (`slash-commands.ts`, `locale-loader.ts`) for `noUncheckedIndexedAccess`, which the root project enables and the client project doesn't. A minimal `ImportMeta` interface merge covers the vite-specific `import.meta.env/glob` those sources use. ## Wiring - `check:e2e-types` = `tsc --noEmit -p tsconfig.json`, with `typescript@^5.9.3` (matching the workspaces) as a root devDependency. - Runs inside `pnpm check` between lint and build — verified build-independent (`--traceResolution` shows every `@marinara-engine/shared` import resolving to `packages/shared/src`, never `dist`), so it works on a fresh clone before anything is built. - The existing pull-request-checks workflow picks it up with **zero CI changes**; the lane adds ~3s. - Root `lib` bumped ES2022 → ES2023 to match the client project the type-queried sources normally compile under. ## Validation - `check:e2e-types` exit 0; full `pnpm check` green. - A/B: reintroducing the motivating bug class (an out-of-scope variable reference) fails the lane with TS2304. - 11-test runtime sanity pass across every edit class — including the Korean-localization and GameSurface-combat tests as canaries for non-ASCII string literals — all green, `--retries=0`. - 3-reviewer adversarial pass verified: all 58 conversion sites well-formed, every retained structural cast checked against the real module exports, the vite `/src` ↔ `packages/client/src` correspondence exact, no behavior change in any "type-only" edit, and lockfile drift limited to the one devDependency. The same pass caught an encoding corruption in an intermediate version of this branch (PowerShell mojibake across the spec's non-ASCII literals) — the final commit was rebuilt byte-exactly via Node and the canary tests above prove it. - Manually verify: run `pnpm check` on a fresh checkout of this branch; optionally re-add a bogus `void someUndeclaredName;` line to `e2e/core-flows.e2e.ts` and confirm `pnpm check:e2e-types` rejects it. <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit - **Bug Fixes** - Improved reliability when parsing empty slash-command arguments. - Preserved locale detection behavior across supported and unsupported paths. - Added clearer validation errors when widget layout bounds are missing. - **Tests** - Strengthened end-to-end coverage for selections, undo, imports, state, and widget layouts. - Added type checking for browser-context test modules and editor textareas. - **Chores** - Integrated end-to-end type checking into the standard validation workflow. <!-- end of auto-generated comment: release notes by coderabbit.ai --> --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-10-23 04:14:24 +07:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
Pasta-Devs/Marinara-Engine#6864
No description provided.