Fix activity-feed test flake: updateJob honors explicit patch.updatedAt; scoped test cleanup
Two-part root cause (found by the lh-ui stream + master together): (1) src/store/jobs.ts updateJob unconditionally overwrote updatedAt with now(), silently clobbering any explicit patch timestamp — JobPatch types it as patchable but the adapter ignored it, so order-sensitive tests rode on same-millisecond tie-breaking (failed ~4/5 in isolation). The store now honors patch.updatedAt ?? now() — semantics-preserving for every existing caller, which never passed updatedAt explicitly. (2) the activity-feed test's finally wiped the ENTIRE shared data/jobs dir — with node:test running test files as concurrent processes, that deletes other processes' live fixtures; cleanup is now scoped to the test's own created ids.
This commit is contained in:
+4
-2
@@ -48,11 +48,13 @@ function getJob(id: string): JobRecord | null {
|
||||
}
|
||||
}
|
||||
|
||||
/** Merge a partial patch into the record (identity fields are immutable). */
|
||||
/** Merge a partial patch into the record (identity fields are immutable).
|
||||
* An explicit patch.updatedAt is honored (tests pin deterministic order);
|
||||
* otherwise the merge bumps it to now. */
|
||||
function updateJob(id: string, patch: JobPatch): JobRecord | null {
|
||||
const record = getJob(id);
|
||||
if (!record) return null;
|
||||
const next: JobRecord = { ...record, ...patch, updatedAt: new Date().toISOString() };
|
||||
const next: JobRecord = { ...record, ...patch, updatedAt: patch.updatedAt ?? new Date().toISOString() };
|
||||
fs.writeFileSync(jobFile(id), JSON.stringify(next, null, "\t"), "utf-8");
|
||||
return next;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user