/** 
 | 
 * @file         ADSO-10192 
 | 
 * @description  Inventory account display relevant account 
 | 
 * @testcategory Web - Financials - Inventory 
 | 
 * @author       Gay Er Xuan (erxuan.gay@3ds.com) 
 | 
 * @copyright    Dassault Systèmes 
 | 
 */ 
 | 
import { qCustomMatcher } from '../../../e2elib/lib/src/main/qmatchers.const'; 
 | 
import { AppMP, Demo, Scenario } from '../../../libmp/appmp'; 
 | 
import { ListRow } from '../../../e2elib/lib/src/pageobjects/list/listrow.component'; 
 | 
import { ListAccountColumn } from '../../../libmp/forms/form.inventoryaccounts'; 
 | 
import { DataFoodBaseAccountName } from '../../../libmp/data/data.account'; 
 | 
import { LogMessage } from '../../../libappbase/logmessage'; 
 | 
import { DataInventoryAccount, DataInventoryCostCostDriver } from '../../../libmp/data/data.inventorycost'; 
 | 
  
 | 
describe('ADSO-10192 - Inventory account display relevant account', () => { 
 | 
  const appMP = AppMP.getInstance(); 
 | 
  const inventoryAccs = [DataInventoryAccount.InventoryHoldingCost, DataInventoryAccount.InventoryValue, DataInventoryAccount.InventoryLocationPreferenceCost]; 
 | 
  const costDrivers = [DataInventoryCostCostDriver.InventoryHolding, DataInventoryCostCostDriver.InventoryValue]; 
 | 
  
 | 
  beforeAll(async () => { 
 | 
    jasmine.addMatchers(qCustomMatcher); 
 | 
    await appMP.login(); 
 | 
  }); 
 | 
  
 | 
  afterAll(async () => { 
 | 
    // Reset view 
 | 
    await appMP.viewAccount.reset(); 
 | 
    await appMP.cleanupAndLogout(); 
 | 
  }); 
 | 
  
 | 
  afterEach(async () => { 
 | 
    await appMP.checkToastMessage(); 
 | 
  }); 
 | 
  
 | 
  it(`Setup - ${AppMP.getDemoDataPath(Demo.Food, Scenario.Base)}`, async () => { 
 | 
    await appMP.createDemoDataset(Demo.Food, Scenario.Base, false); 
 | 
  }); 
 | 
  
 | 
  it(`Step 1 - Open view ${appMP.viewInventoryCosts.viewPath}, then verify Inventory Accounts list showing columns Account, Default value and Default UoM with ${inventoryAccs.length} accounts: ${inventoryAccs.join(', ')}`, async () => { 
 | 
    // Switch to inventory cost view 
 | 
    await appMP.viewInventoryCosts.switchTo(); 
 | 
    const listInventoryAccount = appMP.viewInventoryCosts.frmInventoryAccounts.lstAccounts; 
 | 
    const listName = 'inventory account list'; 
 | 
    // Verify Account, Default value, and Default UoM column is shown in the list 
 | 
    expect(await listInventoryAccount.getColumnByValue(ListAccountColumn.Account)).toBeDefined(LogMessage.list_columnNotExist(ListAccountColumn.Account, listName)); 
 | 
    expect(await listInventoryAccount.getColumnByValue(ListAccountColumn.DefaultValue)).toBeDefined(LogMessage.list_columnNotExist(ListAccountColumn.DefaultValue, listName)); 
 | 
    expect(await listInventoryAccount.getColumnByValue(ListAccountColumn.DefaultUoM)).toBeDefined(LogMessage.list_columnNotExist(ListAccountColumn.DefaultUoM, listName)); 
 | 
    // Verify the account number in the list 
 | 
    expect(await listInventoryAccount.getRowCount()).toBe(inventoryAccs.length, `The number of account in inventory account list should be ${inventoryAccs.length}`); 
 | 
    // Verify each of the account is in the list 
 | 
    for (const inventoryAcc of inventoryAccs) { 
 | 
      const accRow: ListRow | undefined = await listInventoryAccount.getAccountByName(inventoryAcc).catch(() => undefined); 
 | 
      expect(accRow).toBeDefined(`${inventoryAcc} should exist in the list`); 
 | 
    } 
 | 
  }); 
 | 
  
 | 
  it(`Step 2 - Open view ${appMP.viewAccount.viewPath}, then verify the ${inventoryAccs.length} accounts have any one of these cost drivers: ${costDrivers.join(', ')}`, async () => { 
 | 
    await appMP.viewAccount.switchTo(); 
 | 
    // Expand row 
 | 
    const listAccount = appMP.viewAccount.frmAccount.listAccount; 
 | 
    await (await listAccount.getRow({ Name: DataFoodBaseAccountName.CostOfSales })).expandRow(); 
 | 
    // Verify account and cost driver match 
 | 
    for (const inventoryAcc of inventoryAccs) { 
 | 
      expect(await listAccount.isAccountCostDriverMatch(inventoryAcc, costDrivers)).toBe(true, `${inventoryAcc} should have any one of these cost drivers: ${costDrivers.join(', ')}`); 
 | 
    } 
 | 
  }); 
 | 
}); 
 |