Lai,Risheng
2023-11-02 30c02e0c981b16be0918483543f4b812956c45d4
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
/**
 * @file        ADSO-50244
 * @description Delete customer orders
 * @author      Clarence (ccn7@3ds.com)
 * @copyright   Dassault Systèmes
 */
import { AppMP, StepAppMP } from '../../libmp/appmp';
import { DataMetalBaseSalesSegmentName } from '../../libmp/data/data.salessegment';
import { DataMetalBaseProductName } from '../../libmp/data/data.product';
import { DataMetalStockingPointName } from '../../libmp/data/data.stockingpoint';
import { StepList } from '../../libappsop/listsop';
import { StepActionBarPage } from '../../libappsop/actionbarpagesop';
import { ListCustomerOrdersColumn, ListCustomerOrdersContextMenuItem } from '../../libmp/forms/form.customerorders';
import { startOfPlanningYear } from '../../libmp/data/data.period';
 
describe('ADSO-50244 - Delete customer orders', () => {
  const appMP = AppMP.getInstance();
  const scenarioToSelect = 'ADSO-50244';
  const janSOP = `1-Jan-${startOfPlanningYear}`;
  const listCustomerOrders = appMP.viewCustomerOrders.formCustomerOrders.listCustomerOrders;
  const deleteRows: ListCustomerOrdersColumn[] = [{'Sales segment': DataMetalBaseSalesSegmentName.CanManChina, Product: DataMetalBaseProductName.BCCBWide, 'Stocking point': DataMetalStockingPointName.Asia, 'Order date': janSOP, Quantity: '100'},
                                                  {'Sales segment': DataMetalBaseSalesSegmentName.CanManChina, Product: DataMetalBaseProductName.BCCBWide, 'Stocking point': DataMetalStockingPointName.Asia, 'Order date': janSOP, Quantity: '200'}];
 
  beforeAll(async () => {
    await appMP.login();
  });
 
  afterAll(async () => {
    await appMP.resetActiveView(appMP.viewCustomerOrders);
    await appMP.cleanupAndLogout();
  });
 
  afterEach(async () => {
    await appMP.checkToastMessage();
  });
 
  it(`Step 1 - ${StepAppMP.selectScenario(scenarioToSelect)}`, async () => {
    await appMP.selectScenario(scenarioToSelect);
  });
 
  it(`Step 2 - Open view ${appMP.viewCustomerOrders.viewPath}.`, async () => {
    await appMP.viewCustomerOrders.switchTo();
  });
 
  it(`Step 3 - ${StepList.selectRows(listCustomerOrders.title, deleteRows)} ${StepActionBarPage.clickButton('Delete')}`, async () => {
    const rows = await listCustomerOrders.selectListRows(deleteRows);
    await listCustomerOrders.clickActionButton(appMP.abpSales.btnDelete, undefined, rows);
  });
 
  it(`Step 4 - ${StepList.verifyRowNotExist(listCustomerOrders.title, deleteRows[0])} ${StepList.verifyRowNotExist(listCustomerOrders.title, deleteRows[1])}`, async () => {
    await listCustomerOrders.verifyRowNotExist(deleteRows[0]);
    await listCustomerOrders.verifyRowNotExist(deleteRows[1]);
  });
 
  it(`Step 5 - ${StepList.selectAllRowsAndClickMenu(listCustomerOrders.title, ListCustomerOrdersContextMenuItem.Delete.Label)}`, async () => {
    await listCustomerOrders.selectAllAndSelectContextMenu(ListCustomerOrdersContextMenuItem.Delete);
  });
 
  it(`Step 6 - ${StepList.verifyTotalRow(listCustomerOrders.title, 0)}`, async () => {
    await listCustomerOrders.verifyTotalRow(0, 'Expected no more customer order in list after deleting all rows.');
  });
 
  it(`Step 7 - ${StepList.verifyContextMenuDisabled(listCustomerOrders.title, ListCustomerOrdersContextMenuItem.Delete.Label)}`, async () => {
    await listCustomerOrders.verifyContextMenuDisabled(ListCustomerOrdersContextMenuItem.Delete);
  });
 
  it(`Step 8 - ${StepActionBarPage.verifyButtonDisabled('Delete')}`, async () => {
    await appMP.abpSales.btnDelete.verifyEnabled(false);
  });
});