| /** | 
|  * @file        S&OP Checkbox component to wrap common methods the team encounter during development | 
|  * @description Checkbox class extending libappbase's CheckboxBase. | 
|  * 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 { ElementFinder } from '../e2elib/node_modules/protractor/built'; | 
| import { UIActionSOP } from './objectsop'; | 
| import { QUtils } from '../e2elib/lib/src/main/qutils.class'; | 
| import { CheckboxBase } from '../libappbase/checkboxbase'; | 
|   | 
| export class CheckboxSOP extends CheckboxBase implements UIActionSOP { | 
|   public constructor(componentPath: string, isCustomPath?: boolean, elementObj?: ElementFinder) { | 
|     super(componentPath, isCustomPath, elementObj); | 
|   } | 
|   | 
|   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 checkbox ${await this.getComponentLabel()}. Expecting action link text '${expectedActionLinkText}'.`); | 
|   | 
|     if (isActionLinkMatch) { | 
|       await this.clickActionLink(); | 
|     } | 
|   } | 
|   | 
|   public async getValueString(): Promise<string> { | 
|     return (await this.isChecked()) ? 'true' : 'false'; | 
|   } | 
|   | 
|   public async setValue(value: string): Promise<void> { | 
|     await this.toggle(value.toLowerCase() === 'true'); | 
|   } | 
|   | 
|   public async toggleValue(): Promise<void> { | 
|     const currentValue = await this.isChecked(); | 
|     await this.toggle(!currentValue); | 
|   } | 
|   | 
|   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 checkbox ${await this.getComponentLabel()} supports batch edit (expected enable = ${expectedEnable} & action link = ${expectedActionLinkText}).`); | 
|   } | 
|   | 
|   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.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 checkbox ${await this.getComponentLabel()}.`); | 
|   } | 
|   | 
|   public async verifyValue(expectedValue: string): Promise<void> { | 
|     expect(await this.isChecked()).toBe(expectedValue.toLowerCase() === 'true', `Verify check state for checkbox ${await this.getComponentLabel()}.`); | 
|   } | 
|   | 
|   public async verifyVisible(expectedValue: string): Promise<void> { | 
|     expect(await this.isVisible()).toBe(expectedValue.toLowerCase() === 'true', `Verify visible state for checkbox ${await this.getComponentLabel()}.`); | 
|   } | 
| } |