| import { Dashboard } from '../e2elib/lib/src/pageobjects/dashboard/dashboard.component'; | 
| import { Gauge } from '../e2elib/lib/src/pageobjects/gauge.component'; | 
| import { ColorSOP } from './colorsop'; | 
|   | 
| export interface GaugeProperties { | 
|   Value?: string; | 
|   Unit?: string; | 
|   ThresholdColor?: ColorSOP; | 
| } | 
|   | 
| export class DashboardSOP extends Dashboard { | 
|   public constructor(componentPath: string) { | 
|     super(componentPath); | 
|   } | 
|   | 
|   /** | 
|    * E2e lib throws error if gauge title not found thus very hard to use by scriptor as need try catch. | 
|    * | 
|    * @param gaugeTitle Gauge title to identify each gauge in the UI. | 
|    * @returns If found returns gauge, else returns undefined. | 
|    */ | 
|   public async getGaugeSOP(gaugeTitle?: string): Promise<Gauge | undefined> { | 
|     try { | 
|       const gauge = await this.getGauge(gaugeTitle); | 
|       return gauge; | 
|     } catch { | 
|       return undefined; | 
|     } | 
|   } | 
|   | 
|   /** | 
|    * Verify if gauge exists. | 
|    * | 
|    * @param gaugeTitle Gauge title to identify each gauge in the UI. | 
|    */ | 
|   public async verifyGaugeExists(gaugeTitle: string): Promise<void> { | 
|     const gauge = await this.getGaugeSOP(gaugeTitle); | 
|     expect(gauge).toBeDefined(`Expected gauge "${gaugeTitle}" to exist.`); | 
|   } | 
|   | 
|   /** | 
|    * Verify if gauge not exist. | 
|    * | 
|    * @param gaugeTitle Gauge title to identify each gauge in the UI. | 
|    */ | 
|   public async verifyGaugeNotExist(gaugeTitle: string): Promise<void> { | 
|     const gauge = await this.getGaugeSOP(gaugeTitle); | 
|     expect(gauge).toBeUndefined(`Expected gauge "${gaugeTitle}" to not exist.`); | 
|   } | 
|   | 
|   /** | 
|    * Verify gauge properties such as value, unit and threshold color. | 
|    * Scriptor can specifiy one or more gauge properties to verify. | 
|    * | 
|    * @param gaugeTitle Gauge title to identify each gauge in the UI. | 
|    * @param gaugeProps Interface to define one or more gauge properties to verify. | 
|    */ | 
|   public async verifyGaugeProperties(gaugeTitle: string, gaugeProps: GaugeProperties): Promise<void> { | 
|     const gauge = await this.getGaugeSOP(gaugeTitle) as Gauge; | 
|   | 
|     if (gaugeProps.Value) { | 
|       expect(await gauge.getValue()).toBe(gaugeProps.Value, `Verify fail for gauge "${gaugeTitle}" value.`); | 
|     } | 
|   | 
|     if (gaugeProps.Unit) { | 
|       expect(await gauge.getUnit()).toBe(gaugeProps.Unit, `Verify fail for gauge "${gaugeTitle}" unit.`); | 
|     } | 
|   | 
|     if (gaugeProps.ThresholdColor) { | 
|       expect(await gauge.getTresholdColor()).toBe(gaugeProps.ThresholdColor.Rgb, `Verify fail for gauge "${gaugeTitle}" threshold color.`); | 
|     } | 
|   } | 
| } | 
|   | 
| // Step description to re-use in spec file to prevent scriptor re-write each time | 
| const stepDashboard = { | 
|   verifyGaugeExists: (gaugeTitles: string[]): string => `Verify gauge "${gaugeTitles.join(', ')}" exists in dashboard.`, | 
|   verifyGaugeNotExist: (gaugeTitles: string[]): string => `Verify gauge "${gaugeTitles.join(', ')}" not exist in dashboard.`, | 
|   verifyGaugeProperties: (gaugeTitle: string, fields: any): string => { | 
|     const arr: string[] = []; | 
|     for (const [key, value] of Object.entries(fields)) { | 
|       if (typeof value === 'string') { | 
|         arr.push(`${key} = "${value}"`); | 
|       } else { | 
|         arr.push(`${key} = "${(value as ColorSOP).Color}"`); | 
|       } | 
|     } | 
|   | 
|     return `Verify gauge "${gaugeTitle}": ${arr.join(', ')}.`; | 
|   }, | 
| }; | 
|   | 
| export { stepDashboard as StepDashboard }; |