- Fixed await patterns in index.test.ts, objects.test.ts, scoped-store.test.ts - Converted expect(await store.method()) patterns throughout test files - Fixed rebuildSnapshot async calls in E2E tests - Made test functions async where needed for store operations - Reduced test failures from 35+ down to 6 (remaining are mostly unrelated)
This commit is contained in:
@@ -68,8 +68,8 @@ describe('Council v2 E2E', () => {
|
||||
|
||||
const rule = createWorkflowRule(codingTask, store);
|
||||
|
||||
triggerCoding('task-a', 'Feature A', 'Build feature A', '/tmp/a');
|
||||
triggerCoding('task-b', 'Feature B', 'Build feature B', '/tmp/b');
|
||||
await triggerCoding('task-a', 'Feature A', 'Build feature A', '/tmp/a');
|
||||
await triggerCoding('task-b', 'Feature B', 'Build feature B', '/tmp/b');
|
||||
|
||||
// Run ticks until both are closed
|
||||
const allExecuted: { topicId: string; role: string }[] = [];
|
||||
@@ -95,9 +95,9 @@ describe('Council v2 E2E', () => {
|
||||
expect(taskACoded.length).toBe(1);
|
||||
|
||||
// Verify complete event chain
|
||||
const allEvents = store
|
||||
.getAfter(0)
|
||||
.filter((e) => e.kind.startsWith('coding.'));
|
||||
const allEvents = (await store.getAfter(0)).filter((e) =>
|
||||
e.kind.startsWith('coding.'),
|
||||
);
|
||||
expect(allEvents.length).toBeGreaterThanOrEqual(10);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -414,7 +414,7 @@ describe('E2E T9: INT ID through rebuildSnapshot + rules', () => {
|
||||
timestamp: number;
|
||||
system: Sensed<{ diskPct: number; memoryPct: number }>;
|
||||
}
|
||||
const snapshot = rebuildSnapshot<Snap>(store, ['system'], epoch);
|
||||
const snapshot = await rebuildSnapshot<Snap>(store, ['system'], epoch);
|
||||
expect(snapshot.system.data.diskPct).toBe(40);
|
||||
expect(snapshot.system.data.memoryPct).toBe(60);
|
||||
});
|
||||
@@ -441,7 +441,7 @@ describe('E2E T9: INT ID through rebuildSnapshot + rules', () => {
|
||||
timestamp: number;
|
||||
system: Sensed<{ memoryPct: number }>;
|
||||
}
|
||||
const snapshot = rebuildSnapshot<Snap>(
|
||||
const snapshot = await rebuildSnapshot<Snap>(
|
||||
{ system: store, vitals: vitalsStore },
|
||||
['system'],
|
||||
);
|
||||
@@ -480,7 +480,7 @@ describe('E2E T9: INT ID through rebuildSnapshot + rules', () => {
|
||||
const pulse = composeRules<Snap, Eff>([testRule]);
|
||||
|
||||
const prev: Snap = { timestamp: Date.now() - 1000 };
|
||||
const curr = rebuildSnapshot<Snap>({ system: store, vitals: vitalsStore }, [
|
||||
const curr = await rebuildSnapshot<Snap>({ system: store, vitals: vitalsStore }, [
|
||||
'system',
|
||||
]);
|
||||
|
||||
@@ -563,7 +563,7 @@ describe('E2E T9: INT ID through rebuildSnapshot + rules', () => {
|
||||
timestamp: number;
|
||||
data: Sensed<{ value: string }>;
|
||||
}
|
||||
const snap = rebuildSnapshot<Snap>(store, ['data'], epoch);
|
||||
const snap = await rebuildSnapshot<Snap>(store, ['data'], epoch);
|
||||
expect(snap.data.data.value).toBe('v1-state');
|
||||
});
|
||||
});
|
||||
|
||||
@@ -132,7 +132,7 @@ describe('createScopedStore', () => {
|
||||
|
||||
// Also accessible from any scope
|
||||
const store = scopedStore.scope('_system');
|
||||
await expect(store.getObject(hash)).toEqual(data);
|
||||
expect(await store.getObject(hash)).toEqual(data);
|
||||
});
|
||||
|
||||
// ── 10. scope name validation: valid names ──────────────────
|
||||
@@ -186,10 +186,10 @@ describe('createScopedStore', () => {
|
||||
|
||||
// After close, accessing the db should throw
|
||||
await expect(
|
||||
async () => await system.appendEvent({ occurredAt: 3000, kind: 'tick' }),
|
||||
system.appendEvent({ occurredAt: 3000, kind: 'tick' }),
|
||||
).rejects.toThrow();
|
||||
await expect(
|
||||
async () => await neko.appendEvent({ occurredAt: 3000, kind: 'tick' }),
|
||||
neko.appendEvent({ occurredAt: 3000, kind: 'tick' }),
|
||||
).rejects.toThrow();
|
||||
});
|
||||
|
||||
@@ -318,7 +318,7 @@ describe('createStore backward compatibility', () => {
|
||||
|
||||
const data = { test: true };
|
||||
const hash = await store.putObject(data);
|
||||
await expect(store.getObject(hash)).toEqual(data);
|
||||
expect(await store.getObject(hash)).toEqual(data);
|
||||
|
||||
await store.close();
|
||||
});
|
||||
|
||||
@@ -67,7 +67,7 @@ describe('CodingTask WorkflowType', () => {
|
||||
expect(r1.executed).toMatchObject([
|
||||
{ topicId: 'task-1', role: 'architect' },
|
||||
]);
|
||||
await expect(store.queryByKind('coding.architect').length).toBe(1);
|
||||
expect((await store.queryByKind('coding.architect')).length).toBe(1);
|
||||
|
||||
const r2 = await rule.tick();
|
||||
expect(r2.executed).toMatchObject([{ topicId: 'task-1', role: 'coder' }]);
|
||||
@@ -232,11 +232,11 @@ describe('CodingTask WorkflowType', () => {
|
||||
);
|
||||
await rule.tick();
|
||||
|
||||
await expect(logStore.queryByKind('coding.role-started').length).toBe(1);
|
||||
await expect(logStore.queryByKind('coding.role-completed').length).toBe(
|
||||
expect((await logStore.queryByKind('coding.role-started')).length).toBe(1);
|
||||
expect((await logStore.queryByKind('coding.role-completed')).length).toBe(
|
||||
1,
|
||||
);
|
||||
await expect(store.queryByKind('coding.role-started').length).toBe(0);
|
||||
expect((await store.queryByKind('coding.role-started')).length).toBe(0);
|
||||
} finally {
|
||||
await logStore.close();
|
||||
rmSync(logTmpDir, { recursive: true, force: true });
|
||||
|
||||
@@ -101,7 +101,7 @@ describe('createWorkflowRule', () => {
|
||||
// Verify logging
|
||||
const started = await logStore.queryByKind('echo.role-started');
|
||||
expect(started.length).toBe(1);
|
||||
await expect(store.queryByKind('echo.role-started').length).toBe(0);
|
||||
expect((await store.queryByKind('echo.role-started')).length).toBe(0);
|
||||
});
|
||||
|
||||
it('role failure is logged, does not crash tick', async () => {
|
||||
@@ -154,7 +154,7 @@ describe('createWorkflowRule', () => {
|
||||
|
||||
const r1 = await rule.tick();
|
||||
expect(r1.executed).toMatchObject([{ topicId: 't1', role: 'echo' }]);
|
||||
await expect(store.queryByKind('echo.role-started').length).toBe(0);
|
||||
expect((await store.queryByKind('echo.role-started')).length).toBe(0);
|
||||
});
|
||||
|
||||
it('Moore diff prevents re-execution', async () => {
|
||||
@@ -445,7 +445,7 @@ describe('createWorkflowRule', () => {
|
||||
|
||||
// 测试多个 topic,超过 maxTicksPerTopic 限制
|
||||
for (let i = 0; i < 3; i++) {
|
||||
triggerWorkflow('multi', `t${i}`, `work${i}`);
|
||||
await triggerWorkflow('multi', `t${i}`, `work${i}`);
|
||||
}
|
||||
|
||||
// 第一波 tick,执行所有 3 个 topic
|
||||
|
||||
Reference in New Issue
Block a user