@editframe/api 0.11.0-beta.9 → 0.12.0-beta.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/CHUNK_SIZE_BYTES.js +1 -1
- package/dist/ProgressIterator.d.ts +25 -0
- package/dist/ProgressIterator.js +99 -0
- package/dist/ProgressIterator.test.d.ts +1 -0
- package/dist/StreamEventSource.d.ts +50 -0
- package/dist/StreamEventSource.js +130 -0
- package/dist/StreamEventSource.test.d.ts +1 -0
- package/dist/client.d.ts +6 -3
- package/dist/client.js +20 -6
- package/dist/index.d.ts +7 -5
- package/dist/index.js +20 -11
- package/dist/readableFromBuffers.d.ts +1 -2
- package/dist/resources/caption-file.d.ts +7 -3
- package/dist/resources/caption-file.js +22 -2
- package/dist/resources/image-file.d.ts +7 -3
- package/dist/resources/image-file.js +19 -0
- package/dist/resources/isobmff-file.d.ts +16 -3
- package/dist/resources/isobmff-file.js +37 -2
- package/dist/resources/isobmff-track.d.ts +5 -7
- package/dist/resources/isobmff-track.js +44 -1
- package/dist/resources/process-isobmff.d.ts +12 -0
- package/dist/resources/process-isobmff.js +22 -0
- package/dist/resources/process-isobmff.test.d.ts +1 -0
- package/dist/resources/renders.d.ts +10 -5
- package/dist/resources/renders.js +21 -2
- package/dist/resources/transcriptions.d.ts +24 -0
- package/dist/resources/transcriptions.js +45 -0
- package/dist/resources/transcriptions.test.d.ts +1 -0
- package/dist/resources/unprocessed-file.d.ts +12 -53
- package/dist/resources/unprocessed-file.js +31 -130
- package/dist/streamChunker.d.ts +1 -2
- package/dist/streamChunker.js +20 -9
- package/dist/uploadChunks.d.ts +1 -2
- package/dist/uploadChunks.js +1 -4
- package/package.json +3 -2
- package/src/resources/caption-file.test.ts +57 -6
- package/src/resources/caption-file.ts +34 -5
- package/src/resources/image-file.test.ts +56 -5
- package/src/resources/image-file.ts +32 -4
- package/src/resources/isobmff-file.test.ts +57 -6
- package/src/resources/isobmff-file.ts +64 -5
- package/src/resources/isobmff-track.test.ts +3 -3
- package/src/resources/isobmff-track.ts +50 -5
- package/src/resources/process-isobmff.test.ts +62 -0
- package/src/resources/process-isobmff.ts +33 -0
- package/src/resources/renders.test.ts +51 -6
- package/src/resources/renders.ts +34 -5
- package/src/resources/transcriptions.test.ts +49 -0
- package/src/resources/transcriptions.ts +64 -0
- package/src/resources/unprocessed-file.test.ts +19 -430
- package/src/resources/unprocessed-file.ts +45 -161
|
@@ -1,27 +1,19 @@
|
|
|
1
|
-
import { join } from "node:path";
|
|
2
|
-
|
|
3
1
|
import { http, HttpResponse } from "msw";
|
|
4
2
|
import { setupServer } from "msw/node";
|
|
5
3
|
import { afterAll, afterEach, beforeAll, describe, expect, test } from "vitest";
|
|
6
4
|
import { ZodError } from "zod";
|
|
7
5
|
|
|
8
6
|
import { Client } from "../client.ts";
|
|
9
|
-
import {
|
|
7
|
+
import { webReadableFromBuffers } from "../readableFromBuffers.ts";
|
|
10
8
|
import {
|
|
11
9
|
createUnprocessedFile,
|
|
12
|
-
|
|
13
|
-
processAVFileBuffer,
|
|
14
|
-
processImageFile,
|
|
15
|
-
processImageFileBuffer,
|
|
16
|
-
updateUnprocessedFile,
|
|
10
|
+
lookupUnprocessedFileByMd5,
|
|
17
11
|
uploadUnprocessedFile,
|
|
18
12
|
} from "./unprocessed-file.ts";
|
|
19
13
|
|
|
20
14
|
const server = setupServer();
|
|
21
15
|
const client = new Client("ef_TEST_TOKEN", "http://localhost");
|
|
22
16
|
|
|
23
|
-
const TEST_AV_FILE = join(__dirname, "test-av-file.txt");
|
|
24
|
-
|
|
25
17
|
const UploadMustContinue = (id = "test-file") =>
|
|
26
18
|
http.get(`http://localhost/api/v1/unprocessed_files/${id}/upload`, () =>
|
|
27
19
|
HttpResponse.json({}, { status: 202 }),
|
|
@@ -38,7 +30,6 @@ describe("Unprocessed File", () => {
|
|
|
38
30
|
createUnprocessedFile(client, {
|
|
39
31
|
md5: "test-file",
|
|
40
32
|
filename: "test-file",
|
|
41
|
-
processes: [],
|
|
42
33
|
byte_size: 1024 * 1024 * 1025,
|
|
43
34
|
}),
|
|
44
35
|
).rejects.toThrowError(
|
|
@@ -67,7 +58,6 @@ describe("Unprocessed File", () => {
|
|
|
67
58
|
createUnprocessedFile(client, {
|
|
68
59
|
md5: "test-file",
|
|
69
60
|
filename: "test-file",
|
|
70
|
-
processes: [],
|
|
71
61
|
byte_size: 1024 * 1024,
|
|
72
62
|
}),
|
|
73
63
|
).rejects.toThrowError(
|
|
@@ -88,7 +78,6 @@ describe("Unprocessed File", () => {
|
|
|
88
78
|
const result = await createUnprocessedFile(client, {
|
|
89
79
|
md5: "test-file",
|
|
90
80
|
filename: "test-file",
|
|
91
|
-
processes: [],
|
|
92
81
|
byte_size: 1024 * 1024,
|
|
93
82
|
});
|
|
94
83
|
|
|
@@ -96,41 +85,6 @@ describe("Unprocessed File", () => {
|
|
|
96
85
|
});
|
|
97
86
|
});
|
|
98
87
|
|
|
99
|
-
describe("updateUnprocessedFile", () => {
|
|
100
|
-
test("Throws when server responds with an error", async () => {
|
|
101
|
-
server.use(
|
|
102
|
-
http.post("http://localhost/api/v1/unprocessed_files/test-file", () =>
|
|
103
|
-
HttpResponse.text("Internal Server Error", { status: 500 }),
|
|
104
|
-
),
|
|
105
|
-
);
|
|
106
|
-
|
|
107
|
-
await expect(
|
|
108
|
-
updateUnprocessedFile(client, "test-file", {
|
|
109
|
-
processes: [],
|
|
110
|
-
}),
|
|
111
|
-
).rejects.toThrowError(
|
|
112
|
-
"Failed to update unprocessed file 500 Internal Server Error",
|
|
113
|
-
);
|
|
114
|
-
});
|
|
115
|
-
|
|
116
|
-
test("Returns json data from the http response", async () => {
|
|
117
|
-
server.use(
|
|
118
|
-
http.post("http://localhost/api/v1/unprocessed_files/test-file", () =>
|
|
119
|
-
HttpResponse.json(
|
|
120
|
-
{ testResponse: "test" },
|
|
121
|
-
{ status: 200, statusText: "OK" },
|
|
122
|
-
),
|
|
123
|
-
),
|
|
124
|
-
);
|
|
125
|
-
|
|
126
|
-
const result = await updateUnprocessedFile(client, "test-file", {
|
|
127
|
-
processes: [],
|
|
128
|
-
});
|
|
129
|
-
|
|
130
|
-
expect(result).toEqual({ testResponse: "test" });
|
|
131
|
-
});
|
|
132
|
-
});
|
|
133
|
-
|
|
134
88
|
describe("uploadUnprocessedFile", () => {
|
|
135
89
|
test("Throws when server responds with an error", async () => {
|
|
136
90
|
server.use(
|
|
@@ -145,7 +99,7 @@ describe("Unprocessed File", () => {
|
|
|
145
99
|
uploadUnprocessedFile(
|
|
146
100
|
client,
|
|
147
101
|
"test-file",
|
|
148
|
-
|
|
102
|
+
webReadableFromBuffers(Buffer.from("test")),
|
|
149
103
|
4,
|
|
150
104
|
).whenUploaded(),
|
|
151
105
|
).rejects.toThrowError(
|
|
@@ -166,7 +120,7 @@ describe("Unprocessed File", () => {
|
|
|
166
120
|
uploadUnprocessedFile(
|
|
167
121
|
client,
|
|
168
122
|
"test-file",
|
|
169
|
-
|
|
123
|
+
webReadableFromBuffers(Buffer.from("test")),
|
|
170
124
|
4,
|
|
171
125
|
).whenUploaded(),
|
|
172
126
|
).resolves.toEqual([
|
|
@@ -176,408 +130,43 @@ describe("Unprocessed File", () => {
|
|
|
176
130
|
});
|
|
177
131
|
});
|
|
178
132
|
|
|
179
|
-
describe("
|
|
180
|
-
test("
|
|
181
|
-
server.use(
|
|
182
|
-
UploadMustContinue(),
|
|
183
|
-
http.post("http://localhost/api/v1/unprocessed_files", () =>
|
|
184
|
-
HttpResponse.text("Internal Server Error", { status: 500 }),
|
|
185
|
-
),
|
|
186
|
-
);
|
|
187
|
-
|
|
188
|
-
await expect(
|
|
189
|
-
processAVFileBuffer(client, Buffer.from("test"), "test-file").file(),
|
|
190
|
-
).rejects.toThrowError(
|
|
191
|
-
"Failed to create unprocessed file 500 Internal Server Error",
|
|
192
|
-
);
|
|
193
|
-
});
|
|
194
|
-
|
|
195
|
-
test("Throws when server responds with an error when uploading file", async () => {
|
|
196
|
-
server.use(
|
|
197
|
-
http.post("http://localhost/api/v1/unprocessed_files", () =>
|
|
198
|
-
HttpResponse.json(
|
|
199
|
-
{
|
|
200
|
-
complete: false,
|
|
201
|
-
id: "098f6bcd-4621-d373-cade-4e832627b4f6",
|
|
202
|
-
processes: [],
|
|
203
|
-
},
|
|
204
|
-
{ status: 200 },
|
|
205
|
-
),
|
|
206
|
-
),
|
|
207
|
-
UploadMustContinue("098f6bcd-4621-d373-cade-4e832627b4f6"),
|
|
208
|
-
http.post(
|
|
209
|
-
"http://localhost/api/v1/unprocessed_files/098f6bcd-4621-d373-cade-4e832627b4f6/upload",
|
|
210
|
-
() => HttpResponse.text("Internal Server Error", { status: 500 }),
|
|
211
|
-
),
|
|
212
|
-
);
|
|
213
|
-
|
|
214
|
-
await expect(
|
|
215
|
-
processAVFileBuffer(client, Buffer.from("test"), "test-file").file(),
|
|
216
|
-
).rejects.toThrowError(
|
|
217
|
-
"Failed to upload chunk 0 for /api/v1/unprocessed_files/098f6bcd-4621-d373-cade-4e832627b4f6/upload 500 Internal Server Error",
|
|
218
|
-
);
|
|
219
|
-
});
|
|
220
|
-
|
|
221
|
-
test("Throws when server responds with an error when updating file", async () => {
|
|
222
|
-
server.use(
|
|
223
|
-
http.post("http://localhost/api/v1/unprocessed_files", () =>
|
|
224
|
-
HttpResponse.json(
|
|
225
|
-
{
|
|
226
|
-
complete: false,
|
|
227
|
-
id: "098f6bcd-4621-d373-cade-4e832627b4f6",
|
|
228
|
-
processes: [],
|
|
229
|
-
},
|
|
230
|
-
{ status: 200 },
|
|
231
|
-
),
|
|
232
|
-
),
|
|
233
|
-
UploadMustContinue("098f6bcd-4621-d373-cade-4e832627b4f6"),
|
|
234
|
-
http.post(
|
|
235
|
-
"http://localhost/api/v1/unprocessed_files/098f6bcd-4621-d373-cade-4e832627b4f6/upload",
|
|
236
|
-
() => HttpResponse.json({ test }, { status: 201 }),
|
|
237
|
-
),
|
|
238
|
-
http.post(
|
|
239
|
-
"http://localhost/api/v1/unprocessed_files/098f6bcd-4621-d373-cade-4e832627b4f6",
|
|
240
|
-
() => HttpResponse.text("Internal Server Error", { status: 500 }),
|
|
241
|
-
),
|
|
242
|
-
);
|
|
243
|
-
|
|
244
|
-
await expect(
|
|
245
|
-
processAVFileBuffer(client, Buffer.from("test"), "test-file").file(),
|
|
246
|
-
).rejects.toThrowError(
|
|
247
|
-
"Failed to update unprocessed file 500 Internal Server Error",
|
|
248
|
-
);
|
|
249
|
-
});
|
|
250
|
-
|
|
251
|
-
test("Returns json data when upload is successful", async () => {
|
|
252
|
-
server.use(
|
|
253
|
-
http.post("http://localhost/api/v1/unprocessed_files", () =>
|
|
254
|
-
HttpResponse.json(
|
|
255
|
-
{
|
|
256
|
-
complete: false,
|
|
257
|
-
id: "098f6bcd-4621-d373-cade-4e832627b4f6",
|
|
258
|
-
processes: [],
|
|
259
|
-
},
|
|
260
|
-
{ status: 200 },
|
|
261
|
-
),
|
|
262
|
-
),
|
|
263
|
-
UploadMustContinue("098f6bcd-4621-d373-cade-4e832627b4f6"),
|
|
264
|
-
http.post(
|
|
265
|
-
"http://localhost/api/v1/unprocessed_files/098f6bcd-4621-d373-cade-4e832627b4f6/upload",
|
|
266
|
-
() => HttpResponse.json({}, { status: 201 }),
|
|
267
|
-
),
|
|
268
|
-
http.post(
|
|
269
|
-
"http://localhost/api/v1/unprocessed_files/098f6bcd-4621-d373-cade-4e832627b4f6",
|
|
270
|
-
() => HttpResponse.json({ test: "response" }, { status: 200 }),
|
|
271
|
-
),
|
|
272
|
-
);
|
|
273
|
-
|
|
274
|
-
await expect(
|
|
275
|
-
processAVFileBuffer(client, Buffer.from("test"), "test-file").file(),
|
|
276
|
-
).resolves.toEqual({ test: "response" });
|
|
277
|
-
});
|
|
278
|
-
});
|
|
279
|
-
|
|
280
|
-
describe("processAVFile", () => {
|
|
281
|
-
test("Throws when server responds with an error when creating file", async () => {
|
|
282
|
-
server.use(
|
|
283
|
-
http.post("http://localhost/api/v1/unprocessed_files", () =>
|
|
284
|
-
HttpResponse.text("Internal Server Error", { status: 500 }),
|
|
285
|
-
),
|
|
286
|
-
);
|
|
287
|
-
|
|
288
|
-
await expect(
|
|
289
|
-
processAVFile(client, TEST_AV_FILE).file(),
|
|
290
|
-
).rejects.toThrowError(
|
|
291
|
-
"Failed to create unprocessed file 500 Internal Server Error",
|
|
292
|
-
);
|
|
293
|
-
});
|
|
294
|
-
|
|
295
|
-
test("Throws when server responds with an error when uploading file", async () => {
|
|
296
|
-
server.use(
|
|
297
|
-
http.post("http://localhost/api/v1/unprocessed_files", () =>
|
|
298
|
-
HttpResponse.json(
|
|
299
|
-
{
|
|
300
|
-
complete: false,
|
|
301
|
-
id: "098f6bcd-4621-d373-cade-4e832627b4f6",
|
|
302
|
-
processes: [],
|
|
303
|
-
},
|
|
304
|
-
{ status: 200 },
|
|
305
|
-
),
|
|
306
|
-
),
|
|
307
|
-
UploadMustContinue("098f6bcd-4621-d373-cade-4e832627b4f6"),
|
|
308
|
-
http.post(
|
|
309
|
-
"http://localhost/api/v1/unprocessed_files/098f6bcd-4621-d373-cade-4e832627b4f6/upload",
|
|
310
|
-
() => HttpResponse.text("Internal Server Error", { status: 500 }),
|
|
311
|
-
),
|
|
312
|
-
);
|
|
313
|
-
|
|
314
|
-
await expect(
|
|
315
|
-
processAVFile(client, TEST_AV_FILE).file(),
|
|
316
|
-
).rejects.toThrowError(
|
|
317
|
-
"Failed to upload chunk 0 for /api/v1/unprocessed_files/098f6bcd-4621-d373-cade-4e832627b4f6/upload 500 Internal Server Error",
|
|
318
|
-
);
|
|
319
|
-
});
|
|
320
|
-
|
|
321
|
-
test("Throws when server responds with an error when updating file", async () => {
|
|
322
|
-
server.use(
|
|
323
|
-
http.post("http://localhost/api/v1/unprocessed_files", () =>
|
|
324
|
-
HttpResponse.json(
|
|
325
|
-
{
|
|
326
|
-
complete: false,
|
|
327
|
-
id: "098f6bcd-4621-d373-cade-4e832627b4f6",
|
|
328
|
-
processes: [],
|
|
329
|
-
},
|
|
330
|
-
{ status: 200 },
|
|
331
|
-
),
|
|
332
|
-
),
|
|
333
|
-
UploadMustContinue("098f6bcd-4621-d373-cade-4e832627b4f6"),
|
|
334
|
-
http.post(
|
|
335
|
-
"http://localhost/api/v1/unprocessed_files/098f6bcd-4621-d373-cade-4e832627b4f6/upload",
|
|
336
|
-
() => HttpResponse.json({ test }, { status: 201 }),
|
|
337
|
-
),
|
|
338
|
-
http.post(
|
|
339
|
-
"http://localhost/api/v1/unprocessed_files/098f6bcd-4621-d373-cade-4e832627b4f6",
|
|
340
|
-
() => HttpResponse.text("Internal Server Error", { status: 500 }),
|
|
341
|
-
),
|
|
342
|
-
);
|
|
343
|
-
|
|
344
|
-
await expect(
|
|
345
|
-
processAVFile(client, TEST_AV_FILE).file(),
|
|
346
|
-
).rejects.toThrowError(
|
|
347
|
-
"Failed to update unprocessed file 500 Internal Server Error",
|
|
348
|
-
);
|
|
349
|
-
});
|
|
350
|
-
|
|
351
|
-
test("Returns json data when upload is successful", async () => {
|
|
352
|
-
server.use(
|
|
353
|
-
http.post("http://localhost/api/v1/unprocessed_files", () =>
|
|
354
|
-
HttpResponse.json(
|
|
355
|
-
{
|
|
356
|
-
complete: false,
|
|
357
|
-
id: "098f6bcd-4621-d373-cade-4e832627b4f6",
|
|
358
|
-
processes: [],
|
|
359
|
-
},
|
|
360
|
-
{ status: 200 },
|
|
361
|
-
),
|
|
362
|
-
),
|
|
363
|
-
UploadMustContinue("098f6bcd-4621-d373-cade-4e832627b4f6"),
|
|
364
|
-
http.post(
|
|
365
|
-
"http://localhost/api/v1/unprocessed_files/098f6bcd-4621-d373-cade-4e832627b4f6/upload",
|
|
366
|
-
() => HttpResponse.json({}, { status: 201 }),
|
|
367
|
-
),
|
|
368
|
-
http.post(
|
|
369
|
-
"http://localhost/api/v1/unprocessed_files/098f6bcd-4621-d373-cade-4e832627b4f6",
|
|
370
|
-
() => HttpResponse.json({ test: "response" }, { status: 200 }),
|
|
371
|
-
),
|
|
372
|
-
);
|
|
373
|
-
|
|
374
|
-
await expect(processAVFile(client, TEST_AV_FILE).file()).resolves.toEqual(
|
|
375
|
-
{
|
|
376
|
-
test: "response",
|
|
377
|
-
},
|
|
378
|
-
);
|
|
379
|
-
});
|
|
380
|
-
});
|
|
381
|
-
|
|
382
|
-
describe("processImageFileBuffer", () => {
|
|
383
|
-
test("Throws when server responds with an error when creating file", async () => {
|
|
133
|
+
describe("lookupUnprocessedFileByMd5", () => {
|
|
134
|
+
test("Returns json data from the http response", async () => {
|
|
384
135
|
server.use(
|
|
385
|
-
http.
|
|
386
|
-
HttpResponse.
|
|
136
|
+
http.get("http://localhost/api/v1/unprocessed_files/md5/test-md5", () =>
|
|
137
|
+
HttpResponse.json({ test: "response" }, { status: 200 }),
|
|
387
138
|
),
|
|
388
139
|
);
|
|
389
140
|
|
|
390
|
-
await
|
|
391
|
-
processImageFileBuffer(client, Buffer.from("test"), "test-file").file(),
|
|
392
|
-
).rejects.toThrowError(
|
|
393
|
-
"Failed to create unprocessed file 500 Internal Server Error",
|
|
394
|
-
);
|
|
395
|
-
});
|
|
396
|
-
|
|
397
|
-
test("Throws when server responds with an error when uploading file", async () => {
|
|
398
|
-
server.use(
|
|
399
|
-
http.post("http://localhost/api/v1/unprocessed_files", () =>
|
|
400
|
-
HttpResponse.json(
|
|
401
|
-
{
|
|
402
|
-
complete: false,
|
|
403
|
-
id: "098f6bcd-4621-d373-cade-4e832627b4f6",
|
|
404
|
-
processes: [],
|
|
405
|
-
},
|
|
406
|
-
{ status: 200 },
|
|
407
|
-
),
|
|
408
|
-
),
|
|
409
|
-
UploadMustContinue("098f6bcd-4621-d373-cade-4e832627b4f6"),
|
|
410
|
-
http.post(
|
|
411
|
-
"http://localhost/api/v1/unprocessed_files/098f6bcd-4621-d373-cade-4e832627b4f6/upload",
|
|
412
|
-
() => HttpResponse.text("Internal Server Error", { status: 500 }),
|
|
413
|
-
),
|
|
414
|
-
);
|
|
141
|
+
const response = await lookupUnprocessedFileByMd5(client, "test-md5");
|
|
415
142
|
|
|
416
|
-
|
|
417
|
-
processImageFileBuffer(client, Buffer.from("test"), "test-file").file(),
|
|
418
|
-
).rejects.toThrowError(
|
|
419
|
-
"Failed to upload chunk 0 for /api/v1/unprocessed_files/098f6bcd-4621-d373-cade-4e832627b4f6/upload 500 Internal Server Error",
|
|
420
|
-
);
|
|
143
|
+
expect(response).toEqual({ test: "response" });
|
|
421
144
|
});
|
|
422
145
|
|
|
423
|
-
test("
|
|
146
|
+
test("Returns null when file is not found", async () => {
|
|
424
147
|
server.use(
|
|
425
|
-
http.
|
|
426
|
-
HttpResponse.json(
|
|
427
|
-
{
|
|
428
|
-
complete: false,
|
|
429
|
-
id: "098f6bcd-4621-d373-cade-4e832627b4f6",
|
|
430
|
-
processes: [],
|
|
431
|
-
},
|
|
432
|
-
{ status: 200 },
|
|
433
|
-
),
|
|
434
|
-
),
|
|
435
|
-
UploadMustContinue("098f6bcd-4621-d373-cade-4e832627b4f6"),
|
|
436
|
-
http.post(
|
|
437
|
-
"http://localhost/api/v1/unprocessed_files/098f6bcd-4621-d373-cade-4e832627b4f6/upload",
|
|
438
|
-
() => HttpResponse.json({ test }, { status: 201 }),
|
|
439
|
-
),
|
|
440
|
-
http.post(
|
|
441
|
-
"http://localhost/api/v1/unprocessed_files/098f6bcd-4621-d373-cade-4e832627b4f6",
|
|
442
|
-
() => HttpResponse.text("Internal Server Error", { status: 500 }),
|
|
148
|
+
http.get("http://localhost/api/v1/unprocessed_files/md5/test-md5", () =>
|
|
149
|
+
HttpResponse.json({}, { status: 404 }),
|
|
443
150
|
),
|
|
444
151
|
);
|
|
445
152
|
|
|
446
|
-
await
|
|
447
|
-
processImageFileBuffer(client, Buffer.from("test"), "test-file").file(),
|
|
448
|
-
).rejects.toThrowError(
|
|
449
|
-
"Failed to update unprocessed file 500 Internal Server Error",
|
|
450
|
-
);
|
|
451
|
-
});
|
|
452
|
-
|
|
453
|
-
test("Returns json data when upload is successful", async () => {
|
|
454
|
-
server.use(
|
|
455
|
-
http.post("http://localhost/api/v1/unprocessed_files", () =>
|
|
456
|
-
HttpResponse.json(
|
|
457
|
-
{
|
|
458
|
-
complete: false,
|
|
459
|
-
id: "098f6bcd-4621-d373-cade-4e832627b4f6",
|
|
460
|
-
processes: [],
|
|
461
|
-
},
|
|
462
|
-
{ status: 200 },
|
|
463
|
-
),
|
|
464
|
-
),
|
|
465
|
-
UploadMustContinue("098f6bcd-4621-d373-cade-4e832627b4f6"),
|
|
466
|
-
http.post(
|
|
467
|
-
"http://localhost/api/v1/unprocessed_files/098f6bcd-4621-d373-cade-4e832627b4f6/upload",
|
|
468
|
-
() => HttpResponse.json({}, { status: 201 }),
|
|
469
|
-
),
|
|
470
|
-
http.post(
|
|
471
|
-
"http://localhost/api/v1/unprocessed_files/098f6bcd-4621-d373-cade-4e832627b4f6",
|
|
472
|
-
() => HttpResponse.json({ test: "response" }, { status: 200 }),
|
|
473
|
-
),
|
|
474
|
-
);
|
|
153
|
+
const response = await lookupUnprocessedFileByMd5(client, "test-md5");
|
|
475
154
|
|
|
476
|
-
|
|
477
|
-
processImageFileBuffer(client, Buffer.from("test"), "test-file").file(),
|
|
478
|
-
).resolves.toEqual({ test: "response" });
|
|
155
|
+
expect(response).toBeNull();
|
|
479
156
|
});
|
|
480
|
-
});
|
|
481
157
|
|
|
482
|
-
|
|
483
|
-
test("Throws when server responds with an error when creating file", async () => {
|
|
158
|
+
test("Throws when server returns an error", async () => {
|
|
484
159
|
server.use(
|
|
485
|
-
http.
|
|
160
|
+
http.get("http://localhost/api/v1/unprocessed_files/md5/test-md5", () =>
|
|
486
161
|
HttpResponse.text("Internal Server Error", { status: 500 }),
|
|
487
162
|
),
|
|
488
163
|
);
|
|
489
164
|
|
|
490
165
|
await expect(
|
|
491
|
-
|
|
492
|
-
).rejects.toThrowError(
|
|
493
|
-
"Failed to create unprocessed file 500 Internal Server Error",
|
|
494
|
-
);
|
|
495
|
-
});
|
|
496
|
-
|
|
497
|
-
test("Throws when server responds with an error when uploading file", async () => {
|
|
498
|
-
server.use(
|
|
499
|
-
http.post("http://localhost/api/v1/unprocessed_files", () =>
|
|
500
|
-
HttpResponse.json(
|
|
501
|
-
{
|
|
502
|
-
complete: false,
|
|
503
|
-
id: "098f6bcd-4621-d373-cade-4e832627b4f6",
|
|
504
|
-
processes: [],
|
|
505
|
-
},
|
|
506
|
-
{ status: 200 },
|
|
507
|
-
),
|
|
508
|
-
),
|
|
509
|
-
UploadMustContinue("098f6bcd-4621-d373-cade-4e832627b4f6"),
|
|
510
|
-
http.post(
|
|
511
|
-
"http://localhost/api/v1/unprocessed_files/098f6bcd-4621-d373-cade-4e832627b4f6/upload",
|
|
512
|
-
() => HttpResponse.text("Internal Server Error", { status: 500 }),
|
|
513
|
-
),
|
|
514
|
-
);
|
|
515
|
-
|
|
516
|
-
await expect(
|
|
517
|
-
processImageFile(client, TEST_AV_FILE).file(),
|
|
518
|
-
).rejects.toThrowError(
|
|
519
|
-
"Failed to upload chunk 0 for /api/v1/unprocessed_files/098f6bcd-4621-d373-cade-4e832627b4f6/upload 500 Internal Server Error",
|
|
520
|
-
);
|
|
521
|
-
});
|
|
522
|
-
|
|
523
|
-
test("Throws when server responds with an error when updating file", async () => {
|
|
524
|
-
server.use(
|
|
525
|
-
http.post("http://localhost/api/v1/unprocessed_files", () =>
|
|
526
|
-
HttpResponse.json(
|
|
527
|
-
{
|
|
528
|
-
complete: false,
|
|
529
|
-
id: "098f6bcd-4621-d373-cade-4e832627b4f6",
|
|
530
|
-
processes: [],
|
|
531
|
-
},
|
|
532
|
-
{ status: 200 },
|
|
533
|
-
),
|
|
534
|
-
),
|
|
535
|
-
UploadMustContinue("098f6bcd-4621-d373-cade-4e832627b4f6"),
|
|
536
|
-
http.post(
|
|
537
|
-
"http://localhost/api/v1/unprocessed_files/098f6bcd-4621-d373-cade-4e832627b4f6/upload",
|
|
538
|
-
() => HttpResponse.json({ test }, { status: 201 }),
|
|
539
|
-
),
|
|
540
|
-
http.post(
|
|
541
|
-
"http://localhost/api/v1/unprocessed_files/098f6bcd-4621-d373-cade-4e832627b4f6",
|
|
542
|
-
() => HttpResponse.text("Internal Server Error", { status: 500 }),
|
|
543
|
-
),
|
|
544
|
-
);
|
|
545
|
-
|
|
546
|
-
await expect(
|
|
547
|
-
processImageFile(client, TEST_AV_FILE).file(),
|
|
166
|
+
lookupUnprocessedFileByMd5(client, "test-md5"),
|
|
548
167
|
).rejects.toThrowError(
|
|
549
|
-
"Failed to
|
|
168
|
+
"Failed to lookup unprocessed file by md5 test-md5 500 Internal Server Error",
|
|
550
169
|
);
|
|
551
170
|
});
|
|
552
|
-
|
|
553
|
-
test("Returns json data when upload is successful", async () => {
|
|
554
|
-
server.use(
|
|
555
|
-
http.post("http://localhost/api/v1/unprocessed_files", () =>
|
|
556
|
-
HttpResponse.json(
|
|
557
|
-
{
|
|
558
|
-
complete: false,
|
|
559
|
-
id: "098f6bcd-4621-d373-cade-4e832627b4f6",
|
|
560
|
-
processes: [],
|
|
561
|
-
},
|
|
562
|
-
{ status: 200 },
|
|
563
|
-
),
|
|
564
|
-
),
|
|
565
|
-
UploadMustContinue("098f6bcd-4621-d373-cade-4e832627b4f6"),
|
|
566
|
-
http.post(
|
|
567
|
-
"http://localhost/api/v1/unprocessed_files/098f6bcd-4621-d373-cade-4e832627b4f6/upload",
|
|
568
|
-
() => HttpResponse.json({}, { status: 201 }),
|
|
569
|
-
),
|
|
570
|
-
http.post(
|
|
571
|
-
"http://localhost/api/v1/unprocessed_files/098f6bcd-4621-d373-cade-4e832627b4f6",
|
|
572
|
-
() => HttpResponse.json({ test: "response" }, { status: 200 }),
|
|
573
|
-
),
|
|
574
|
-
);
|
|
575
|
-
|
|
576
|
-
await expect(
|
|
577
|
-
processImageFile(client, TEST_AV_FILE).file(),
|
|
578
|
-
).resolves.toEqual({
|
|
579
|
-
test: "response",
|
|
580
|
-
});
|
|
581
|
-
});
|
|
582
171
|
});
|
|
583
172
|
});
|