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
const { I } = inject();
 
/**
 * Helper to test different information displayed in Details panel,
 * like region labels, editable fields, meta info, etc.
 */
module.exports = {
  _rootSelector: ".lsf-details",
  _labelSelector: ".lsf-detailed-region .lsf-labels-list span",
  _textSelector: ".lsf-region-meta__content_type_text",
  _editMetaSelector: '[aria-label="Edit region\'s meta"]',
  _editableFieldInput: ".lsf-region-editor__input",
  _editableFieldTitle: ".lsf-region-editor__text",
  _metaField: ".lsf-detailed-region__meta-text",
  _resultBlockSelector: ".lsf-detailed-region__result",
  _resultTitleSelector: ".ant-typography,[class*='typography-']",
  _resultValueSelector: ".lsf-region-meta__value",
  _sectionHeadSelector: ".lsf-details__section-head",
  locateDetailPanel() {
    return locate(this._rootSelector);
  },
  locate(locator) {
    return locator ? locate(locator).inside(this.locateDetailPanel()) : this.locateDetailPanel();
  },
  locateMeta() {
    return this.locate(this._metaField);
  },
  locateEditableField(field) {
    const title = this.locate(this._editableFieldTitle).withText(field);
 
    return this.locate(this._editableFieldInput).before(title);
  },
  locateResultBlock() {
    return this.locate(this._resultBlockSelector);
  },
  locateResultRating(rating) {
    const locator = this.locateResultBlock().withDescendant(locate(this._resultTitleSelector).withText("Rating"));
 
    if (typeof rating === "undefined") return locator;
 
    return locator.withDescendant(locate(this._resultValueSelector).withText(`${rating}`));
  },
  locateResultTextarea(text) {
    const locator = this.locateResultBlock().withDescendant(locate(this._resultTitleSelector).withText("Text"));
 
    if (typeof text === "undefined") return locator;
 
    if (!Array.isArray(text)) text = [text];
    for (const line of text) {
      locator.withDescendant(locate(this._resultValueSelector).withText(line));
    }
    return locator;
  },
  locateResultChoices(value) {
    const locator = this.locateResultBlock().withDescendant(locate(this._resultTitleSelector).withText("Choices"));
 
    if (typeof value === "undefined") return locator;
 
    if (!Array.isArray(value)) value = [value];
 
    return locator.withDescendant(locate(this._resultValueSelector).withText(value.join(", ")));
  },
  locateLabel(text) {
    return text ? locate(this._labelSelector).withText(`${text}`) : locate(this._labelSelector);
  },
  locateText(text) {
    return text ? locate(this._textSelector).withText(`${text}`) : locate(this._textSelector);
  },
  clickEditMeta() {
    I.click(this.locate(this._editMetaSelector));
  },
  fillMeta(text) {
    I.fillField(this.locateMeta(), text);
  },
  // can be not very precise: actual '82.1000003' will match value '82.1'
  seeFieldWithValue(field, value) {
    I.seeInField(this.locateEditableField(field), value);
  },
  seeMeta(text) {
    I.see(text, this.locateMeta());
  },
  dontSeeMeta(text) {
    I.dontSee(text, this.locateMeta());
  },
  clickMeta() {
    I.click(this.locateMeta());
  },
  seeLabel(text) {
    I.seeElement(this.locateLabel(text));
  },
  seeLabels(count) {
    count && I.seeElement(this.locateLabel().at(count));
    I.dontSeeElement(this.locateLabel().at(count + 1));
  },
  seeText(text) {
    I.seeElement(this.locateText(text));
  },
  seeResultRating(rating) {
    I.seeElement(this.locateResultRating(rating));
  },
  seeResultTextarea(text) {
    I.seeElement(this.locateResultTextarea(text));
  },
  seeResultChoices(value) {
    I.seeElement(this.locateResultChoices(value));
  },
  clickCreateRelation() {
    I.click(this.locate('[aria-label="Create Relation"]'));
  },
  clickDeleteRegion() {
    I.click(this.locate('[aria-label="Delete selected region"]'));
  },
 
  seeRelations(count) {
    I.seeElement(this.locate(this._sectionHeadSelector).withText(`Relations (${count})`));
  },
};