haorenhui
2023-10-30 6d6cc10d9e8e242661da7fd655dec155a09d676c
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
73
74
75
76
77
78
79
80
/**
 * @file        ADSO-9599
 * @description Create and delete recipe assignment with effective date
 * @author      Chan Clarence (ccn7@3ds.com)
 * @copyright   Dassault Systèmes
 */
import { AppMP, Demo, Scenario } from '../../libmp/appmp';
import { qCustomMatcher } from '../../e2elib/lib/src/main/qmatchers.const';
import { StepList } from '../../libappsop/listsop';
import { DataMetalBaseProductName } from '../../libmp/data/data.product';
import { DataMetalBaseRecipeName } from '../../libmp/data/data.recipe';
import { DialogRecipeAssignmentFields, okButtonDisabledTooltip } from '../../libmp/dialogs/dialog.recipeassignment';
import { ListRecipeAssignment, ListRecipeAssignmentColumn, ListRecipeAssignmentContextMenuItem } from '../../libmp/forms/form.recipeassignment';
 
describe('ADSO-9599 - Create and delete recipe assignment with effective date', () => {
  const appMP = AppMP.getInstance();
  const listRecipeAssignment = appMP.viewRecipes.formRecipeAssignment.listRecipeAssignment;
  const recipeName = DataMetalBaseRecipeName._5XXX;
  const productName = DataMetalBaseProductName.MoltenAluminium3XXX;
  const effectiveDate = '1-Jun-2021';
  const effectiveDateForPrecondition = 'Jun-1-2021';
 
  const rowListRecipeAssignment: ListRecipeAssignmentColumn = { 'Product name': productName, 'Recipe name': recipeName, 'Effective date': effectiveDate };
  const inputDlgRecipeAssignment: DialogRecipeAssignmentFields = { Product: productName, Recipe: recipeName, EffectiveDate: effectiveDate };
 
  beforeAll(async () => {
    jasmine.addMatchers(qCustomMatcher);
    await appMP.login();
  });
 
  afterAll(async () => {
    await appMP.viewRecipes.reset();
    await appMP.cleanupAndLogout();
  });
 
  afterEach(async () => {
    await appMP.checkToastMessage();
  });
 
  describe('Create recipe assignment with effective date', () => {
    it(`Step 1 - ${AppMP.getDemoDataPath(Demo.Metals, Scenario.Base)}`, async () => {
      await appMP.createDemoDataset(Demo.Metals, Scenario.Base, false);
    });
 
    it(`Step 2 - Open view ${appMP.viewRecipes.viewPath}`, async () => {
      await appMP.viewRecipes.switchTo();
    });
 
    it(`Step 3 - In Recipe Assignments list, right click and select "Create" menu.<br>
        In dialog, set Product = "${productName}", Recipe = "${recipeName}" and Effective date = "${effectiveDate}". Click OK to create.`, async () => {
      const [dlgRecipeAssignment] = await listRecipeAssignment.selectContextMenu(ListRecipeAssignmentContextMenuItem.Create);
      await dlgRecipeAssignment.updateDialogValues(inputDlgRecipeAssignment);
      await dlgRecipeAssignment.clickOK();
    });
 
    it('Step 4 - Verify recipe assignment created correctly.', async () => {
      await listRecipeAssignment.verifyRowExists(rowListRecipeAssignment);
    });
 
    it(`Step 5 - Click "Create" menu to bring up dialog again.<br>
        Set the same values as previous step and verify OK disabled with precondition = "${okButtonDisabledTooltip.notUnique(productName, effectiveDateForPrecondition)}".
        Click Cancel to dismiss dialog.`, async () => {
      const [dlgRecipeAssignment] = await listRecipeAssignment.selectContextMenu(ListRecipeAssignmentContextMenuItem.Create);
      await dlgRecipeAssignment.updateDialogValues(inputDlgRecipeAssignment);
      await dlgRecipeAssignment.verifyOKDisabled(okButtonDisabledTooltip.notUnique(productName, effectiveDateForPrecondition), true);
      await dlgRecipeAssignment.clickCancel();
    });
  });
 
  describe('Delete recipe assignment with effective date', () => {
    it(`Step 1 - ${StepList.selectRowAndClickMenu(ListRecipeAssignment.title, rowListRecipeAssignment, ListRecipeAssignmentContextMenuItem.Delete.Label)}`, async () => {
      const row = await listRecipeAssignment.getRow(rowListRecipeAssignment);
      await listRecipeAssignment.selectContextMenu(ListRecipeAssignmentContextMenuItem.Delete, row);
    });
 
    it(`Step 2 - ${StepList.verifyRowNotExist(ListRecipeAssignment.title, rowListRecipeAssignment)}`, async () => {
      await listRecipeAssignment.verifyRowNotExist(rowListRecipeAssignment);
    });
  });
});