test: tighten helper assertion guards

This commit is contained in:
Peter Steinberger
2026-05-08 06:56:31 +01:00
parent c9053ff208
commit ab192eb3f0
9 changed files with 87 additions and 54 deletions

View File

@@ -944,7 +944,10 @@ export function describeTtsSummarizationContract() {
`Invalid targetLength: ${testCase.targetLength}`,
);
} else {
await expect(call, String(testCase.targetLength)).resolves.toBeDefined();
await expect(call, String(testCase.targetLength)).resolves.toMatchObject({
summary: expect.any(String),
inputLength: 4,
});
}
});
@@ -1159,8 +1162,10 @@ export function describeTtsProviderRuntimeContract() {
if (result.success) {
throw new Error("expected synthesis failure");
}
expect(result.error).toBeDefined();
const errorMessage = result.error ?? "";
const errorMessage = result.error;
if (typeof errorMessage !== "string") {
throw new Error("expected synthesis failure error message");
}
expect(errorMessage).toBe("TTS conversion failed: openai: provider failed");
expect(errorMessage).not.toContain("TTS conversion failed: TTS conversion failed:");
expect(errorMessage.match(/TTS conversion failed:/g)).toHaveLength(1);
@@ -1259,7 +1264,9 @@ export function describeTtsAutoApplyContract() {
if (params.expectSamePayload) {
expect(result).toBe(params.payload);
} else {
expect(result.mediaUrl).toBeDefined();
if (typeof result.mediaUrl !== "string" || result.mediaUrl.length === 0) {
throw new Error("expected auto TTS to attach mediaUrl");
}
}
});
}