()
| 151 | </html>`; |
| 152 | |
| 153 | const createMockCapServer = async () => { |
| 154 | const state: MockState = { |
| 155 | completeBodies: [], |
| 156 | progressBodies: [], |
| 157 | initiateBodies: [], |
| 158 | presignBodies: [], |
| 159 | uploadBytes: [], |
| 160 | uploadHeaders: [], |
| 161 | videoId: `e2e-${Date.now()}`, |
| 162 | }; |
| 163 | |
| 164 | const server = createServer(async (request, response) => { |
| 165 | const url = new URL(request.url ?? "/", "http://127.0.0.1"); |
| 166 | |
| 167 | if (request.method === "OPTIONS") { |
| 168 | sendJson(response, 204, {}); |
| 169 | return; |
| 170 | } |
| 171 | |
| 172 | try { |
| 173 | if (request.method === "GET" && url.pathname === "/capture.html") { |
| 174 | sendHtml(response, animatedCapturePage()); |
| 175 | return; |
| 176 | } |
| 177 | |
| 178 | if ( |
| 179 | request.method === "GET" && |
| 180 | url.pathname === "/api/extension/bootstrap" |
| 181 | ) { |
| 182 | sendJson(response, 200, { |
| 183 | user: { |
| 184 | id: "user-e2e", |
| 185 | email: "extension-e2e@cap.test", |
| 186 | }, |
| 187 | organization: { |
| 188 | id: "org-e2e", |
| 189 | name: "Extension E2E", |
| 190 | }, |
| 191 | plan: { |
| 192 | isPro: true, |
| 193 | maxRecordingSeconds: 600, |
| 194 | }, |
| 195 | }); |
| 196 | return; |
| 197 | } |
| 198 | |
| 199 | if ( |
| 200 | request.method === "POST" && |
| 201 | url.pathname === "/api/extension/instant-recordings" |
| 202 | ) { |
| 203 | await parseJsonBody(request); |
| 204 | sendJson(response, 200, { |
| 205 | id: state.videoId, |
| 206 | shareUrl: `${baseUrl()}/share/${state.videoId}`, |
| 207 | upload: { |
| 208 | type: "multipart", |
| 209 | }, |
| 210 | }); |
no test coverage detected