-
Notifications
You must be signed in to change notification settings - Fork 123
feat(react): add preact upstream tests for E2E pipeline verification #2279
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: main
Are you sure you want to change the base?
Changes from all commits
4d87fa0
0794939
513da0b
c636bef
c98f48e
dbf2ea6
dfc8fad
65083a3
0f22865
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,4 @@ | ||
| [submodule "packages/react/preact-upstream-tests/preact"] | ||
| path = packages/react/preact-upstream-tests/preact | ||
| url = https://github.com/hzy/preact.git | ||
| branch = lynx/v10.24.x | ||
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -98,6 +98,7 @@ export default tseslint.config( | |||||
| // testing-library | ||||||
| 'packages/testing-library/**', | ||||||
| 'packages/react/testing-library/**', | ||||||
| 'packages/react/preact-upstream-tests/**', | ||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Narrow the ignore scope to only vendored upstream code. Ignoring Suggested diff- 'packages/react/preact-upstream-tests/**',
+ 'packages/react/preact-upstream-tests/preact/**',As per coding guidelines: 📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||
|
|
||||||
| // gesture-runtime-testing | ||||||
| 'packages/lynx/gesture-runtime/__test__/**', | ||||||
|
|
||||||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,8 @@ | ||
| --- | ||
| applyTo: "{skiplist.json,vitest.shared.ts,README.md,package.json}" | ||
| --- | ||
|
|
||
| When updating skiplist categories, always run each selected group in both projects (`preact-upstream` and `preact-upstream-compiled`) with `SKIPLIST_ONLY=<category>:<index>` before moving entries. | ||
| Keep mode orthogonality explicit: shared failures stay in `skip_list`/`permanent_skip_list`, no-compile-only failures go to `nocompile_skip_list`, compiled-only failures go to `compiler_skip_list`. | ||
| Because skip matching is title-based, check for duplicate test titles across files before removing an entry; a single title may map to multiple test cases with different outcomes. | ||
| In README positioning and run-order guidance, treat compiled mode as the primary product-path confidence signal and describe no-compile mode as a runtime baseline/regression-isolation tool. |
Large diffs are not rendered by default.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,25 @@ | ||
| { | ||
| "name": "@lynx-js/preact-upstream-tests", | ||
| "version": "0.0.0", | ||
| "private": true, | ||
| "scripts": { | ||
| "preact:init": "cd ../../.. && git submodule update --init packages/react/preact-upstream-tests/preact", | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Because this package is picked up by the root Vitest project globs, introducing a mandatory manual |
||
| "preact:status": "cd ../../.. && git submodule status packages/react/preact-upstream-tests/preact", | ||
| "preact:update": "cd ../../.. && git submodule update --remote packages/react/preact-upstream-tests/preact", | ||
| "test": "vitest run --workspace vitest.workspace.ts", | ||
| "test:compiled": "vitest run --workspace vitest.workspace.ts --project preact-upstream-compiled", | ||
| "test:no-compile": "vitest run --workspace vitest.workspace.ts --project preact-upstream", | ||
| "test:report": "node report.mjs", | ||
| "test:skipped": "SKIPLIST_ONLY=skip_list,nocompile_skip_list vitest run --workspace vitest.workspace.ts --project preact-upstream", | ||
| "test:skipped:compiled": "SKIPLIST_ONLY=skip_list,compiler_skip_list vitest run --workspace vitest.workspace.ts --project preact-upstream-compiled" | ||
| }, | ||
| "devDependencies": { | ||
| "@lynx-js/react": "workspace:*", | ||
| "@lynx-js/testing-environment": "workspace:*", | ||
| "chai": "^5.2.0", | ||
| "jsdom": "^26.1.0", | ||
| "sinon": "^19.0.2", | ||
| "sinon-chai": "^4.0.0", | ||
| "vitest": "^3.2.4" | ||
| } | ||
| } | ||
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
| @@ -0,0 +1,267 @@ | ||||||
| #!/usr/bin/env node | ||||||
| // Copyright 2026 The Lynx Authors. All rights reserved. | ||||||
| // Licensed under the Apache License Version 2.0 that can be found in the | ||||||
| // LICENSE file in the root directory of this source tree. | ||||||
|
|
||||||
| /** | ||||||
| * report.mjs — pass/skip dashboard for preact-upstream-tests. | ||||||
| * | ||||||
| * Runs both vitest projects, parses per-file summaries, and prints a grouped | ||||||
| * coverage table. Progress goes to stderr; the table goes to stdout so it can | ||||||
| * be piped / redirected freely. | ||||||
| * | ||||||
| * Usage: | ||||||
| * pnpm test:report | ||||||
| * pnpm test:report > report.txt | ||||||
| */ | ||||||
|
|
||||||
| import { spawnSync } from 'node:child_process'; | ||||||
| import { readFileSync } from 'node:fs'; | ||||||
| import path from 'node:path'; | ||||||
| import { fileURLToPath } from 'node:url'; | ||||||
|
|
||||||
| const __dirname = path.dirname(fileURLToPath(import.meta.url)); | ||||||
|
|
||||||
| // ── Groupings (order matters — first match wins) ────────────────────────────── | ||||||
| const GROUPS = [ | ||||||
| { | ||||||
| label: 'Core Reconciliation', | ||||||
| match: f => /\/(?:render|components|fragments|keys)\.test\.js$/.test(f), | ||||||
| }, | ||||||
| { | ||||||
| label: 'Lifecycle Methods', | ||||||
| match: f => f.includes('/lifecycles/'), | ||||||
| }, | ||||||
| { | ||||||
| label: 'Hooks', | ||||||
| match: f => f.includes('/hooks/test/browser/'), | ||||||
| }, | ||||||
| { | ||||||
| label: 'API & Utilities', | ||||||
| match: () => true, // catch-all | ||||||
| }, | ||||||
| ]; | ||||||
|
|
||||||
| // Files excluded from the vitest run (not counted in dashboard totals) | ||||||
| const EXCLUDED = [ | ||||||
| { | ||||||
| file: 'getDomSibling.test.js', | ||||||
| tests: 18, | ||||||
| category: 'test_methodology', | ||||||
| reason: 'Preact internals: _children VNode attachment', | ||||||
| }, | ||||||
| { file: 'refs.test.js', tests: 26, category: 'dual_thread', reason: 'BSI refs ≠ DOM nodes (deferred)' }, | ||||||
| { | ||||||
| file: 'replaceNode.test.js', | ||||||
| tests: 11, | ||||||
| category: 'test_methodology', | ||||||
| reason: 'SSR replaceNode / pre-populated DOM', | ||||||
| }, | ||||||
| ]; | ||||||
|
|
||||||
| // Skiplist (with category tags) — used for attribution | ||||||
| const skiplist = JSON.parse(readFileSync(path.resolve(__dirname, 'skiplist.json'), 'utf-8')); | ||||||
|
|
||||||
| const CATEGORY_LABELS = { | ||||||
| lynx_not_web: 'Lynx ≠ Web', | ||||||
| dual_thread: 'Dual-thread / IPC', | ||||||
| test_methodology: 'Test methodology', | ||||||
| }; | ||||||
|
|
||||||
| // ── Run one vitest project and return per-file stats ────────────────────────── | ||||||
| function runProject(project) { | ||||||
| process.stderr.write(` ${project.padEnd(32)} …`); | ||||||
| const r = spawnSync( | ||||||
| 'npx', | ||||||
|
||||||
| 'npx', | |
| 'pnpm', |
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.
Fail fast when a Vitest project exits non-zero.
The current flow always parses output and continues, so a failed run can still generate a misleading dashboard.
Proposed fix
function runProject(project) {
process.stderr.write(` ${project.padEnd(32)} …`);
const r = spawnSync(
'npx',
['vitest', 'run', '--workspace', 'vitest.workspace.ts', '--project', project],
{ cwd: __dirname, encoding: 'utf-8', maxBuffer: 16 * 1024 * 1024 },
);
+ if (r.status !== 0) {
+ throw new Error(
+ `Vitest project "${project}" failed (exit ${r.status ?? 'unknown'}).\n`
+ + `${r.stdout ?? ''}\n${r.stderr ?? ''}`,
+ );
+ }
const output = (r.stdout ?? '') + (r.stderr ?? '');
const stats = parse(output);🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.
In `@packages/react/preact-upstream-tests/report.mjs` around lines 74 - 85, Check
the spawnSync result (variable r) for failures before parsing: if r.error is set
or r.status is non-zero, write the combined output to stderr (using output) and
fail fast by calling process.exit(r.status || 1) or throwing an error; move this
check to immediately after computing r/output and before calling parse(output)
and computing stats/total/pass so a failing Vitest run doesn’t produce
misleading dashboard results.
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.
Use an organization-controlled submodule remote.
A personal-namespace GitHub URL increases availability/supply-chain risk for a critical test dependency. Please point this submodule at an org-owned canonical mirror (while keeping the same tracked branch/commit behavior).
🤖 Prompt for AI Agents