yanweiyuan3
2023-08-09 588bc7829387dfc761cc25f06f77d4c81818bd10
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
import { QConsole } from '../e2elib/lib/src/helper/qconsole';
import { frmSelectImage } from '../e2elib/lib/src/UI/WebComponentTypeLibrary/frmSelectImage';
import { ButtonSOP } from './buttonsop';
 
/**
 * Web built-in select image dialog.
 */
export class FormSelectImage extends frmSelectImage {
 
  private readonly btnSelectImage: ButtonSOP;
 
  public constructor(btnSelectImage: string) {
    super(frmSelectImage._name);
    this.btnSelectImage = new ButtonSOP(btnSelectImage);
  }
 
  /**
   * Opens the select image form, finds and select the icon and click ok.
   * Enters image name using the Search/Filter edit field, then find the image in the lists and selects it.
   *
   * @param name Icon name
   */
  public async selectImage(name: string): Promise<void> {
    // Open select image form by clicking select icon button.
    await this.btnSelectImage.click();
    await QConsole.waitForStable();
 
    // Filter icon list
    await this.efSearch._ref().sendInput(name);
 
    // Navigate category one by one to search for the icon (on the filtered list)
    const rowCount = await this.lstImageCategories._ref().getRowCount();
    let isFound = false;
    for (let i = 0; i < rowCount; i++) {
      await this.lstImageCategories._ref().selectListRowsByIndex([i]);
      try {
        await this.lstImages._ref().selectListRowsByValue([[{ columnID: ListImagesColumn.Name, value: name }]]);
        isFound = true;
        break;
      } catch {
        // do nothing
      }
    }
    expect(isFound).toBe(true, `Unable to find the image name "${name}" in the select image dialog.`);
    await this.btnOk._ref().click();
    await this._ref().waitUntilHidden(); // Wait dialog dismiss
  }
}
 
export enum ListImagesColumn {
  Name = 'Name',
}