Bin
2025-12-16 9e0b2ba2c317b1a86212f24cbae3195ad1f3dbfa
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
import { Labels, LabelStudio, Sidebar, VideoView } from "@humansignal/frontend-test/helpers/LSF/index";
import { simpleVideoConfig, simpleVideoData, simpleVideoResult } from "../../data/video_segmentation/regions";
import { TWO_FRAMES_TIMEOUT } from "../utils/constants";
 
// This test suite has exhibited flakiness in CI environments, so we are using retries
// while we work on improving CI stability for visual comparisons.
const suiteConfig = {
  retries: {
    runMode: 3, // Retry 3 times in CI (headless mode)
    openMode: 0, // No retries in local development (interactive mode)
  },
};
 
describe("Video segmentation", suiteConfig, () => {
  it("Should be able to draw a simple rectangle", () => {
    LabelStudio.params().config(simpleVideoConfig).data(simpleVideoData).withResult([]).init();
 
    LabelStudio.waitForObjectsReady();
    Sidebar.hasNoRegions();
 
    Labels.select("Label 1");
 
    VideoView.drawRectRelative(0.2, 0.2, 0.6, 0.6);
 
    Sidebar.hasRegions(1);
  });
 
  it("Should have changes in canvas", () => {
    LabelStudio.params().config(simpleVideoConfig).data(simpleVideoData).withResult([]).init();
    LabelStudio.waitForObjectsReady();
 
    // Wait for video and regions to be fully loaded
    cy.wait(TWO_FRAMES_TIMEOUT);
 
    Sidebar.hasNoRegions();
 
    // Wait for video to be fully loaded and stable
    VideoView.captureCanvas("canvas");
 
    Labels.select("Label 2");
    VideoView.drawRectRelative(0.2, 0.2, 0.6, 0.6);
 
    // Ensure drawing operations are complete before comparison
    cy.wait(1000);
 
    Sidebar.hasRegions(1);
 
    VideoView.canvasShouldChange("canvas", 0);
  });
  it("Should be invisible out of the lifespan (rectangle)", () => {
    LabelStudio.params().config(simpleVideoConfig).data(simpleVideoData).withResult(simpleVideoResult).init();
    LabelStudio.waitForObjectsReady();
    // Wait for video and regions to be fully loaded
    VideoView.waitForRegionInKonvaByIndex(0);
    VideoView.waitForStableState();
 
    Sidebar.hasRegions(1);
 
    VideoView.captureCanvas("canvas");
 
    VideoView.clickAtFrame(4);
    VideoView.waitForFrame(4);
    VideoView.waitForRegionNotInKonvaByIndex(0);
    VideoView.waitForStableState();
 
    VideoView.canvasShouldChange("canvas", 0);
  });
 
  it("Should be invisible out of the lifespan (transformer)", () => {
    LabelStudio.params().config(simpleVideoConfig).data(simpleVideoData).withResult(simpleVideoResult).init();
    LabelStudio.waitForObjectsReady();
    // Wait for frame change to be fully processed
    VideoView.waitForRegionInKonvaByIndex(0);
    VideoView.waitForStableState();
    Sidebar.hasRegions(1);
 
    cy.log("Remember an empty canvas state");
    VideoView.clickAtFrame(4);
    VideoView.waitForFrame(4);
    VideoView.waitForRegionNotInKonvaByIndex(0);
    VideoView.waitForStableState();
    VideoView.captureCanvas("canvas");
 
    VideoView.clickAtFrame(3);
    VideoView.waitForRegionInKonvaByIndex(0);
    VideoView.waitForStableState();
    cy.log("Select region");
    VideoView.clickAtRelative(0.5, 0.5);
    Sidebar.hasSelectedRegions(1);
    VideoView.clickAtFrame(4);
    VideoView.waitForFrame(4); // Wait for frame 4
    Sidebar.hasSelectedRegions(1);
 
    cy.wait(1000);
 
    VideoView.canvasShouldNotChange("canvas", 0);
  });
});