Repository navigation
Expand file tree
/
Copy pathcycle.spec.ts
More file actions
2077 lines (1927 loc) · 113 KB
/
Copy pathcycle.spec.ts
File metadata and controls
2077 lines (1927 loc) · 113 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
/**
* The whole cycle, in a browser, against a real server.
*
* Token → project → schema → ingest → approve → annotate → complete → promote →
* publish → export → download. No mocks anywhere: the bundle is the built one that
* ships in the wheel, and `visionset server` serves it beside the real API over the
* real kernel.
*
* ## One test, and that is deliberate
*
* Every step needs the last one's output — there is no project to ingest into and
* no batch to approve until earlier steps ran — and Playwright gives each test its
* own page and its own everything. Splitting this into ten tests would mean either
* ten sign-ins walking back through the product, or shared module state that makes
* the order load-bearing and invisible. `test.step` gives the reporting a
* multi-test file would have bought, without the lie.
*
* ## What it deliberately does not do
*
* **The source is images, not a video.** The issue says "generated video"; video is
* now a browser capability rather than a server one, so the two paths no longer share
* a pipeline to sample here at all. Decoding is covered where it happens —
* `@visionset/media`'s own Chromium suite and the ingest screen's component tests —
* and the whole browser-to-batch walk has its own spec. Buying a real decode inside
* this five-minute budget would re-test that for coverage that already exists.
* Recorded rather than skipped quietly.
*
* **The export is addressed to a target, and the archive is opened.** The release
* holds a box, a polygon and a polyline; `yolo11` takes the first two and drops the
* third, so the walk meets the real lossy consent — the sentence naming the target
* and the count — before the archive arrives, and then reads `data.yaml` out of
* the download to see the class map the trainer would.
*
* **And once more through a pre-processing recipe.** Written from the release's
* Export section in the recipe's modal, and chosen there; the second archive is opened
* for the report that names the recipe under its hash and for the train
* fold's augmented variant beside its source.
*/
import { expect, test, type Download, type Locator, type Page, type Request, type TestInfo } from "@playwright/test";
import { readFileSync } from "node:fs";
import { closeReview, expectPinnedSchema, focusCanvas, openInfo, openReview, openReviewAll, reviewMove, reviewTile, saveNow } from "../e2e/_frame";
import {
activate,
closeTags,
images,
openBatch,
openProject,
openTags,
putAwayPanel,
token,
zipEntries,
zipEntry,
} from "./_walk";
import { emptyWorkspace } from "./_workspace";
import { expectSection, openSection } from "../e2e/_sections";
const TAG = "v1";
/** The recipe the walk writes, named on the second export and in its report. */
const RECIPE = "yolo-640";
/**
* The reserved model id that resolves to this build's own no-op segmenter.
*
* Spelled here rather than imported from the Python that defines it, because
* that string is a contract between the two halves and a suite importing it
* from one of them could never notice the two disagreeing. `test_stub_provider`
* holds the other end.
*/
const STUB_MODEL_ID = "visionset/stub-segmenter";
/** What the connection is called on screen, so a refusal can be read. */
const STAND_IN = "built-in stand-in";
/**
* What the same connection is called after the walk edits it.
*
* A second constant rather than a literal at the call site, because a rename
* moves two test ids at once — the connection's row is `connection-{name}` and the
* name that opens its sheet is `open-{name}` — so the new name is read in three places and a
* typo in one of them fails as a timeout rather than as a mismatch.
*/
const REPINNED = "built-in stand-in, repinned";
/**
* A project name nothing else in the workspace will collide with — **including
* this same spec on another repetition**.
*
* A project name is unique per workspace, case-insensitively, and a fixed
* literal here used to make `--repeat-each` useless: the workspace outlived a
* repetition, so repeat 2 died on `POST /projects → 409` before reaching
* anything the suite is about. The connection name had the same problem one
* screen later and nobody had noticed it, which is the argument against curing
* a collision one name at a time.
*
* Neither needs curing now. Every attempt begins on an empty workspace — see
* the `beforeEach` below — so no name in this walk collides with a name from
* another attempt, and none of them has to move.
*
* The suffix stays anyway, and is unconditional, because it costs nothing and
* it makes a failure message name the attempt it came from. That is worth more
* now than it was: a retry can finally produce a second, *different* failure,
* and two reports that name the same project are two reports somebody has to
* tell apart by hand.
*/
function projectFor(info: TestInfo): string {
return `browser-cycle-${info.repeatEachIndex}-${info.retry}`;
}
/**
* Every attempt starts on an empty workspace — a retry included, and every
* repetition of `--repeat-each`.
*
* On the first attempt of a freshly built workspace this deletes nothing and
* costs two reads. It exists for the second: the workspace is rebuilt once per
* *server* start, not once per attempt, so without this a retry inherits the
* previous attempt's projects and dies on the project list's empty state — an
* assertion about the workspace, three steps in, unrelated to whatever actually
* failed.
*
* Unconditional rather than guarded on `retry`, because a repair that only runs
* on the rare attempt has the same property as the defect it repairs: nothing
* exercises it until the day it matters. Run every time, its two reads are
* proved by every run of this suite.
*/
test.beforeEach(async ({ request }) => {
await emptyWorkspace(request, token());
});
test("the whole cycle, from opening the app to a downloaded export", async ({ page, request }, info) => {
test.slow();
const PROJECT = projectFor(info);
/*
* The project is made through the API, before the app opens. New project in the
* browser no longer makes an empty project: it asks for the classes, the files
* and the batch in one go, and `new-project.spec.ts` walks it against this same
* server. This walk is about what comes after — the schema editor's empty
* draft, Add images, the batch — so it starts from the empty project that
* dialog would never leave behind.
*/
const created = await request.post("/projects", {
headers: { Authorization: `Bearer ${token()}` },
data: { name: PROJECT, description: "Driven by #59" },
});
expect(created.ok(), `POST /projects answered ${created.status()}`).toBe(true);
// Collected across the whole walk rather than
// asserted at one moment: a clean load should produce **zero** console errors and
// no failed request, and the only one there had been was the browser asking for
// `/favicon.ico` unprompted and the API root correctly answering 404.
//
// Both halves are needed. `console` catches what the page complains about;
// `requestfailed` and a 404 sweep catch the case where a browser fetches
// something on its own initiative and says nothing — which is exactly what a
// missing icon does in a headless run.
const consoleErrors: string[] = [];
const badRequests: string[] = [];
// Every API call the *app* made that the API refused, exempted from the
// console assertion because the walk contains refused calls by design —
// `GET /projects/{id}/schema` answers 404 for a project that has no schema
// yet, which is how the editor knows to open on an empty draft — and Chrome
// logs a console error for each; a resource the *browser* went looking for
// on its own still stands out. The set is keyed by URL because that is what
// a console message's location carries; the list is keyed by route and
// status because that is what a person can check, and it is pinned in the
// final step. Without the list the exemption is unbounded: any route, any
// status, silently tolerated.
const apiRefusals = new Set<string>();
const refusedApiCalls: string[] = [];
// Requests the *app* issued that the network stack reported as aborted.
// Asserted rather than ignored — see the final step for why they are not
// `badRequests` and what the one expected member of this list is.
const abortedApiCalls: string[] = [];
// Whether the curated model's size could be read on *this* installation, taken
// from what the form actually rendered. The probe reaches a hub through the
// optional local-inference runtime, so it answers 500 on an installation
// without it and 200 on one with it — and both are the product working. Read
// rather than assumed, because the two inference CI jobs install differently
// and a developer's machine matches neither.
let curatedSizeRefused = false;
// The job's own address, noted while it is reached by clicking. A *finished* job's card in
// the batch panel says "Done" and has no door, so the viewer a completed batch reopens as is
// reached by address alone; the road in is still the one the app itself produced.
let jobAddress = "";
// The app's calls still in flight. A reload or a typed address tears down
// whatever the page is reading or writing, and the aborted list below pins
// every torn-down call as one the *app* abandoned — so the walk lets the page
// fall quiet before it throws the page away, and what the list still catches
// is the app's own doing.
const inFlight = new Set<Request>();
page.on("request", (request) => {
const kind = request.resourceType();
if (kind === "fetch" || kind === "xhr") inFlight.add(request);
});
page.on("requestfinished", (request) => inFlight.delete(request));
page.on("requestfailed", (request) => inFlight.delete(request));
const settled = (): Promise<void> => quiet(inFlight);
page.on("response", (response) => {
const kind = response.request().resourceType();
if (response.status() < 400) return;
if (kind === "fetch" || kind === "xhr") {
apiRefusals.add(response.url());
// The path without its query, which is the part that identifies the route.
// A download-size query carries a model id and a revision that move with
// the catalog, and pinning those would fail on a bumped revision rather
// than on a refusal.
refusedApiCalls.push(
`${response.request().method()} ${new URL(response.url()).pathname} ${response.status()}`,
);
return;
}
badRequests.push(`${response.status()} ${kind} ${response.url()}`);
});
page.on("console", (message) => {
if (message.type() !== "error") return;
if (apiRefusals.has(message.location().url)) return;
consoleErrors.push(`${message.text()} @ ${message.location().url}`);
});
page.on("requestfailed", (request) => {
// **The reason, not just the URL.** A bare `failed <url>` cannot tell a
// resource the browser could not fetch from a call that completed and whose
// empty body stream the network stack then tore down, and those want
// opposite responses. Splitting them here is what lets each be asserted for
// what it is instead of one of them being quietly tolerated.
const reason = request.failure()?.errorText ?? "unknown";
const kind = request.resourceType();
if ((kind === "fetch" || kind === "xhr") && reason === "net::ERR_ABORTED") {
const path = new URL(request.url()).pathname;
// A GET of image bytes torn down mid-flight is the app *cancelling*, not
// abandoning: `AssetImage` and `AssetThumbnail` abort their transfer when
// the consumer unmounts (#572), so a walk that navigates while frames and
// tiles are still loading produces these by design, in numbers that
// depend on timing. Every other aborted call stays pinned below.
if (request.method() === "GET" && /\/(thumbnail|content)$/.test(path)) return;
abortedApiCalls.push(`${request.method()} ${path}`);
return;
}
badRequests.push(`failed ${reason} ${request.url()}`);
});
await test.step("open the app, which asks for nothing", async () => {
await page.goto("./");
// The browser session against the real thing: `visionset server`
// on this machine, a browser, and the product — nothing typed, nothing
// pasted, no token anywhere in this step.
await expect(page.getByTestId("app-rail")).toBeVisible();
await expect(page.getByTestId("token-input")).toHaveCount(0);
});
await test.step("and a minted token still opens it too", async () => {
// The credential a third party uses, exercised in the one place a browser can
// still reach the form. The session cookie is *still in the jar* while this
// runs, so it is also the proof that the bearer header is tried first.
// The way to it is Settings → Access ("Use a different token"), which verifies the token
// against the real server exactly as the front door's form does.
await page.getByTestId("rail-settings").click();
await page.getByTestId("settings-access-different-button").click();
await page.getByTestId("settings-access-token-input").fill(token());
await page.getByTestId("settings-access-token-submit").click();
await expect(page.getByTestId("settings-access-kind")).toHaveText("Token");
await page.getByTestId("rail-projects").click();
// The rail is the product; reaching it means the credential was accepted by
// the real `StoredTokenAuthProvider` against a real digest.
await expect(page.getByTestId("app-rail")).toBeVisible();
});
await test.step("open the project from the list", async () => {
// From the project list, which is where `/` lands: there is no Home page.
await expect(page.getByTestId("projects-screen")).toBeVisible();
await page.getByTestId(`open-${PROJECT}`).click();
await expect(page.getByTestId("project-screen")).toBeVisible();
// A project opens on its default section, spelled in the URL.
await expect(page).toHaveURL(/\/projects\/[0-9a-f-]{36}\/overview$/);
// The open-project tab names it; no eyebrow line is drawn over the content.
await expect(page.getByTestId(/^open-tab-[0-9a-f-]{36}$/)).toContainText(PROJECT);
await expect(page.getByTestId("project-title")).toHaveCount(0);
});
await test.step("declare a schema with all four geometries", async () => {
/*
* A brand-new project opens on Overview, on **one** invitation chosen from
* its real state — no schema and no images, so the invitation is the ingest
* one: its steps, each leading on by a link to its page, and no filled button
* anywhere on the composed screen. Define classes is the second step's link,
* and this run walks it rather than the tab bar: a schema first is a road the
* steps name as open, and the walk proves it is a real one.
*
* The count is asserted here rather than in a unit test because "no filled
* button on the page" is a claim about the whole composed screen, and the
* header lives outside the panel that owns the invitation.
*/
await expect(page.getByTestId("overview-empty")).toBeVisible();
await expect(page.getByTestId("first-run")).toHaveAttribute(
"data-invitation",
"schema-first",
);
await expect(page.locator("button.bg-primary")).toHaveCount(0);
// Each step's way on is a link to its page.
await expect(page.getByTestId("overview-ingest")).toHaveAttribute("href", /\/overview\?add=images$/);
await expect(page.getByTestId("first-run-classes")).toHaveAttribute("href", /\/schema$/);
// And the retired checklist is gone rather than merely dismissed.
await expect(page.getByTestId("journey-checklist")).toHaveCount(0);
await page.getByTestId("first-run-classes").click();
await expectSection(page, "schema");
// A project starts schema-less on purpose, so the editor opens on an empty
// draft rather than an error.
await expect(page.getByTestId("schema-editor")).toContainText("Saving creates version 1");
for (const [index, [name, geometry]] of (
[
["vehicle", "bbox"],
["lane", "polygon"],
["daytime", "classification_tag"],
// The picker offers it because the API accepts it and the lane
// exporters need it — not because anything draws one. Declaring it here
// is the schema editor's half of that, against a real `create_version`
// that would answer `UnsupportedGeometry` if the kernel disagreed.
["centerline", "polyline"],
] as const
).entries()) {
await page.getByTestId("add-class").click();
await page.getByTestId(`class-name-${index}`).fill(name);
if (geometry !== "bbox") {
// Pick the wanted shape *before* clearing the default, which is also the
// only order the control permits: a class never passes through accepting
// nothing, so the last shape standing refuses to come off. The list
// stays open between the two picks; Escape puts it away and leaves the
// class sheet where it is.
await page.getByTestId(`class-geometry-${index}-input`).click();
await page.getByTestId(`class-geometry-${index}-${geometry}`).click();
await page.getByTestId(`class-geometry-${index}-bbox`).click();
await page.keyboard.press("Escape");
await expect(page.getByTestId(`class-geometry-${index}-chip-${geometry}`)).toBeVisible();
await expect(page.getByTestId(`class-geometry-${index}-chip-bbox`)).toHaveCount(0);
}
// New class opened the class sheet on a blank class, with focus in its name.
// Nothing is in the draft until it is submitted, which also puts it away
// before the next class is added.
await page.getByTestId("class-sheet-done").click();
await expect(page.getByTestId("class-sheet")).toHaveCount(0);
}
/*
* One class, two shapes, against a real `create_version` (#584).
*
* The whole point of a geometry set is that a class labelled as a box on some
* frames and as an outline on others is one class — and the only place that
* can be shown end to end is here, where the kernel actually judges the
* document. `vehicle` keeps its box and gains a polygon.
*/
await page.getByTestId("class-card-0").click();
await page.getByTestId("class-geometry-0-input").click();
await page.getByTestId("class-geometry-0-polygon").click();
await page.keyboard.press("Escape");
await expect(page.getByTestId("class-geometry-0-chip-bbox")).toBeVisible();
await expect(page.getByTestId("class-geometry-0-chip-polygon")).toBeVisible();
// The shape reaches the draft on Save, not on the click.
await page.getByTestId("class-sheet-done").click();
await expect(page.getByTestId("class-sheet")).toHaveCount(0);
/*
* The draft survives leaving the section, in a real DOM.
*
* jsdom cannot carry this claim on its own: the mechanism is the open
* section being the only one mounted, and "the component really was
* destroyed and rebuilt" is a statement about a browser's own
* reconciliation. Four unsaved classes is also the largest thing this cycle
* ever has to lose, and losing it here would be silent — the run would carry
* on and publish version 1 with whatever survived.
*/
await openSection(page, "overview");
await expect(page.getByTestId("schema-editor")).toHaveCount(0);
await openSection(page, "schema");
for (const name of ["vehicle", "lane", "daytime", "centerline"]) {
await expect(page.getByTestId("class-list")).toContainText(name);
}
/*
* And the draft survives a **reload**, which is a claim about the server
* rather than about React.
*
* The tab-switch check above proves only that state held above the tabs
* outlived a component being destroyed — everything it asserts is still true
* of a draft that never leaves the browser. A reload discards the whole
* page, so four unsaved classes coming back can only mean the server was
* holding them: the editor autosaves each edit through
* `PUT .../schema/drafts/curated` and seeds from `GET` on the way back up.
* That is the promise this feature exists to make, and jsdom cannot make it
* — there "reload" is a remount against a stub, which proves the stub.
*
* Nothing has been published at this point, so a version-1 fallback cannot
* be what answers: the project is still schema-less, and anything on screen
* after this reload came out of the draft.
*/
await settled();
await page.reload();
await expect(page.getByTestId("schema-editor")).toContainText("Saving creates version 1");
for (const name of ["vehicle", "lane", "daytime", "centerline"]) {
await expect(page.getByTestId("class-list")).toContainText(name);
}
// The two shapes on `vehicle` survive too, so what came back is the draft as
// edited rather than a re-seed from the four names alone.
await page.getByTestId("class-card-0").click();
await expect(page.getByTestId("class-geometry-0-chip-bbox")).toBeVisible();
await expect(page.getByTestId("class-geometry-0-chip-polygon")).toBeVisible();
// Nothing was changed, so Save just closes the dialog.
await page.getByTestId("class-sheet-done").click();
await expect(page.getByTestId("class-sheet")).toHaveCount(0);
// The draft holds four classes the project has never published, so the
// commit bar is up, offering version 1.
await expect(page.getByTestId("commit-bar")).toHaveAttribute("data-state", "up");
await page.getByTestId("save-schema").click();
// Published, the draft matches the version in force and the bar goes down.
// The history is a view *of* the schema rather than a peer of it: one press
// away in the section's band, not a fourth tab.
await expect(page.getByTestId("commit-bar")).toHaveAttribute("data-state", "down");
await expect(page.getByTestId("open-history")).toHaveAttribute("aria-label", /version 1/);
await page.getByTestId("open-history").click();
await expect(page.getByTestId("version-history")).toBeVisible();
await expect(page.getByTestId("version-1")).toBeVisible();
await expect(page.getByTestId("version-1")).toContainText("Active");
await page.keyboard.press("Escape");
await expect(page.getByTestId("history-sheet")).toHaveCount(0);
});
await test.step("ingest three images into a new batch", async () => {
// Add images is a button on Overview and Images; from Classes, where the
// schema was just saved, it is the overflow's first entry.
await page.getByTestId("project-menu").click();
await page.getByTestId("menu-ingest").click();
// A dialog over the section it was asked from, held open by the address.
await expect(page.getByRole("dialog", { name: "Add images" })).toBeVisible();
await expect(page).toHaveURL(/\/projects\/[0-9a-f-]{36}\/schema\?add=images$/);
await page.getByTestId("file-input").setInputFiles(images());
await expect(page.getByTestId("chosen")).toContainText("3 images");
await page.getByTestId("register-source").click();
await expect(page.getByTestId("source-card")).toBeVisible();
await page.getByTestId("batch-name").fill("cycle-batch");
await page.getByTestId("start-ingest").click();
// The run is launched with a 202 and polled to its end — the only place in the
// product where the answer arrives on a job row rather than in the response.
await expect(page.getByTestId("run-state")).toHaveText("Done", { timeout: 60_000 });
await expect(page.getByTestId("run-progress")).toContainText("3 of 3");
await expect(page.getByTestId("failures")).toHaveCount(0);
});
await test.step("the finished run names the batch it filled, and opens it", async () => {
// **The only test anywhere that drives the settled run's own route onward.**
// Walking back through the project to find the batch instead would be a suite
// finding it by another road, which cannot notice that the screen offers none.
await expect(page.getByTestId("run-outcome")).toContainText("“cycle-batch” is ready, as a draft");
// The batch's own count, not the run's: content addressing could have made
// it fewer than the files read.
await expect(page.getByTestId("run-outcome")).toContainText("It holds 3 images.");
// The project declared a schema before this ingest, so the step's filled
// control is the approval, made in place — and *Open* sits on the outcome
// beside it. The walk keeps to the panel's road below, which is the one
// that exercises the batch's own approve dialog.
await expect(page.getByTestId("approve-open")).toHaveAttribute("data-variant", "default");
await expect(page.getByTestId("ingest-another")).toBeVisible();
await expect(page.getByTestId("approve-needs-schema")).toHaveCount(0);
await page.getByTestId("open-batch").click();
// A batch has no page of its own: it opens in the Overview's panel, so "Open"
// lands on the Overview with the batch it names already open — and the
// dialog closes on the way, since the address no longer holds it.
await expect(page).toHaveURL(/\/projects\/[0-9a-f-]+\/overview\?batch=[0-9a-f-]+$/);
await expect(page.getByRole("dialog", { name: "Add images" })).toHaveCount(0);
await expect(page.getByTestId("batch-sheet").getByRole("heading", { level: 2, name: "cycle-batch" })).toBeVisible();
});
await test.step("a draft batch's panel offers approval, and has no jobs to open", async () => {
// Before approval there are no jobs, so there is nowhere to annotate: the panel
// says so and offers the one step that cuts them. What it offers is the batch's
// own `allowed_actions` as the kernel computed them — against a real server, so the
// draft's declarations are the kernel's answer rather than a fixture's.
const panel = page.getByTestId("batch-sheet");
await expect(panel.getByTestId("batch-phase")).toHaveText("Draft");
await expect(panel.getByTestId("batch-sheet-jobs")).toContainText("No jobs yet");
await expect(panel.getByTestId(/^batch-sheet-job-/)).toHaveCount(0);
await expect(panel.getByTestId("approve-batch")).toBeVisible();
// No route into the annotator, and nothing to start, complete or promote yet.
await expect(panel.getByTestId("sheet-annotate")).toHaveCount(0);
await expect(panel.getByTestId("start-batch")).toHaveCount(0);
await expect(panel.getByTestId("complete-cycle-batch")).toHaveCount(0);
await expect(panel.getByTestId("promote-cycle-batch")).toHaveCount(0);
});
await test.step("approve the batch, which pins the schema and cuts one job", async () => {
// Navigated rather than `goBack()`: history depth is an implementation detail
// of how the previous steps got here, and a cycle this long should not depend
// on it.
await openProject(page, PROJECT, "overview");
await expect(page.getByTestId("overview-batches")).toBeVisible();
const row = page.getByTestId("overview-batch-cycle-batch");
await expect(row).toContainText("Draft");
await expect(page.getByTestId("batch-sheet")).toHaveCount(0);
// A draft's row opens its approval, not its panel: approving is the one thing a
// draft is opened for. Opening it moves nothing and navigates nowhere.
await row.locator("[data-row-open]").click();
await expect(page.getByTestId("approve-dialog")).toBeVisible();
await expect(page.getByTestId("batch-sheet")).toHaveCount(0);
await expect(page).toHaveURL(/\/projects\/[0-9a-f-]+\/overview$/);
// Switched off: the next step drives the panel's own Start annotating.
await page.getByTestId("approve-start").click();
await page.getByTestId("approve-submit").click();
// Approved, the panel opens on the batch, at its next step.
const panel = page.getByTestId("batch-sheet");
await expect(panel.getByRole("heading", { level: 2, name: "cycle-batch" })).toBeVisible();
await expect(page).toHaveURL(/\/projects\/[0-9a-f-]+\/overview\?batch=[0-9a-f-]+$/);
await expect(panel.getByTestId("batch-phase")).toHaveText("Approved");
await panel.getByTestId("start-batch").click();
await expect(panel.getByTestId("batch-phase")).toHaveText("Labeling");
// The version pins *at approval* — the Overview's row now names it, and the
// batch reads as being labeled.
await openProject(page, PROJECT, "overview");
await expect(row).toContainText("Labeling");
await expect(row).toContainText("v1");
});
await test.step("the panel's Annotate is the way in: the one job opens, and the arrow comes back to the batch", async () => {
// Only the way in is driven here: the cycle server has no `text_detect` model,
// so the pre-label half of the panel's controls is exercised against the
// server suite.
await openBatch(page, PROJECT, "cycle-batch");
const panel = page.getByTestId("batch-sheet");
// The panel's top bar holds the batch's moves. The closing move, *Complete*, is
// not declared while frames are still to do, so it is withheld with its count.
await expect(panel.getByTestId("complete-cycle-batch")).toBeDisabled();
// Approved with no partition, the batch has one job: one card, nobody holding it.
const jobs = panel.getByTestId("batch-sheet-jobs");
await expect(jobs.getByTestId(/^batch-sheet-job-/)).toHaveCount(1);
await expect(jobs.getByTestId("batch-sheet-job-Job 1")).toContainText("Unassigned");
// The forward step — the one the panel opens on — is Annotate while there is work
// left; every control in the bar is quiet. With exactly one job it goes straight
// into the editor.
const annotate = panel.getByTestId("sheet-annotate");
await expect(annotate).toHaveAttribute("data-autofocus", "");
await annotate.click();
await expect(page.getByTestId("annotation-page")).toBeVisible();
// The job names no frame, so it opens on its first — and the annotator then
// writes the frame it is showing into the address, as it does after any
// walk, which is why `?asset=` may already be there.
await expect(page.getByTestId("asset-position")).toContainText("Frame 1 of 3");
await expect(page).toHaveURL(/\/jobs\/[0-9a-f-]+(\?asset=[0-9a-f-]+)?$/);
// The arrow goes up to the batch, which is the Overview with its panel open.
await page.getByTestId("back").click();
await expect(page).toHaveURL(/\/projects\/[0-9a-f-]+\/overview\?batch=[0-9a-f-]+$/);
await expect(page.getByTestId("batch-sheet").getByRole("heading", { level: 2, name: "cycle-batch" })).toBeVisible();
});
await test.step("reach the annotator by clicking, on the frame that was chosen", async () => {
// **The annotator is reached by clicking, and that is the reason this step
// exists.** `page.goto('./jobs/' + id)` with the id read out of the API makes
// a defect that blocks the whole product invisible to a green suite.
// Nothing here types a URL.
await openBatch(page, PROJECT, "cycle-batch");
await page.getByTestId("batch-sheet").getByTestId("sheet-annotate").click();
await expect(page.getByTestId("annotation-page")).toBeVisible();
await expect(page.getByTestId("asset-position")).toContainText("Frame 1 of 3");
// The grid button switches frames without leaving: an overlay over the
// workspace, the URL unmoved, and Escape returning to exactly the frame that
// was on screen.
const inTheEditor = page.url();
await page.getByTestId("open-gallery").click();
await expect(page.getByTestId("frame-gallery")).toBeVisible();
expect(page.url()).toBe(inTheEditor);
await page.keyboard.press("Escape");
await expect(page.getByTestId("frame-gallery")).toHaveCount(0);
await expect(page.getByTestId("asset-position")).toContainText("Frame 1 of 3");
// The **third** frame, so "it opened the job" and "it opened this frame" cannot
// be confused: a page that ignored the click would still show 1/3. By its
// position, through the overlay's own tile, because the batch no longer shows its
// frames anywhere but here.
await page.getByTestId("open-gallery").click();
await page.getByRole("button", { name: /^Frame 3,/ }).click();
await expect(page.getByTestId("annotation-page")).toBeVisible();
await expect(page.getByTestId("asset-position")).toContainText("Frame 3 of 3");
await expect(page).toHaveURL(/\/jobs\/[0-9a-f-]+\?asset=[0-9a-f-]+$/);
const chosen = new URL(page.url()).searchParams.get("asset");
// The only honest way to check the deep link: reload the
// URL **the app itself produced**, which is a fresh `GET /app/jobs/<id>?asset=`
// at the server and therefore drives the SPA deep-link fallback for real. A
// typed `page.goto('./jobs/…')` would assert the same thing while reopening
// the door this task closed.
await settled();
await page.reload();
await expect(page.getByTestId("annotation-page")).toBeVisible();
await expect(page.getByTestId("asset-position")).toContainText("Frame 3 of 3");
expect(new URL(page.url()).searchParams.get("asset")).toBe(chosen);
// And back to the batch, from the arrow. Leaving is still a thing you can
// do; it is not the only way to look at your own frames.
await page.getByTestId("back").click();
await expect(page.getByTestId("batch-sheet").getByRole("heading", { level: 2, name: "cycle-batch" })).toBeVisible();
await expect(page).toHaveURL(/\/projects\/[0-9a-f-]+\/overview\?batch=[0-9a-f-]+$/);
});
await test.step("set up a connection to the built-in stand-in", async () => {
/*
* **Auto-labeling had no coverage against a real server at all**, which is
* how a defect that made every suggestion a 500 passed a full green run.
* The obstacle was always the weights: the models that answer a point
* prompt are gigabytes and one of them is gated, so no scenario could fetch
* one on a runner.
*
* `visionset/stub-segmenter` is the shipped no-op that closes it. Every
* hop below is the product's own: the form, the download action, the
* connection's lifecycle. Only the thing at the far end predicts nothing.
*/
await putAwayPanel(page);
await page.getByTestId("rail-models").click();
await expect(page.getByTestId("models-screen")).toBeVisible();
await page.getByTestId("new-connection").click();
await page.getByTestId("connection-name").fill(STAND_IN);
// Through **Custom model**, which is the point of it not being in the
// curated list: nobody choosing a model is offered a segmenter that cannot
// segment, and anybody who needs it can still name it.
//
// The list only exists once the real `/inference/providers` read has
// answered — wait for it rather than racing the click against that request.
await expect(page.getByTestId("connection-model")).toBeVisible();
// Whether the list lands on a curated model, or falls back to Custom
// model with an empty id, is a catalog fact `connection-model` being
// visible does not settle: `defaultEntry` seeds the first entry that
// answers a point prompt, but returns `undefined` when none does, and
// the size line renders nothing for an empty id — so the wait below
// would die on a bare, undiagnosable timeout on such an installation.
// Assert the seed landed on a curated model before waiting on the price
// probe only a curated model triggers.
await expect(
page.getByTestId("connection-model").getByRole("radio", { checked: true }),
).not.toHaveText(/Custom model/);
// Let the seeded model's size probe settle before moving off it: clicking
// through the list faster than that request resolves leaves the
// refusal landing at whatever point the dialog happens to unmount, which
// is the difference between a pinned list and a flaky one. Waiting is
// also what makes the answer readable — `size-known` and
// `size-unavailable` are the form's own two outcomes, and the final step
// expects a refusal from this route exactly when the second one is what
// rendered.
const sizeLine = page.getByTestId(/^size-(known|unavailable)$/);
await expect(sizeLine).toBeVisible();
curatedSizeRefused = (await sizeLine.getAttribute("data-testid")) === "size-unavailable";
await page.getByTestId("model-option-custom").click();
await page.getByTestId("connection-custom-model").fill(STUB_MODEL_ID);
await page.getByTestId("connection-revision").fill("stub");
await page.getByTestId("connection-submit").click();
// Born not set up, like every local connection, and made ready by the same
// action — the lifecycle here is the real one, not a shortcut written for a
// suite. What is different is only that there is nothing to fetch.
// Read inside the card rather than off the screen. Both ids live inside a
// connection's own card, so an unscoped read is sound only while the
// workspace holds exactly one — and Playwright's strict mode then refuses
// the locator, naming the selector instead of the assumption.
const card = page.getByTestId(`connection-${STAND_IN}`);
await expect(card.getByTestId("connection-status")).toContainText(/not set up/i);
// The download is the model sheet's: the row is read, and its name opens
// the sheet where the connection is set up.
await card.getByTestId(`open-${STAND_IN}`).click();
await expect(page.getByTestId("model-sheet")).toBeVisible();
await page.getByTestId("download-weights").click();
await expect(card.getByTestId("connection-status")).toContainText(/ready/i, {
timeout: 15_000,
});
// The sheet is a modal layer over the page: put it away before the walk moves on.
await page.keyboard.press("Escape");
await expect(page.getByTestId("model-sheet")).toHaveCount(0);
/*
* One connection, asserted rather than assumed.
*
* The suggest panel further down names this connection in a sentence and
* offers a picker from two upwards, so a second connection breaks that
* assertion as a *missing string* — pointing at the suggest panel while the
* cause is an extra row on this screen. Stated here, where the count is
* decided, a violation names the count.
*
* The source line is what is counted because it is unconditional inside a
* row, while the download button is the sheet's and appears only before setup.
*/
await expect(page.getByTestId("connection-source")).toHaveCount(1);
});
await test.step("a click in the editor comes back as a shape, from a real server", async () => {
/*
* The gap this walk existed around. Everything here is real: a real
* `POST /inference/suggest`, the real route, the real mask pipeline turning
* a grid of pixels into a polygon, and the real editor putting it in the
* document. The annotator's own suite stubs this request outright, which is
* correct for what that suite tests and is exactly why it could not notice.
*
* The suggestion is **taken back before the step ends**, so the counts every
* later step asserts — the trunk's, the release's — are the counts the
* hand-drawn work produced. What is being claimed here is that a click
* reaches a model and comes back as a shape, not that a stand-in's square
* belongs in somebody's dataset.
*/
await openBatch(page, PROJECT, "cycle-batch");
await page.getByTestId("batch-sheet").getByTestId("sheet-annotate").click();
await expect(page.getByTestId("annotation-page")).toBeVisible();
await expect(page.getByTestId("object-count")).toHaveText("0");
// A class first: the suggestion is a shape and a shape needs one, which is
// the whole reason the model is never asked to name anything.
await activate(page, "vehicle");
await page.getByTestId("tool-suggest").click();
// One connection, so the panel names it in a sentence rather than offering a
// picker — `suggest-connection-select` appears from two upwards, counting the
// detectors Detect all can be pointed at.
await expect(page.getByTestId("suggest-connection")).toContainText(STAND_IN);
await expect(page.getByTestId("suggest-idle")).toBeVisible();
const canvas = (await page.getByTestId("annotator-canvas").boundingBox())!;
await page.getByTestId("annotator-root").focus();
await page.mouse.click(canvas.x + canvas.width * 0.5, canvas.y + canvas.height * 0.5);
// The shape came back and rendered. Generous, because this is the one
// request in the walk that crosses a model boundary — a cold provider is
// built on the first ask.
await expect(page.getByTestId("suggest-shown")).toBeVisible({ timeout: 15_000 });
await expect(page.getByTestId("suggestion-shape")).toBeVisible();
// Accepting is what puts it in the document, and the count is what says so.
await page.getByTestId("suggest-accept").click();
await expect(page.getByTestId("object-count")).toHaveText("1");
// And taken back, so nothing downstream inherits it. Undo rather than a
// delete: it is one gesture, and it also asserts that an accepted
// suggestion is an ordinary edit rather than something the history cannot
// reach.
await page.getByTestId("annotator-root").focus();
await page.keyboard.press("ControlOrMeta+z");
await expect(page.getByTestId("object-count")).toHaveText("0");
await expect(page.getByTestId("save-state").filter({ hasText: /Edited|Saving|Not saved/ })).toHaveCount(0);
// Back to the batch, because the step after this one starts there. A step
// that leaves the walk somewhere its successor does not expect fails in the
// successor, which is a long way from the line that caused it.
await page.getByTestId("back").click();
await expect(page.getByTestId("batch-sheet").getByRole("heading", { level: 2, name: "cycle-batch" })).toBeVisible();
});
await test.step("annotate all three assets", async () => {
// Back in through the panel's Annotate, which opens on the first frame, because the
// drawing below walks 1 → 2 → 3.
await page.getByTestId("batch-sheet").getByTestId("sheet-annotate").click();
await expect(page.getByTestId("annotation-page")).toBeVisible();
await expect(page.getByTestId("asset-position")).toContainText("Frame 1 of 3");
// The batch's pin, named on the screen. Not the project's active
// version — they are the same number here because nothing has published
// since approval, and the point is that the annotator says which one it is
// judged against, because the pin is movable.
//
// And it answers the question it raises, in the frame's information card.
// Nothing about the project's active version is read until the card is
// opened, so it is the only place in the editor where that read is
// legitimate. Here the pin *is* the active version, because nothing has
// published since approval: the footer says it is not behind.
await openInfo(page);
await expect(page.getByTestId("frame-info-schema")).toContainText("v1");
await expect(page.getByTestId("frame-info-schema")).toHaveAttribute("data-behind", "false");
await page.keyboard.press("Escape");
await expect(page.getByTestId("frame-info-trigger")).toHaveAttribute("aria-expanded", "false");
// 1 — a box.
await drawBox(page);
await saveNow(page);
await expect(page.getByTestId("save-state")).toContainText("All saved");
await page.getByTestId("next-asset").click();
// 2 — a polygon, closed with Enter.
await expect(page.getByTestId("asset-position")).toContainText("Frame 2 of 3");
await drawPolygon(page);
await saveNow(page);
await expect(page.getByTestId("save-state")).toContainText("All saved");
await page.getByTestId("next-asset").click();
// 3 — a whole-asset tag, from the rail's tags popover. Never the canvas: a tag
// is not a shape, so no tool and no gesture reaches one.
await expect(page.getByTestId("asset-position")).toContainText("Frame 3 of 3");
await openTags(page);
await page.getByTestId("tag-chip-daytime").click();
await expect(page.getByTestId("tag-chip-daytime")).toHaveAttribute("data-active", "true");
await expect(page.getByTestId("tag-count")).toHaveText("1 assigned");
// The stage says it too, on the chip row beside the ⓘ, while the popover is open.
await expect(page.getByTestId("frame-tag-chip-daytime")).toBeVisible();
// And it is counted where it is assigned, not where shapes are counted: a tag
// renders in neither canvas layer, so a badge on the picture reading
// `1 object` was a number nothing on screen could account for.
await expect(page.getByTestId("object-count")).toHaveText("0");
await expect(page.getByTestId("objects-empty")).toHaveText("Nothing drawn yet.");
await closeTags(page);
await saveNow(page);
await expect(page.getByTestId("save-state")).toContainText("All saved");
// 3a — a lane, written the way lanes are actually written.
//
// **This is the point of shipping a geometry an agent writes.** The workflow
// it exists for is *an agent pre-labels lanes and a person reviews them
// here*. So the
// lane arrives over the REST API, with the same credential the app is
// holding, and everything after this line is the person's half of that.
//
// The job comes off the URL and **the asset comes off the page**, which is
// the distinction this step was written wrong once: the asset travels as a
// query parameter that names where the annotator was *entered*, and
// Next moves the frame without rewriting it. Reading `?asset=` here
// addressed frame 1 while standing on frame 3, and every assertion that
// followed still passed — the lane really was written, really did render, and
// really was on the wrong picture. `data-asset` is what the page says about
// itself.
const origin = new URL(page.url()).origin;
const jobId = new URL(page.url()).pathname.split("/").filter(Boolean).at(-1);
jobAddress = `./jobs/${jobId}`;
const assetId = await page.getByTestId("annotation-page").getAttribute("data-asset");
const written = await page.request.post(
`${origin}/jobs/${jobId}/annotations`,
{
headers: { Authorization: `Bearer ${token()}` },
data: [
{
asset_id: assetId,
label_class: "centerline",
geometry: {
type: "polyline",
// Ascending Y, which is what a lane looks like and what TuSimple
// would require of it at export.
points: [
[8, 6],
[24, 30],
[40, 58],
],
},
attributes: {},
provenance: "model",
model_ref: "cycle-spec@1",
confidence: 0.8,
},
],
},
);
expect(written.status()).toBe(201);
expect((await written.json()).items[0].geometry.type).toBe("polyline");
// 3b — the lane is on the page a person is looking at. Loaded afresh rather
// than refetched in place, because the assertion worth making is that the
// *stored* annotation renders, not that an optimistic update did. The asset
// is named explicitly so the entry point and the frame agree.
await settled();
await page.goto(`./jobs/${jobId}?asset=${assetId}`);
await expect(page.getByTestId("annotation-page")).toBeVisible();
// One: the lane. The tag on this frame is not an object, and the count says so.
await expect(page.getByTestId("object-count")).toHaveText("1");
// Still assigned, and still counted in its own region — excluding it from the
// objects is not the same as losing it. The tags live in the rail's popover now,
// and the stage's chip row says them without opening it.
await expect(page.getByTestId("frame-tag-chip-daytime")).toBeVisible();
await openTags(page);
await expect(page.getByTestId("tag-chip-daytime")).toHaveAttribute("data-active", "true");
await expect(page.getByTestId("tag-count")).toHaveText("1 assigned");
await closeTags(page);
// The row is its number, first, and the class; there is no trailing `#n` any more.
await expect(page.getByTestId("object-row-0")).toContainText("centerline");
await expect(page.getByTestId("object-row-0")).toHaveText(/^\s*1\s*centerline/);
// Drawn as an open path. `<polyline>` and not `<polygon>` is the whole
// difference between a lane and a closed ring, and it is the one thing a unit
// test over the document model structurally cannot see.
// Scoped to the committed layer's own group rather than to `svg polyline`:
// `TransientLayer` draws a `<polyline>` too, for the polygon being dragged.
await expect(page.locator("[data-annotation-id] polyline")).toHaveCount(1);
await expect(page.locator("[data-annotation-id] polyline")).toHaveAttribute("fill", "none");
// Row **0**, where it used to be row 1: the tag on this frame took the first
// number, and does not any more.
await expect(page.getByTestId("object-row-1")).toHaveCount(0);
// 3c — the lane tool is live, and it is live off a schema this server sent.
//
// A **disabled** polyline button with a sentence explaining why lanes can only
// be written by an agent is what this replaces, and it is worth keeping at this
// level rather than
// only in `e2e/polyline.spec.ts`: the strip is built from `drawableGeometry`
// over the *pinned* schema, so what is asserted here is that a real
// `SchemaVersionOut` — round-tripped through the API and the generated client —
// still yields the tool. The drawing behaviour itself is that spec's, against
// the showcase, where a session can be walked without disturbing this one.
const laneTool = page.getByTestId("tool-polyline");
await expect(laneTool).not.toHaveAttribute("aria-disabled", /.*/);
await laneTool.click();
await expect(laneTool).toHaveAttribute("data-active", "true");
// Back to select, so the rest of the walk starts where it used to.
await page.getByTestId("tool-select").click();
// 3d — a person marks the lane's middle vertex occluded, saves, and the mark
// survives a reload: the visibility went to the server and came back, rather
// than living in the browser's document. The release exported further down
// carries it into OpenLane 2D.
await selectObject(page, 0);
await expect(page.getByTestId("vertex-occluded-count")).toHaveText("Not recorded");
await page.getByTestId("vertex-toggle-1").focus();
await page.keyboard.press("Space");
await expect(page.getByTestId("vertex-toggle-1")).toHaveAttribute("aria-pressed", "true");
await expect(page.locator('[data-annotation-id] polyline[data-occluded="true"]')).toHaveCount(1);
await saveNow(page);
await expect(page.getByTestId("save-state")).toContainText("All saved");
await settled();
await page.reload();
await expect(page.getByTestId("annotation-page")).toBeVisible();
await expect(page.locator('[data-annotation-id] polyline[data-occluded="true"]')).toHaveCount(1);
await selectObject(page, 0);
await expect(page.getByTestId("vertex-toggle-1")).toHaveAttribute("aria-pressed", "true");
await expect(page.getByTestId("vertex-occluded-count")).toHaveText("1 occluded");
const stored = await page.request.get(`${origin}/jobs/${jobId}/assets/${assetId}/annotations`, {
headers: { Authorization: `Bearer ${token()}` },
});
expect(stored.status()).toBe(200);
const lane = (await stored.json()).items.find(
(one: { geometry: { type: string } }) => one.geometry.type === "polyline",
);
expect(lane.geometry.visibility).toEqual([2, 1, 2]);
await focusCanvas(page);
await page.keyboard.press("Escape");
await expect(page.getByTestId("vertex-region")).toHaveCount(0);
/*
* 3a-bis — #381: **a version published anywhere moves this batch's pin, and
* nobody presses re-pin.**
*
* This is the only run that can show it. The unit suites stub the publish, so
* they can assert what the client sent and rendered; whether the *server*
* moved the pin in the same transaction is a fact about `SchemaService`, and
* this is the one place that service is real. Before #381 the pin stayed at
* v1 here and the new class was invisible in this batch until somebody found
* the re-pin — which is the dead end the issue was reopened for.
*
* Published through the API rather than the Schema tab because the claim is
* about the kernel, not about a screen: leaving the editor and coming back
* would test navigation as well, and the Schema tab publishing *at all* is
* already covered above. The extra class is never drawn, and
* `DatasetStats.per_class` lists only classes with annotations, so nothing
* downstream counts it.
*/
const job = await page.request.get(`${origin}/jobs/${jobId}`, {
headers: { Authorization: `Bearer ${token()}` },
});
const batchId = (await job.json()).batch_id;
const batch = await page.request.get(`${origin}/batches/${batchId}`, {
headers: { Authorization: `Bearer ${token()}` },
});
const beforePin = (await batch.json()).schema_version;
const projectId = (await batch.json()).project_id;
// The whole contract plus one — `create_version` takes the entire class list,
// so a class left out is a class removed, and reading the active version is
// how this stays an *additive* change rather than an accidental narrowing.
const active = await page.request.get(`${origin}/projects/${projectId}/schema`, {
headers: { Authorization: `Bearer ${token()}` },
});
const current = (await active.json()).classes;
const grown = await page.request.post(`${origin}/projects/${projectId}/schema/versions`, {
headers: { Authorization: `Bearer ${token()}` },
data: {
classes: [
...current,
{ name: "pedestrian", geometries: ["bbox"] },
// A long name and every shape at once, for the row measurement below.
// In *this* publish rather than one of its own: the step after asserts
// `v${beforePin + 2}`, so an extra version here would move a number
// that is checking something else. #596
{
name: "pedestrian crossing",
geometries: ["bbox", "polygon", "polyline", "classification_tag"],
},
// The control for it: the *same* three chips against a short name, which
// must stay on one line. Without it, "the long row wrapped" is satisfied
// by a layout that wraps every row — and a fixed flex basis would do