Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 4 Next »

While using Cypress, in order to add/modify entries in PP tables through Pricefx APIs( instead of the gui), we just need to carry out the following steps:

  1. Add the following command to commands.js of Cypress

 

Cypress.Commands.add('insertDataToPPTable', (file) => {

  // read the file which contains details on: the username/partition, password, pp table id(into which data will be inserted) and the json file which contains data to be inserted into the PP table

  const readParamsJson = require('../fixtures'+file)

  //read the data to be inserted into the selected PP table

  const allData = require('../fixtures/'+readParamsJson.fileName)

 

  //read the configurations for username/partition and password from cypress.json

  

       

   //looping the json data file to insert the rows one by one  

  allData.forEach((row) =>{

     

      cy.request({

          url:`${Cypress.env('apiBaseUrl')}`+readParamsJson.username.substr(0, readParamsJson.username.indexOf('/'))+"/lookuptablemanager.add/"+readParamsJson.tableId,

          method: "POST",

          auth: {

              "username": readParamsJson.username,

              "password": readParamsJson.password

          },

 

          body:{

 

              "data": row

          }

   

      })

 

      .its("status")

      .should("eq", 200);

 

  });

 

  1. Note that the command takes one string parameter, which contains the relative path (from fixtures folder)to a json file. The json file is expected to be present in the fixtures folder of the cypress project. It should contain details as shown in the sample below

{

    "username":"<partition>/<loginName>",

    "password":"<password>",

    "tableId" : 174,

    "fileName":"PPTableData/UserHierarchy-Customer/PPData.json"

}

 

 

Note the following about the parameters in the file:

a)       Username is combination of {partition}/{loginName}

b)      Password is the password associated with the loginName used in step 1

c)       tableId is the id of the PP table into which the data needs to be inserted. The table id can be found using the following request in postman(refer to the screenshot below for an example):

(info) https://<urlOfTheCustomerApplication>/pricefx/automation/lookuptablemanager.fetch

 

 

While sending the above request, “Authorization” should be set as shown in the screenshot below(using appropriate {partition name}/{loginName} and {password})

The response “body” will have an array of json elements, one per PP table present in the system. Each element gives details about the PP table including the PP table id as shown in the example below

{

                "version": 9,

                "typedId": "174.LT",

                "uniqueName": "UserHierarchy-Customer",

                "label": "General - User Hierarchy Customer",

                "validAfter": "2000-01-01",

                "status": "ACTIVE",

                "simulationSet": null,

                "type": "MATRIX",

                "valueType": "MATRIX6",

                "nodeId": 16,

                "userGroupEdit": "SDM_Edit,PBM_Edit,RBMEdit",

                "userGroupViewDetails": "SDM_View,PBM_View,RBMView",

                "hideWarnings": false,

                "formatType": null,

                "lastUpdateByName": "pfx.jenkins",

                "createdByName": "pfx.jenkins",

                "numberOfKeyFields": 6,

                "createDate": "2020-10-27T07:03:37",

                "createdBy": 318,

                "lastUpdateDate": "2021-08-02T14:10:48",

                "lastUpdateBy": 447,

                "id": 174,

                "isPlasma": false

            }

 

Value of the field “id” is is the id of the table whose “uniqueName” is UserHierarchy-Customer

 

d)      fileName is the relative path (from fixtures folder)to the file which contains the actual data to be inserted into the PP table identified above. Format of the file for a Matrix6 PP table is as below(multiple rows can be inserted in one go):

[

    {"key1":"SE01",

     "key2":"Default",

     "key3":"ISO",

     "key4":"S62",

     "key5":"Test",

     "key6":"Admin"

 

     },

{"key1":"SE02",

     "key2":"Default",

     "key3":"ISO1",

     "key4":"S62",

     "key5":"Test",

     "key6":"Admin"

 

     }

 

 ]

      

  1. In the cypress testcase, the command can be called as shown below:

describe('userHierarchyTableTest', () => {

  

   

 

    it('userHierarchy', () => {

        cy.insertDataToPPTable("/PPTableData/UserHierarchy-Product/BasicDetails.json")

        cy.insertDataToPPTable("/PPTableData/UserHierarchy-Customer/BasicDetails.json")

 

       

    });

});

  • No labels