Skip to content

Commit 4976e0e

Browse files
committed
test: add assembly status parity fixtures
1 parent 32f1c52 commit 4976e0e

3 files changed

Lines changed: 258 additions & 1 deletion

File tree

docs/todo.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,5 +65,5 @@
6565
## Zod v4 parity hardening
6666
- [x] Add runtime parity fixtures by copying proven Assembly Instructions from `~/code/content` (stepParsing fixtures)
6767
- [x] Add a sync-v4 regression fixture to verify `.passthrough()``.catchall(z.unknown())` and `z.record(...)` key injection
68-
- [ ] Add runtime parity coverage for `assemblyStatus` (ok/error/busy) once stable samples are selected
68+
- [x] Add runtime parity coverage for `assemblyStatus` (ok/error/busy) once stable samples are selected
6969
- [x] Add a CI guard that `@transloadit/zod` exports list stays in sync with `packages/node/src/alphalib/types`
Lines changed: 248 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,248 @@
1+
type AssemblyStatusFixture =
2+
| { name: string; value: unknown; valid: true }
3+
| { name: string; value: unknown; valid: false }
4+
5+
const assemblyStatusOk = {
6+
ok: 'ASSEMBLY_COMPLETED',
7+
http_code: 200,
8+
message: 'The Assembly was successfully completed.',
9+
assembly_id: '4723718834074932b22a59b209220018',
10+
parent_id: null,
11+
account_id: '4ce4fb3d9d1842b6ba5d6f3ccee4b066',
12+
account_name: 'examples-section-prod',
13+
account_slug: 'examples-section-prod',
14+
template_id: null,
15+
template_name: null,
16+
instance: 'spenge.transloadit.com',
17+
assembly_url: 'http://api2.spenge.transloadit.com/assemblies/4723718834074932b22a59b209220018',
18+
assembly_ssl_url:
19+
'https://api2-spenge.transloadit.com/assemblies/4723718834074932b22a59b209220018',
20+
uppyserver_url: 'https://api2-spenge.transloadit.com/companion/',
21+
companion_url: 'https://api2-spenge.transloadit.com/companion/',
22+
websocket_url: 'https://api2-spenge.transloadit.com/ws20008',
23+
update_stream_url:
24+
'https://api2-spenge.transloadit.com/ws20008?assembly=4723718834074932b22a59b209220018',
25+
tus_url: 'https://api2-spenge.transloadit.com/resumable/files/',
26+
bytes_received: 1113,
27+
bytes_expected: 1113,
28+
upload_duration: 0.325,
29+
client_agent: null,
30+
client_ip: null,
31+
client_referer: null,
32+
transloadit_client: 'node-sdk:3.0.2',
33+
start_date: '2023/12/20 16:36:27 GMT',
34+
upload_meta_data_extracted: true,
35+
warnings: [],
36+
is_infinite: false,
37+
has_dupe_jobs: false,
38+
execution_start: '2023/12/20 16:36:27 GMT',
39+
execution_duration: 1.399,
40+
queue_duration: 0.421,
41+
jobs_queue_duration: 0.04,
42+
notify_start: null,
43+
notify_url: null,
44+
notify_response_code: null,
45+
notify_response_data: null,
46+
notify_duration: null,
47+
last_job_completed: '2023/12/20 16:36:28 GMT',
48+
fields: {},
49+
running_jobs: [],
50+
bytes_usage: 1048639,
51+
executing_jobs: [],
52+
started_jobs: [':original:::original', 'converted:::original', 'exported:::original', 'exported::converted'],
53+
parent_assembly_status: null,
54+
params:
55+
'{"steps":{":original":{"robot":"/upload/handle"},"converted":{"use":":original","robot":"/document/convert","result":true,"format":"vtt"},"exported":{"use":["converted",":original"],"robot":"/s3/store","credentials":"demo_s3_credentials","url_prefix":"https://demos.transloadit.com/"}}, "auth":{"key":"****","expires":"2023-12-21T16:36:26.972Z"}}',
56+
template: null,
57+
merged_params:
58+
'{"steps":{":original":{"robot":"/upload/handle"},"converted":{"use":":original","robot":"/document/convert","result":true,"format":"vtt"},"exported":{"use":["converted",":original"],"robot":"/s3/store","credentials":"demo_s3_credentials","url_prefix":"https://demos.transloadit.com/"}}, "auth":{"key":"****","expires":"2023-12-21T16:36:26.972Z"}}',
59+
expected_tus_uploads: 1,
60+
started_tus_uploads: 1,
61+
finished_tus_uploads: 1,
62+
tus_uploads: [
63+
{
64+
filename: 'subtitle.srt',
65+
fieldname: 'file',
66+
size: 302,
67+
offset: 302,
68+
finished: true,
69+
upload_url: 'https://api2-buchen.transloadit.com/resumable/files/ab9753a6f59d0ef51b881a56004d9f14',
70+
},
71+
],
72+
uploads: [
73+
{
74+
id: '7e5ce0bb323044e7a9deeb7d6f6e312f',
75+
name: 'subtitle.srt',
76+
basename: 'subtitle',
77+
ext: 'srt',
78+
size: 302,
79+
mime: 'application/x-subrip',
80+
type: null,
81+
field: 'file',
82+
md5hash: '23664a1e4a8cad08d4ca6294d3d9bee3',
83+
original_id: '7e5ce0bb323044e7a9deeb7d6f6e312f',
84+
original_basename: 'subtitle',
85+
original_name: 'subtitle.srt',
86+
original_path: '/',
87+
original_md5hash: '23664a1e4a8cad08d4ca6294d3d9bee3',
88+
from_batch_import: false,
89+
is_tus_file: true,
90+
tus_upload_url: 'https://api2-buchen.transloadit.com/resumable/files/ab9753a6f59d0ef51b881a56004d9f14',
91+
url: 'https://demos.transloadit.com/7e/5ce0bb323044e7a9deeb7d6f6e312f/subtitle.srt',
92+
ssl_url: 'https://demos.transloadit.com/7e/5ce0bb323044e7a9deeb7d6f6e312f/subtitle.srt',
93+
meta: {},
94+
is_temp_url: false,
95+
},
96+
],
97+
results: {
98+
':original': [
99+
{
100+
id: '7e5ce0bb323044e7a9deeb7d6f6e312f',
101+
name: 'subtitle.srt',
102+
basename: 'subtitle',
103+
ext: 'srt',
104+
size: 302,
105+
mime: 'application/x-subrip',
106+
type: null,
107+
field: 'file',
108+
md5hash: '23664a1e4a8cad08d4ca6294d3d9bee3',
109+
original_id: '7e5ce0bb323044e7a9deeb7d6f6e312f',
110+
original_basename: 'subtitle',
111+
original_name: 'subtitle.srt',
112+
original_path: '/',
113+
original_md5hash: '23664a1e4a8cad08d4ca6294d3d9bee3',
114+
from_batch_import: false,
115+
is_tus_file: false,
116+
tus_upload_url: null,
117+
url: 'https://demos.transloadit.com/7e/5ce0bb323044e7a9deeb7d6f6e312f/subtitle.srt',
118+
ssl_url: 'https://demos.transloadit.com/7e/5ce0bb323044e7a9deeb7d6f6e312f/subtitle.srt',
119+
meta: {},
120+
is_temp_url: false,
121+
queue: 'live',
122+
queue_time: 0.02,
123+
exec_time: 0.43,
124+
cost: 61,
125+
},
126+
],
127+
converted: [
128+
{
129+
id: '5a6d14421bb9494b8b01edb4f674d767',
130+
name: 'subtitle.vtt',
131+
basename: 'subtitle',
132+
ext: 'vtt',
133+
size: 328,
134+
mime: 'text/vtt',
135+
type: null,
136+
field: 'file',
137+
md5hash: '30aabe4875747e49e1bc1be0ed2d7acb',
138+
original_id: '7e5ce0bb323044e7a9deeb7d6f6e312f',
139+
original_basename: 'subtitle',
140+
original_name: 'subtitle.srt',
141+
original_path: '/',
142+
original_md5hash: '23664a1e4a8cad08d4ca6294d3d9bee3',
143+
from_batch_import: false,
144+
is_tus_file: false,
145+
tus_upload_url: null,
146+
url: 'https://demos.transloadit.com/5a/6d14421bb9494b8b01edb4f674d767/subtitle.vtt',
147+
ssl_url: 'https://demos.transloadit.com/5a/6d14421bb9494b8b01edb4f674d767/subtitle.vtt',
148+
meta: {},
149+
is_temp_url: false,
150+
queue: 'live',
151+
queue_time: 0.02,
152+
exec_time: 0.47,
153+
cost: 1048576,
154+
},
155+
],
156+
},
157+
build_id: '7261900535',
158+
}
159+
160+
const assemblyStatusUploading = {
161+
ok: 'ASSEMBLY_UPLOADING',
162+
assembly_id: 'b841ea401e1a11e7b37d7bda1b503cdd',
163+
assembly_ssl_url: 'https://api2-freja.transloadit.com/assemblies/b841ea401e1a11e7b37d7bda1b503cdd',
164+
websocket_url: 'https://api2-freja.transloadit.com/ws20277',
165+
tus_url: 'https://api2-freja.transloadit.com/resumable/files/',
166+
expected_tus_uploads: 2,
167+
started_tus_uploads: 0,
168+
finished_tus_uploads: 0,
169+
}
170+
171+
const assemblyStatusExpired = {
172+
error: 'ASSEMBLY_EXPIRED',
173+
http_code: 200,
174+
message: 'The Assembly expired.',
175+
ok: null,
176+
assembly_id: '8b9dd2803eee11f0810ddf94e3864ef6',
177+
parent_id: null,
178+
account_id: '47c2abfc5ae1437ca330bc628dddd557',
179+
account_name: null,
180+
account_slug: null,
181+
api_auth_key_id: '5db01f1876a84a998b583f82b24eddf6',
182+
template_id: null,
183+
template_name: null,
184+
instance: 'u535up.transloadit.com',
185+
region: 'us-east-1',
186+
assembly_url: 'http://api2-u535up.transloadit.com/assemblies/8b9dd2803eee11f0810ddf94e3864ef6',
187+
assembly_ssl_url:
188+
'https://api2-u535up.transloadit.com/assemblies/8b9dd2803eee11f0810ddf94e3864ef6',
189+
uppyserver_url: 'https://api2-u535up.transloadit.com/companion/',
190+
companion_url: 'https://api2-u535up.transloadit.com/companion/',
191+
websocket_url: 'https://api2-u535up.transloadit.com/ws20011',
192+
update_stream_url:
193+
'https://api2-u535up.transloadit.com/ws20011?assembly=8b9dd2803eee11f0810ddf94e3864ef6',
194+
tus_url: 'https://api2-u535up.transloadit.com/resumable/files/',
195+
bytes_received: 0,
196+
bytes_expected: 0,
197+
upload_duration: 0.132,
198+
client_agent: null,
199+
client_ip: null,
200+
client_referer: null,
201+
start_date: '2025/06/01 13:44:31 GMT',
202+
upload_meta_data_extracted: false,
203+
warnings: [],
204+
is_infinite: false,
205+
has_dupe_jobs: false,
206+
execution_start: '2025-06-01T13:44:31.000Z',
207+
execution_duration: 28805.262,
208+
queue_duration: 0,
209+
jobs_queue_duration: 0,
210+
notify_start: null,
211+
notify_url: null,
212+
notify_response_code: null,
213+
notify_response_data: null,
214+
notify_duration: null,
215+
last_job_completed: null,
216+
fields: {},
217+
running_jobs: [],
218+
bytes_usage: 3024,
219+
usage_tags: '',
220+
executing_jobs: [],
221+
started_jobs: [],
222+
parent_assembly_status: null,
223+
params: null,
224+
template: null,
225+
merged_params: null,
226+
num_input_files: 0,
227+
uploads: [],
228+
results: {},
229+
build_id: '15302315784',
230+
}
231+
232+
export const assemblyStatusFixtures: AssemblyStatusFixture[] = [
233+
{
234+
name: 'demo-ok',
235+
value: assemblyStatusOk,
236+
valid: true,
237+
},
238+
{
239+
name: 'busy-uploading',
240+
value: assemblyStatusUploading,
241+
valid: true,
242+
},
243+
{
244+
name: 'expired-error',
245+
value: assemblyStatusExpired,
246+
valid: true,
247+
},
248+
]

packages/zod/test/runtime-parity.test.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,21 @@
11
import assert from 'node:assert/strict'
22

3+
import { assemblyStatusSchema as v3AssemblyStatus } from '../src/v3/assemblyStatus.ts'
34
import { assemblyInstructionsSchema as v3AssemblyInstructions } from '../src/v3/template.ts'
5+
import { assemblyStatusSchema as v4AssemblyStatus } from '../src/v4/assemblyStatus.ts'
46
import { assemblyInstructionsSchema as v4AssemblyInstructions } from '../src/v4/template.ts'
57
import { robotBase as v3RobotBase, robotFFmpeg as v3RobotFFmpeg } from '../src/v3/robots/_instructions-primitives.ts'
68
import { robotBase as v4RobotBase, robotFFmpeg as v4RobotFFmpeg } from '../src/v4/robots/_instructions-primitives.ts'
9+
import { assemblyStatusFixtures } from './fixtures/assembly-status.ts'
710
import { assemblyInstructionFixtures } from './fixtures/assembly-instructions.ts'
811

912
const schemas = [
13+
{
14+
name: 'assemblyStatus',
15+
v3: v3AssemblyStatus,
16+
v4: v4AssemblyStatus,
17+
fixtures: assemblyStatusFixtures,
18+
},
1019
{
1120
name: 'assemblyInstructions',
1221
v3: v3AssemblyInstructions,

0 commit comments

Comments
 (0)