/**
|
* @file S&OP Panel component to wrap common methods the team encounter during development
|
* @description Panel class extending e2elib's PanelBase.
|
* 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 { PanelBase } from '../libappbase/panelbase';
|
|
export class PanelSOP extends PanelBase {
|
public constructor(componentPath: string) {
|
super(componentPath);
|
}
|
|
/**
|
* Ensure only 1 collapsible panel is expanded.
|
*
|
* @param panel The panel to be expanded. For the rest, if it's expanded, click to collapse.
|
*/
|
public async showOnlyPanel(panel: PanelSOP): Promise<void> {
|
// Get all property name and check whether it is PanelSOP type
|
const allPropertyName = Object.getOwnPropertyNames(this);
|
for (const propertyName of allPropertyName) {
|
const property = Object.getOwnPropertyDescriptor(this, propertyName);
|
if (property!.value instanceof PanelSOP) {
|
const childComponent = property!.value;
|
// Ensure only target panel is expanded (for the rest, if it's expanded, click to collapse)
|
const canClick = (panel === childComponent) !== (await childComponent.isShown());
|
|
if (canClick) {
|
await childComponent.clickPanel();
|
}
|
}
|
}
|
}
|
|
public async verifyTitle(expectedTitle: string): Promise<void> {
|
expect(await this.getTitle()).toBe(expectedTitle, `Verify panel ${await this.getComponentLabel()} title value.`);
|
}
|
}
|
|
// Step description to re-use in spec file to prevent scriptor re-write each time
|
const stepPanel = {
|
showOnlyPanel: (panelName: string): string => `Collapse all panels and ensure only panel ${panelName} is expanded.`,
|
verifyTitle: (panelName: string, expectedTitle: string): string => `In panel '${panelName}, verify title = '${expectedTitle}'.'`,
|
};
|
|
export { stepPanel as StepPanel };
|