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
import { Form } from '../../e2elib/lib/src/pageobjects/form.component';
import { DialogCurrency } from '../dialogs/dialog.currency';
import { ListSOP } from '../../libappsop/listsop';
 
/**
 * Currency form.
 */
export class FormCurrency extends Form {
  public listCurrency = new ListCurrency();
 
  public constructor() {
    super('FormCurrency');
  }
}
 
/**
 * Currency list in Currency form.
 */
class ListCurrency extends ListSOP<DialogCurrency, ListCurrencyColumn> {
  public constructor() {
    super('ListCurrency', new DialogCurrency());
 
    // Set primary key column name(s), to display in error message when assert fails
    this.rowPrimaryColumnNames = {Name: ''};
  }
 
  /**
   * Verify first row is base currency (bold text for Name column) while the other rows are non-bold.
   *
   * @param baseCurrency Base currency name to verify the first row.
   */
  public async verifyFirstRowBaseCurrency(baseCurrency: string): Promise<void> {
    const totalRows = await this.getRowCount();
    for (let x = 0; x < totalRows; x++) {
      const row = await this.getRowByIndex(x);
      // Verify 1st row is the base currency and bold
      if (x === 0) {
        await this.verifyRowValues(row, {Name: baseCurrency});
        await this.verifyRowCellBold(row, {Name: 'true'});
      } else {
        // Non-base currency is NOT bold
        await this.verifyRowCellBold(row, {Name: 'false'});
      }
    }
  }
}
 
export interface ListCurrencyColumn {
  Name?: string;
  Base?: string; // Image attribute to indicate if base currency
}
 
const listCurrencyContextMenuItem = {
  Create: { ContextMenu: 'listContextMenuCurrency', Name: 'MenuCreate', Label: 'Create' },
  Delete: { ContextMenu: 'listContextMenuCurrency', Name: 'MenuDelete', Label: 'Delete' },
  SetAsBase: { ContextMenu: 'listContextMenuCurrency', Name: 'MenuSetAsBase', Label: 'Set as base' },
};
 
export { listCurrencyContextMenuItem as ListCurrencyContextMenuItem };
 
/**
 * Disabled context menu tooltip.
 */
export const menuDisabledTooltip = {
  // Partial prefix indicates precondition defined partially thus use partial match when verifying.
  currencyIsDefault: (): string => 'Base currencies are used to determine the value of other currencies and cannot be deleted.',
  currencyInUse: (currencyName: string): string => `Currency ${currencyName} is in use.`,
};