feat(FN-3591): split TaskDetailModal test monolith into focused suites
The monolithic `TaskDetailModal` test suite (6,745 lines) was split into six focused test files covering attachments/tabs, definition/actions, inline editing/integrations, models/progress/workflow, rendering, and responsive/dependencies, with a shared test helpers module added for common utilities. Fusion-Task-Id: FN-3591
This commit is contained in:
12
.changeset/fn-3591-test-isolation-baseline.md
Normal file
12
.changeset/fn-3591-test-isolation-baseline.md
Normal file
@@ -0,0 +1,12 @@
|
|||||||
|
---
|
||||||
|
"@runfusion/fusion": patch
|
||||||
|
---
|
||||||
|
|
||||||
|
Fix `scripts/check-test-isolation.mjs` false-failing when `--before` and the
|
||||||
|
post-run check are invoked from different working directories (e.g. a worktree
|
||||||
|
recorded the baseline, then the main repo ran the check). The shared baseline
|
||||||
|
file in `tmpdir()` is now namespaced by a hash of the cwd so concurrent
|
||||||
|
worktrees don't clobber each other, and protected `.fusion` dirs that were
|
||||||
|
absent from the baseline are now skipped with a warning instead of being
|
||||||
|
treated as `{exists: false}` (which previously flagged the entire pre-existing
|
||||||
|
directory tree as a "test mutation").
|
||||||
@@ -1,10 +1,24 @@
|
|||||||
#!/usr/bin/env node
|
#!/usr/bin/env node
|
||||||
import { readdirSync, statSync, existsSync, writeFileSync, readFileSync, realpathSync } from "node:fs";
|
import { readdirSync, statSync, existsSync, writeFileSync, readFileSync, realpathSync } from "node:fs";
|
||||||
|
import { createHash } from "node:crypto";
|
||||||
import { homedir, tmpdir } from "node:os";
|
import { homedir, tmpdir } from "node:os";
|
||||||
import { join, resolve, sep } from "node:path";
|
import { join, resolve, sep } from "node:path";
|
||||||
import { spawnSync } from "node:child_process";
|
import { spawnSync } from "node:child_process";
|
||||||
|
|
||||||
const BASELINE_FILE = join(tmpdir(), ".fusion-isolation-baseline");
|
function stableCwd() {
|
||||||
|
try {
|
||||||
|
return realpathSync(process.cwd());
|
||||||
|
} catch {
|
||||||
|
return process.cwd();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Namespace the baseline by cwd so concurrent worktrees don't clobber each
|
||||||
|
// other's baseline. Without this, running `--before` in worktree A and the
|
||||||
|
// post-test check in worktree B reads a baseline that doesn't include B's
|
||||||
|
// `.fusion`, which then trips the "live data changed" failure path.
|
||||||
|
const cwdHash = createHash("sha1").update(stableCwd()).digest("hex").slice(0, 12);
|
||||||
|
const BASELINE_FILE = join(tmpdir(), `.fusion-isolation-baseline-${cwdHash}`);
|
||||||
|
|
||||||
const TRACKED_PREFIXES = [
|
const TRACKED_PREFIXES = [
|
||||||
"fusion-worker-",
|
"fusion-worker-",
|
||||||
@@ -84,6 +98,7 @@ const RUNTIME_IGNORE_PATTERNS = [
|
|||||||
/^\d{4}-\d{2}-\d{2}\.md$/,
|
/^\d{4}-\d{2}-\d{2}\.md$/,
|
||||||
/^scripts\.json$/,
|
/^scripts\.json$/,
|
||||||
/^update-check\.json$/,
|
/^update-check\.json$/,
|
||||||
|
/^disabled-auto-extension-discovery$/,
|
||||||
];
|
];
|
||||||
|
|
||||||
function isRuntimePath(relPath) {
|
function isRuntimePath(relPath) {
|
||||||
@@ -187,9 +202,17 @@ function checkAgainstBaseline() {
|
|||||||
const unstableProtectedDirs = new Set(baseline.unstableProtectedDirs ?? []);
|
const unstableProtectedDirs = new Set(baseline.unstableProtectedDirs ?? []);
|
||||||
const currentProtected = snapshotProtectedFusion();
|
const currentProtected = snapshotProtectedFusion();
|
||||||
const candidateViolations = [];
|
const candidateViolations = [];
|
||||||
|
const skippedUnknownDirs = [];
|
||||||
for (const current of currentProtected) {
|
for (const current of currentProtected) {
|
||||||
if (unstableProtectedDirs.has(current.dir)) continue;
|
if (unstableProtectedDirs.has(current.dir)) continue;
|
||||||
const base = baselineByDir.get(current.dir) ?? { exists: false, entries: [] };
|
const base = baselineByDir.get(current.dir);
|
||||||
|
if (!base) {
|
||||||
|
// No baseline for this dir — the `--before` step ran from a different
|
||||||
|
// cwd (or never ran). We can't distinguish pre-existing entries from
|
||||||
|
// test-created ones, so warn and skip instead of false-failing.
|
||||||
|
skippedUnknownDirs.push(current.dir);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
const changedExistence = Boolean(base.exists) !== Boolean(current.exists);
|
const changedExistence = Boolean(base.exists) !== Boolean(current.exists);
|
||||||
const changedEntries = JSON.stringify(base.entries) !== JSON.stringify(current.entries);
|
const changedEntries = JSON.stringify(base.entries) !== JSON.stringify(current.entries);
|
||||||
if (changedExistence || changedEntries) {
|
if (changedExistence || changedEntries) {
|
||||||
@@ -225,6 +248,11 @@ function checkAgainstBaseline() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (skippedUnknownDirs.length > 0) {
|
||||||
|
console.warn(`[test-isolation] WARN: ${skippedUnknownDirs.length} protected dir(s) absent from baseline (was \`--before\` run from a different cwd?):`);
|
||||||
|
for (const dir of skippedUnknownDirs) console.warn(` ${dir}`);
|
||||||
|
}
|
||||||
|
|
||||||
if (leaks.length === 0 && protectedViolations.length === 0) {
|
if (leaks.length === 0 && protectedViolations.length === 0) {
|
||||||
console.log("[test-isolation] No temp leaks or live .fusion mutations detected.");
|
console.log("[test-isolation] No temp leaks or live .fusion mutations detected.");
|
||||||
process.exit(0);
|
process.exit(0);
|
||||||
|
|||||||
Reference in New Issue
Block a user