fix(team): preserve cached task nested fields
This commit is contained in:
parent
b9cfdb9323
commit
961691f477
2 changed files with 17 additions and 4 deletions
|
|
@ -774,9 +774,9 @@ function restorePersistentTaskProjectionShape(
|
|||
owner: typeof task.owner === 'string' ? task.owner : undefined,
|
||||
createdBy: typeof task.createdBy === 'string' ? task.createdBy : undefined,
|
||||
status,
|
||||
workIntervals: Array.isArray(task.workIntervals) ? task.workIntervals : undefined,
|
||||
reviewIntervals: Array.isArray(task.reviewIntervals) ? task.reviewIntervals : undefined,
|
||||
historyEvents: Array.isArray(task.historyEvents) ? task.historyEvents : undefined,
|
||||
workIntervals: normalizeWorkIntervals(task),
|
||||
reviewIntervals: normalizeReviewIntervals(task),
|
||||
historyEvents: normalizeHistoryEvents(task),
|
||||
blocks: Array.isArray(task.blocks) ? task.blocks : undefined,
|
||||
blockedBy: Array.isArray(task.blockedBy) ? task.blockedBy : undefined,
|
||||
related: Array.isArray(task.related)
|
||||
|
|
@ -785,7 +785,7 @@ function restorePersistentTaskProjectionShape(
|
|||
createdAt: typeof task.createdAt === 'string' ? task.createdAt : undefined,
|
||||
updatedAt: typeof task.updatedAt === 'string' ? task.updatedAt : undefined,
|
||||
projectPath: typeof task.projectPath === 'string' ? task.projectPath : undefined,
|
||||
comments: Array.isArray(task.comments) ? task.comments : undefined,
|
||||
comments: normalizeComments(task),
|
||||
needsClarification:
|
||||
task.needsClarification === 'lead' || task.needsClarification === 'user'
|
||||
? task.needsClarification
|
||||
|
|
|
|||
|
|
@ -593,15 +593,27 @@ describe('team-fs-worker integration', () => {
|
|||
subject: 'Persisted subject',
|
||||
status: 'pending',
|
||||
createdAt: '2026-05-02T12:00:00.000Z',
|
||||
workIntervals: [{ startedAt: '2026-05-02T12:00:00.000Z' }],
|
||||
reviewIntervals: [{ reviewer: 'alice', startedAt: '2026-05-02T12:30:00.000Z' }],
|
||||
comments: [
|
||||
{
|
||||
id: 'comment-1',
|
||||
author: 'alice',
|
||||
text: 'Looks good',
|
||||
createdAt: '2026-05-02T12:45:00.000Z',
|
||||
},
|
||||
],
|
||||
}),
|
||||
'utf8'
|
||||
);
|
||||
|
||||
const firstWorker = createWorker(workerPath);
|
||||
let firstTasks: unknown[] = [];
|
||||
let firstTaskKeys: string[] = [];
|
||||
try {
|
||||
const first = await callGetAllTasks(firstWorker, tasksBase, projectionCacheBase);
|
||||
expect(first.tasks[0]).toMatchObject({ teamName, subject: 'Persisted subject' });
|
||||
firstTasks = first.tasks;
|
||||
firstTaskKeys = Object.keys(first.tasks[0] as Record<string, unknown>);
|
||||
expect(first.diag?.cacheMisses).toBe(1);
|
||||
expect(first.diag?.persistentCacheWrites).toBe(1);
|
||||
|
|
@ -616,6 +628,7 @@ describe('team-fs-worker integration', () => {
|
|||
expect(Object.keys(second.tasks[0] as Record<string, unknown>)).toEqual(
|
||||
firstTaskKeys
|
||||
);
|
||||
expect(second.tasks).toEqual(firstTasks);
|
||||
expect(second.diag?.cacheHits).toBe(0);
|
||||
expect(second.diag?.cacheMisses).toBe(0);
|
||||
expect(second.diag?.persistentCacheLoads).toBe(1);
|
||||
|
|
|
|||
Loading…
Reference in a new issue