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
56
57
58
59
60
61
62
63
64
/**
 * @file        S&OP NumberPicker component to wrap common methods the team encounter during development
 * @description NumberPicker class extending e2elib's NumberPicker.
 * 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 { QConsole } from '../e2elib/lib/src/helper/qconsole';
import { QUtils } from '../e2elib/lib/src/main/qutils.class';
import { NumberPicker } from '../e2elib/lib/src/pageobjects/numberpicker.component';
import { UIActionSOP } from './objectsop';
 
export class NumberPickerSOP extends NumberPicker implements UIActionSOP {
  public constructor(componentPath: string) {
    super(componentPath);
  }
 
  public async clickActionLinkText(expectedActionLinkText: string): Promise<void> {
    const isActionLinkMatch = await this.hasActionLink() && await this.getActionLinkText() === expectedActionLinkText;
    expect(isActionLinkMatch).toBe(true, `Unable to proceed click action link for numberpicker ${await this.getComponentLabel()}. Expecting action link text '${expectedActionLinkText}'.`);
 
    if (isActionLinkMatch) {
      await this.clickActionLink();
    }
  }
 
  public async getValueString(): Promise<string> {
    return this.getValue();
  }
 
  public async setValue(value: string): Promise<void> {
    await this.sendInput(value);
    await QConsole.waitForStable();
  }
 
  public async verifyBatchEditEnabled(expectedEnable: boolean, expectedActionLinkText: string): Promise<void> {
    const isBatchEditEnableDisableOK = await this.hasActionLink() &&
                                       await this.getActionLinkText() === expectedActionLinkText &&
                                       !await this.isDisabled() === expectedEnable;
    expect(isBatchEditEnableDisableOK).toBe(true, `Verify numberpicker ${await this.getComponentLabel()} supports batch edit (expected enable = ${expectedEnable} & action link = ${expectedActionLinkText}).`);
  }
 
  public async verifyHasMaskError(expectedValue: boolean): Promise<void> {
    // Implements UIActionSOP
    await this.hasMaskError(expectedValue);
  }
 
  public async verifyTooltip(expectedValue: string): Promise<void> {
    const tooltip = await QUtils.getTooltip(this.tooltipLabelElement, true, true, true);
    expect(tooltip).toBe(expectedValue, `Hover ${await this.getComponentLabel()} to verify tooltip.`);
  }
 
  public async verifyEnabled(expectedEnable: boolean): Promise<void> {
    expect(!await this.isDisabled()).toBe(expectedEnable, `Verify enable state for numberpicker ${await this.getComponentLabel()}.`);
  }
 
  public async verifyValue(expectedValue: string): Promise<void> {
    expect(await this.getValue()).toBe(expectedValue, `Verify value for numberpicker ${await this.getComponentLabel()}.`);
  }
 
  public async verifyVisible(expectedValue: string): Promise<void> {
    expect(await this.isVisible()).toBe(expectedValue.toLowerCase() === 'true', `Verify visible state for numberpicker ${await this.getComponentLabel()}.`);
  }
}