fix: accept zero-length Companion transcripts
This commit is contained in:
@@ -24168,6 +24168,18 @@ mod tests {
|
|||||||
|
|
||||||
let companion_transcript = get_json(app.clone(), "/api/companion/transcript").await;
|
let companion_transcript = get_json(app.clone(), "/api/companion/transcript").await;
|
||||||
assert_eq!(companion_transcript["total"], 0);
|
assert_eq!(companion_transcript["total"], 0);
|
||||||
|
let empty_window = get_json(app.clone(), "/api/companion/transcript?start=0&limit=0").await;
|
||||||
|
assert_eq!(
|
||||||
|
empty_window,
|
||||||
|
json!({
|
||||||
|
"state": "stopped",
|
||||||
|
"start": 0,
|
||||||
|
"limit": 0,
|
||||||
|
"total": 0,
|
||||||
|
"next": null,
|
||||||
|
"items": [],
|
||||||
|
})
|
||||||
|
);
|
||||||
|
|
||||||
let host_workers = get_json(app.clone(), &format!("/api/hosts/{host_id}/workers")).await;
|
let host_workers = get_json(app.clone(), &format!("/api/hosts/{host_id}/workers")).await;
|
||||||
assert!(
|
assert!(
|
||||||
|
|||||||
@@ -104,6 +104,24 @@ Deno.test("Companion transcript boundary accepts only bounded user-visible items
|
|||||||
],
|
],
|
||||||
};
|
};
|
||||||
assertEquals(parseCompanionTranscriptProjection(fixture), fixture);
|
assertEquals(parseCompanionTranscriptProjection(fixture), fixture);
|
||||||
|
assertEquals(
|
||||||
|
parseCompanionTranscriptProjection({
|
||||||
|
state: "stopped",
|
||||||
|
start: 0,
|
||||||
|
limit: 0,
|
||||||
|
total: 0,
|
||||||
|
next: null,
|
||||||
|
items: [],
|
||||||
|
}),
|
||||||
|
{
|
||||||
|
state: "stopped",
|
||||||
|
start: 0,
|
||||||
|
limit: 0,
|
||||||
|
total: 0,
|
||||||
|
next: null,
|
||||||
|
items: [],
|
||||||
|
},
|
||||||
|
);
|
||||||
|
|
||||||
assertThrows(
|
assertThrows(
|
||||||
() =>
|
() =>
|
||||||
|
|||||||
@@ -63,7 +63,7 @@ export function parseCompanionTranscriptProjection(
|
|||||||
]);
|
]);
|
||||||
const start = boundedInteger(record.start);
|
const start = boundedInteger(record.start);
|
||||||
const limit = boundedInteger(record.limit);
|
const limit = boundedInteger(record.limit);
|
||||||
if (limit < 1 || limit > MAX_TRANSCRIPT_ITEMS) {
|
if (limit > MAX_TRANSCRIPT_ITEMS) {
|
||||||
throw new TypeError("Companion transcript limit is out of range");
|
throw new TypeError("Companion transcript limit is out of range");
|
||||||
}
|
}
|
||||||
const items = boundedArray(record.items, limit).map(parseTranscriptItem);
|
const items = boundedArray(record.items, limit).map(parseTranscriptItem);
|
||||||
|
|||||||
Reference in New Issue
Block a user