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
53
54
55
/**
 * @file        S&OP Label component to wrap common methods the team encounter during development
 * @description Label class extending e2elib's Label.
 * All S&OP page objects inherit from our own class (inheriting e2e/libappbase), but we can propose common methods to them.
 * @author      Clarence (clarence.chan@3ds.com)
 * @copyright   Dassault Systèmes
 */
import { QUtils } from '../e2elib/lib/src/main/qutils.class';
import { Label } from '../e2elib/lib/src/pageobjects/label.component';
import { ElementFinder } from '../e2elib/node_modules/protractor/built';
import { UIActionSOP } from './objectsop';
 
export class LabelSOP extends Label implements UIActionSOP {
  public constructor(componentPath: string, isCustomPath?: boolean, elementObj?: ElementFinder) {
    super(componentPath, isCustomPath, elementObj);
  }
 
  public async clickActionLinkText(_expectedActionLinkText: string): Promise<void> {
    // Implements UIActionSOP. Not implementing
  }
 
  public async getValueString(): Promise<string> {
    return this.getText();
  }
 
  public async setValue(_value: string): Promise<void> {
    // Do nothing as label can't be changed by user
    // Argument prefix _ so that not flagged as error not used
  }
 
  public async verifyBatchEditEnabled(_expectedEnable: boolean, _expectedActionLinkText: string): Promise<void> {
    // Implements UIActionSOP. Not implementing
  }
 
  public async verifyHasMaskError(_expectedValue: boolean): Promise<void> {
    // Implements UIActionSOP, do nothing as no mask error
  }
 
  public async verifyTooltip(expectedValue: string): Promise<void> {
    const tooltip = await QUtils.getTooltip(this.tooltipElement, true, true, true);
    expect(tooltip).toBe(expectedValue, `Hover ${await this.getComponentLabel()} to verify tooltip.`);
  }
 
  public async verifyEnabled(_expectedEnable: boolean): Promise<void> {
    // Label has no enable/disable state
  }
 
  public async verifyValue(expectedValue: string): Promise<void> {
    expect(await this.getText()).toBe(expectedValue, `Verify label ${await this.getComponentLabel()}.`);
  }
 
  public async verifyVisible(expectedValue: string): Promise<void> {
    expect(await this.isVisible()).toBe(expectedValue.toLowerCase() === 'true', `Verify visible state for label ${await this.getComponentLabel()}.`);
  }
}