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
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
Feature("Time traveling");
 
const IMAGE =
  "https://htx-pub.s3.us-east-1.amazonaws.com/examples/images/nick-owuor-astro-nic-visuals-wDifg5xc9Z4-unsplash.jpg";
 
Scenario(
  "Travel through history with the selected brush region",
  async ({ I, LabelStudio, AtImageView, AtOutliner }) => {
    I.amOnPage("/");
    LabelStudio.init({
      data: { image: IMAGE },
      config: `<View>
      <Image name="img" value="$image" defaultZoom="auto"/>
      <Brush name="tag" toName="img" />
      <Labels name="labels">
        <Label value="1"></Label>
      </Labels>
    </View>`,
    });
 
    LabelStudio.waitForObjectsReady();
 
    AtOutliner.seeRegions(0);
    AtOutliner.dontSeeSelectedRegion();
 
    I.say("Draw a brush region");
    await AtImageView.lookForStage();
 
    AtImageView.selectToolByCode("brush");
    AtImageView.hasSelectedTool("brush");
 
    AtImageView.drawThroughPoints([
      [50, 50],
      [100, 50],
      [50, 80],
    ]);
 
    AtOutliner.seeRegions(1);
    AtOutliner.seeSelectedRegion();
 
    I.say("Add a brush stroke to the last created region (2 strokes, 1 region)");
    AtImageView.drawThroughPoints([
      [50, 100],
      [100, 100],
      [50, 130],
    ]);
 
    I.say("Check that we are drawing in the same region");
    AtOutliner.seeRegions(1);
    AtOutliner.seeSelectedRegion();
 
    I.say("Go back through history");
    I.pressKey(["CommandOrControl", "z"]);
 
    I.say("The brush region still should be selected (1 stroke, 1 region)");
    AtOutliner.seeRegions(1);
    AtOutliner.seeSelectedRegion();
 
    I.say("Try the same with redo");
    I.pressKey(["CommandOrControl", "shift", "z"]);
 
    I.say("The brush region still should be selected (2 strokes, 1 region)");
    AtOutliner.seeRegions(1);
    AtOutliner.seeSelectedRegion();
  },
);
 
Scenario(
  "Travel through history after moving the rectangle region",
  async ({ I, LabelStudio, AtImageView, AtOutliner }) => {
    I.amOnPage("/");
    LabelStudio.init({
      data: { image: IMAGE },
      config: `<View>
    <Image name="img" value="$image" defaultZoom="auto" />
    <Rectangle name="tag" toName="img" />
    <Labels name="labels">
        <Label value="1"></Label>
    </Labels>
  </View>`,
    });
    LabelStudio.waitForObjectsReady();
 
    AtOutliner.seeRegions(0);
    AtOutliner.dontSeeSelectedRegion();
 
    I.say("Draw a rectangle region");
    await AtImageView.lookForStage();
    AtImageView.selectToolByCode("rectangle");
    AtImageView.hasSelectedTool("rectangle");
    AtImageView.drawByDrag(100, 100, 200, 200);
 
    I.say("Select the region");
    AtImageView.clickAt(150, 150);
 
    I.say("Check that the region is created and selected");
    AtOutliner.seeRegions(1);
    AtOutliner.seeSelectedRegion();
 
    I.say("Move the last created region 2 times");
    AtImageView.drawByDrag(200, 200, 100, 0);
    AtImageView.drawByDrag(300, 200, 0, -100);
 
    I.say("When we move region we should do not create any other region or loose the selection (moved 2 times)");
    AtOutliner.seeRegions(1);
    AtOutliner.seeSelectedRegion();
 
    I.say("Go back through history");
    I.pressKey(["CommandOrControl", "z"]);
 
    I.say("The rectangle region still should be selected (moved 1 time)");
    AtOutliner.seeRegions(1);
    AtOutliner.seeSelectedRegion();
 
    I.say("Repeat going back through history");
    I.pressKey(["CommandOrControl", "z"]);
 
    I.say("The rectangle region still should be selected (moved 0 times)");
    AtOutliner.seeRegions(1);
    AtOutliner.seeSelectedRegion();
 
    I.say("Try the same with redo");
    I.pressKey(["CommandOrControl", "shift", "z"]);
 
    I.say("The brush region still should be selected (moved 1 time)");
    AtOutliner.seeRegions(1);
    AtOutliner.seeSelectedRegion();
  },
);