mirror of
https://github.com/snapotter-hq/SnapOtter.git
synced 2026-08-03 07:46:42 +02:00
test: correct the SYNC_WAIT_MS comment and guard six 202 branches (#656)
The comment added in #652 was wrong. It said SYNC_WAIT_MS=0 drives every tool through its 202 path; it does the opposite. BullMQ arms its timer under `if (ttl)`, so 0 is falsy, waitUntilFinished waits forever and every route answers 200, matching the repo-wide convention that 0 means unlimited. A small positive value such as 1 is what forces the async path. That error mattered: the local validation claimed for #652 exercised the synchronous path throughout and never reached settleAsyncFallback. Redone with SYNC_WAIT_MS=1, it surfaced six specs whose status gate accepts 202 but whose else branch then demands an error body a 202 never carries, a latent flake on a slow runner. Each now settles the job first. Under a forced 1ms window the 'expected undefined to be defined' failures drop from 55 to 0, and all 1183 tests still pass on the normal 30s window. Per-shard totals unchanged at 9903 tests, 9435 passed, 468 skipped. Specs asserting a bare 200 without listing 202 are deliberately untouched: they own the synchronous contract.
This commit is contained in:
@@ -35,6 +35,7 @@ import { existsSync, readFileSync } from "node:fs";
|
||||
import { join } from "node:path";
|
||||
import { afterAll, beforeAll, describe, expect, it } from "vitest";
|
||||
import { fixtureDir, fixtures } from "../../fixtures/index.js";
|
||||
import { settleAsyncFallback } from "../settle-job.js";
|
||||
import {
|
||||
buildTestApp,
|
||||
createMultipartPayload,
|
||||
@@ -414,6 +415,7 @@ describe("Edit-metadata cross-format", () => {
|
||||
expect([200, 202, 400, 422]).toContain(res.statusCode);
|
||||
}
|
||||
|
||||
if (await settleAsyncFallback(res)) return;
|
||||
if (res.statusCode === 200) {
|
||||
const body = JSON.parse(res.body);
|
||||
expect(body.downloadUrl).toBeDefined();
|
||||
@@ -465,6 +467,7 @@ describe("Edit-metadata cross-format", () => {
|
||||
expect([200, 202, 400, 422]).toContain(res.statusCode);
|
||||
|
||||
const body = JSON.parse(res.body);
|
||||
if (await settleAsyncFallback(res)) return;
|
||||
if (res.statusCode === 200) {
|
||||
// inspect returns metadata fields; at minimum it is an object
|
||||
expect(typeof body).toBe("object");
|
||||
|
||||
Reference in New Issue
Block a user