()
| 70 | </html>`; |
| 71 | |
| 72 | const createMockCapServer = async () => { |
| 73 | const requests: string[] = []; |
| 74 | const server = createServer(async (request, response) => { |
| 75 | const url = new URL(request.url ?? "/", "http://127.0.0.1"); |
| 76 | requests.push(`${request.method} ${url.pathname}`); |
| 77 | |
| 78 | if (request.method === "OPTIONS") { |
| 79 | sendJson(response, 204, {}); |
| 80 | return; |
| 81 | } |
| 82 | if (request.method === "GET" && url.pathname === "/capture.html") { |
| 83 | response.writeHead(200, { "Content-Type": "text/html; charset=utf-8" }); |
| 84 | response.end(capturePage()); |
| 85 | return; |
| 86 | } |
| 87 | if ( |
| 88 | request.method === "GET" && |
| 89 | url.pathname === "/api/extension/bootstrap" |
| 90 | ) { |
| 91 | sendJson(response, 200, { |
| 92 | user: { id: "user-e2e", email: "e2e@cap.test" }, |
| 93 | organization: { id: "org-e2e", name: "E2E" }, |
| 94 | plan: { isPro: true, maxRecordingSeconds: 600 }, |
| 95 | }); |
| 96 | return; |
| 97 | } |
| 98 | if ( |
| 99 | request.method === "POST" && |
| 100 | url.pathname === "/api/extension/instant-recordings" |
| 101 | ) { |
| 102 | await readRequestBody(request); |
| 103 | sendJson(response, 200, { |
| 104 | id: "video-repro", |
| 105 | shareUrl: `${origin}/share/video-repro`, |
| 106 | upload: { type: "multipart" }, |
| 107 | }); |
| 108 | return; |
| 109 | } |
| 110 | if ( |
| 111 | request.method === "POST" && |
| 112 | url.pathname === "/api/upload/multipart/initiate" |
| 113 | ) { |
| 114 | await readRequestBody(request); |
| 115 | sendJson(response, 200, { uploadId: "upload-repro", provider: "s3" }); |
| 116 | return; |
| 117 | } |
| 118 | if ( |
| 119 | request.method === "POST" && |
| 120 | url.pathname === "/api/upload/multipart/presign-part" |
| 121 | ) { |
| 122 | await readRequestBody(request); |
| 123 | sendJson(response, 200, { |
| 124 | presignedUrl: `${origin}/mock-s3/part`, |
| 125 | provider: "s3", |
| 126 | }); |
| 127 | return; |
| 128 | } |
| 129 | if (request.method === "PUT" && url.pathname.startsWith("/mock-s3/")) { |
no test coverage detected