fix: werewolf test async + e2e tick loop
CI / test (push) Has been cancelled

This commit is contained in:
2026-04-18 07:06:40 +00:00
parent 1afce01335
commit be2d9de6b1
2 changed files with 10 additions and 14 deletions
+6 -10
View File
@@ -390,16 +390,12 @@ async function main() {
// Run ticks until game ends
let maxTicks = 100;
while (maxTicks-- > 0) {
const result = await ticker();
if (!result || result.length === 0) {
// Check if game ended
const events = await store.queryByKind('werewolf.game-end', { limit: 1 });
if (events.length > 0) {
console.log('\n🎮 游戏结束!');
break;
}
// Might be waiting, tick again
continue;
await ticker();
// Check if game ended
const endEvents = await store.queryByKind('werewolf.game-end', { limit: 1 });
if (endEvents.length > 0) {
console.log('\n🎮 游戏结束!');
break;
}
}
@@ -46,9 +46,9 @@ describe('werewolf WorkflowType', () => {
if (tmpDir) rmSync(tmpDir, { recursive: true, force: true });
}
function trigger(topicId: string) {
const hash = store.putObject('werewolf game start');
store.appendEvent({
async function trigger(topicId: string) {
const hash = await store.putObject('werewolf game start');
await store.appendEvent({
occurredAt: Date.now(),
kind: 'werewolf.__start__',
key: topicId,
@@ -62,7 +62,7 @@ describe('werewolf WorkflowType', () => {
try {
const wf = createWerewolfWorkflow();
const rule = createWorkflowRule(wf, store);
trigger('g1');
await trigger('g1');
const order: string[] = [];
// Max 200 ticks to allow the game to finish