Skip to content

armgit / Cap

Public Imported from GitHub
0

Open source Loom alternative. Beautiful, shareable screen recordings.

test(web): add mobile recording contract tests

Richie McIlroy8a3af90c7eca
diff --git a/apps/web/__tests__/unit/mobile-api-contract.test.ts b/apps/web/__tests__/unit/mobile-api-contract.test.ts
index 724e3f9df..5859794f3 100644
--- a/apps/web/__tests__/unit/mobile-api-contract.test.ts
+++ b/apps/web/__tests__/unit/mobile-api-contract.test.ts
@@ -204,4 +204,36 @@ describe("mobile API contract schemas", () => {
expect(playback.url).toContain("signed.example");
expect(upload.upload.type).toBe("put");
});
+
+ it("decodes segmented mobile recording contracts", () => {
+ const targets = Schema.decodeUnknownSync(
+ Mobile.MobileRecordingUploadTargetsResponse,
+ )({
+ uploads: {
+ "segments/video/init.mp4": {
+ type: "put",
+ url: "https://signed.example/init",
+ headers: { "Content-Type": "video/mp4" },
+ },
+ },
+ });
+ const complete = Schema.decodeUnknownSync(
+ Mobile.MobileRecordingCompleteInput,
+ )({
+ durationSeconds: 12.4,
+ totalBytes: 4_000_000,
+ videoSegments: [
+ { index: 1, duration: 2.02 },
+ { index: 2, duration: 1.98 },
+ ],
+ audioSegments: [
+ { index: 1, duration: 2 },
+ { index: 2, duration: 2 },
+ ],
+ });
+
+ expect(targets.uploads["segments/video/init.mp4"]?.type).toBe("put");
+ expect(complete.videoSegments).toHaveLength(2);
+ expect(complete.audioSegments).toHaveLength(2);
+ });
});