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
const { I } = inject();
const Helpers = require("../tests/helpers");
 
module.exports = {
  _rootSelector: ".lsf-paragraphs",
  _filterSelector: "button[data-testid*='select-trigger']",
  _phraseSelector: "[class^='phrase--']",
  _phraseDialoguetextSelector: "[class^='dialoguetext--']",
 
  getParagraphTextSelector(idx) {
    // Convert 1-based test index to 0-based data-testid index
    const zeroBasedIdx = idx - 1;
    return `[data-testid="phrase:${zeroBasedIdx}"] [class^='dialoguetext--']`;
  },
 
  selectTextByOffset(paragraphIdx, startOffset, endOffset) {
    I.executeScript(Helpers.selectText, {
      selector: this.getParagraphTextSelector(paragraphIdx),
      rangeStart: startOffset,
      rangeEnd: endOffset,
    });
  },
  setSelection(startLocator, startOffset, endLocator, endOffset) {
    I.setSelection(startLocator, startOffset, endLocator, endOffset);
  },
  locate(locator) {
    return locator ? locate(locator).inside(this.locateRoot()) : this.locateRoot();
  },
  locateRoot() {
    return locate(this._rootSelector);
  },
  locateText(text) {
    const locator = locate(
      `${this.locateRoot().toXPath()}//*[starts-with(@class,'phrase--')]//*[contains(@class,'text--')]//text()[contains(.,'${text}')]`,
    );
 
    return locator;
  },
 
  clickFilter(...authors) {
    // Open dropdown and wait for it to appear
    I.click(locate(this._filterSelector));
    I.waitTicks(1);
    // For the new select component, we need to select each author
    // and the dropdown is managed automatically
    for (const author of authors) {
      // We may or may not have a search field depending on number of options
      const hasSearchField = I.executeScript(() => {
        return !!document.querySelector("input[data-testid='select-search-field']");
      });
 
      if (hasSearchField) {
        // Try to search if field is available
        I.fillField(locate("input[data-testid='select-search-field']"), author);
        I.waitTicks(3);
      }
 
      // Select the author option
      I.click(locate(`div[data-testid='select-option-${author}']`));
      I.waitTicks(3);
    }
 
    // Close any open dropdown
    I.pressKey("Escape");
    I.waitTicks(3); // Wait for UI to update after filter change
  },
 
  // Select All button helpers
  seeSelectAllButton(index) {
    I.seeElement(`[data-testid="select-all-btn:${index}"]`);
  },
 
  clickSelectAllButton(index) {
    I.click(`[data-testid="select-all-btn:${index}"]`);
  },
 
  seeSelectAllButtonDisabled(index) {
    I.seeElement(`[data-testid="select-all-btn:${index}"][disabled]`);
  },
 
  dontSeeSelectAllButton(index) {
    I.dontSeeElement(`[data-testid="select-all-btn:${index}"]`);
  },
};