PEP-270: тесты «готово» ждут ходов сторожа, а не одного
Some checks failed
peppa/lint lint: success за 2с
peppa/typecheck typecheck: success за 47с
peppa/build build: success за 33с
peppa/test test: failure за 1387с
peppa-ci / ci (pull_request) Failing after 25m19s

Под нагрузкой CI ответ Gitea опаздывает, prGate закрыт и «готово» придерживается до
следующего reviewCardTick — тесты делали один ход и падали (прогон 193). Проверки те же:
одно новое сообщение и ровно пять карточек; см. PEP-282.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
peppa-bot 2026-11-24 19:32:37 +00:00
parent 23af08d9a9
commit 93000397a8
2 changed files with 15 additions and 4 deletions

View File

@ -292,8 +292,12 @@ describe("ready-for-review only when mergeable", () => {
t.green(t.push());
t.pull().mergeable = true;
await t.toReview();
await cardTick();
const fresh = await cards(t.proj.id);
// The watchdog ticks until the card goes: on a loaded CI runner one Gitea answer may come too late for the first tick.
const fresh = await waitFor("a new message", async () => {
await cardTick();
const c = await cards(t.proj.id);
return c.length ? c : null;
});
assert.equal(fresh.length, 1, "a new message");
assert.notEqual(fresh[0]!.id, q!.id);
await t.stopAll();

View File

@ -6,7 +6,7 @@ import { mkdtempSync, writeFileSync } from "node:fs";
import { tmpdir } from "node:os";
import { join } from "node:path";
import { after, before, describe, test } from "node:test";
import { core, db, project, runner, setDefaultOwner, teardown } from "./helpers.ts";
import { core, db, project, runner, setDefaultOwner, teardown, waitFor } from "./helpers.ts";
import { MockGitea } from "../src/mock-gitea.ts";
import { questions, releases, tasks, telegramOutbox, users } from "@peppa/db";
import { eq, sql } from "drizzle-orm";
@ -132,7 +132,14 @@ describe("Сводка готовых в Telegram", () => {
const { proj, refs } = await inReview(5);
const t0 = Date.now();
for (const ref of refs) await core.sendReviewCard(db, ref, { text: `${ref.key} готова` }, null, null as never).catch(() => null);
const cards = (await db.select().from(questions).where(eq(questions.projectId, proj.id))).filter((q) => q.msgType === "done");
// A slow Gitea answer (a loaded CI runner) holds a card back; the watchdog's ticks send it, as live.
const done = async () => (await db.select().from(questions).where(eq(questions.projectId, proj.id))).filter((q) => q.msgType === "done");
const cards = await waitFor("five cards", async () => {
const c = await done();
if (c.length >= 5) return c;
await runner.reviewCardTick(db);
return null;
});
assert.equal(cards.length, 5);
for (const q of cards) assert.equal(await core.acceptDigestHold(db, q, new Date(t0 + 60_000)), "wait", "within the pause");
for (const q of cards) assert.equal(await core.acceptDigestHold(db, q, new Date(t0 + 400_000)), "held", "more than two within an hour");