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
65
66
67
68
69
70
71
72
import { DialogSOP } from '../../libappsop/dialogsop';
import { ListSOP } from '../../libappsop/listsop';
import { DialogDummy } from './dialog.dummy';
 
export interface DialogExportSOPReportsFields {
  // No input element in dialog for now
}
 
export interface ListExportSOPScenariosFields {
  Name?: string;
}
 
export class DialogExportSOPReports extends DialogSOP<DialogExportSOPReportsFields> {
  public static readonly title = 'Export S&OP Reports';
  public static readonly buttonExport = 'Export';
  public readonly listScenarios = new ListExportSOPScenarios();
 
  public constructor() {
    super('DialogSCIExportReports', 'DialogSCIExportReports.btnExport');
  }
}
 
export class ListExportSOPScenarios extends ListSOP<DialogDummy, ListExportSOPScenariosFields> {
  public static title = `Scenarios (dialog ${DialogExportSOPReports.title})`;
 
  public constructor() {
    super('lstLibSCIScenario', new DialogDummy());
  }
 
  public async selectScenarioViaMenu(scenarioName: string): Promise<void> {
    const row = await this.getRow({Name: scenarioName});
    await this.selectContextMenu(listExportSOPScenariosContextMenuItem.Select, row);
  }
 
  public async setScenarioAsBase(scenarioName: string): Promise<void> {
    const row = await this.getRow({Name: scenarioName});
    await this.selectContextMenu(listExportSOPScenariosContextMenuItem.SetAsBase, row);
  }
 
  public async setScenarioAsCurrent(scenarioName: string): Promise<void> {
    const row = await this.getRow({Name: scenarioName});
    await this.selectContextMenu(listExportSOPScenariosContextMenuItem.SetAsCurrent, row);
  }
 
  public async unselectScenarioViaMenu(scenarioName: string): Promise<void> {
    const row = await this.getRow({Name: scenarioName});
    await this.selectContextMenu(listExportSOPScenariosContextMenuItem.Unselect, row);
  }
 
  public async verifyScenarioSelected(scenarioName: string, expectedChecked: boolean): Promise<void> {
    const row = await this.getRow({Name: scenarioName});
    expect(await row.isChecked()).toBe(expectedChecked, `Verify scenario '${scenarioName}' checked status.`);
  }
}
 
const listExportSOPScenariosContextMenuItem = {
  SetAsBase: { ContextMenu: 'cmContent', Name: 'MenuSetBase', Label: 'Set as base' },
  SetAsCurrent: { ContextMenu: 'cmContent', Name: 'MenuSetCurrent', Label: 'Set as current' },
  Select: { ContextMenu: 'cmContent', Name: 'MenuSelect', Label: 'Select' },
  Unselect: { ContextMenu: 'cmContent', Name: 'MenuUnselect', Label: 'Unselect' },
};
 
const stepDialogExportSOPReports = {
  setScenarioAsBase: (scenarioName: string): string => `In list '${ListExportSOPScenarios.title}', right click scenario '${scenarioName}' and select menu '${listExportSOPScenariosContextMenuItem.SetAsBase.Label}'.`,
  setScenarioAsCurrent: (scenarioName: string): string => `In list '${ListExportSOPScenarios.title}', right click scenario '${scenarioName}' and select menu '${listExportSOPScenariosContextMenuItem.SetAsCurrent.Label}'.`,
  unselectScenarioViaMenu: (scenarioName: string): string => `In list '${ListExportSOPScenarios.title}', right click scenario '${scenarioName}' and select menu '${listExportSOPScenariosContextMenuItem.Unselect.Label}'.`,
  selectScenarioViaMenu: (scenarioName: string): string => `In list '${ListExportSOPScenarios.title}', right click scenario '${scenarioName}' and select menu '${listExportSOPScenariosContextMenuItem.Select.Label}'.`,
  verifyScenarioSelected: (scenarioName: string, expectedSelected: boolean): string => `In list '${ListExportSOPScenarios.title}', verify scenario '${scenarioName}' selected = ${expectedSelected}.`,
};
 
export { listExportSOPScenariosContextMenuItem as ListExportSOPScenariosContextMenuItem };
export { stepDialogExportSOPReports as StepDialogExportSOPReports };