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 2 Next »

  • variables

  • API login

Test case

  //1) Find PL id 112, Label = Cypress 
  //2) open PL and check strategy for product MB-003 (data-row-key = 112.PL) and check, that strategy is Competitor based 
  //3) Go to PP table, open PriceStrategy table and change 1st strategy strategy on row "Meatball" from "Competitor based" to "CostPlus" 
  //4) Go back to PL and recalculate our "cypress" PL 
  //5) Open PL and check, that strategy has been changed to "CostPlus" 
  //6) Go back to PP table PriceStrategy and change again row "Meatball" to previous state (from "CostPlus" to "Competitor based") 
  //7) Go back to LPG and recalculate our "cypress" PL 

Code

const TypeID = '112.PL';//Type ID of the PL or LPG
const ID = '112';//ID of the PL or LPG
const ProductTypeID = '4845.PLI';//ypeId (hidden column) of the product
const attribute = 'attribute4';//column attribute


//Js code for LPG calculation handling - it needs to be above cypress code or in different file
cy.waitForCalculation = LPGstatus => {
  cy.get(`[data-row-key="${TypeID}"]`).each(row => {
    if (row.html().includes('Ready')) {
      return Promise.resolve(true);
    } else {
      cy.get('[data-test=module-header-button-menu] > :nth-child(2)').click();
      cy.waitForSpinner();
      cy.waitForCalculation(LPGstatus);
    }
  });
};

describe('PL test', () => {
  before(() => {
    cy.login('demoPartition');//API login ("demoPartition" is the setting configured in file users.js)
  });

  beforeEach(() => {
    // Configure 'X-PriceFx-Csrf-Token' and 'X-PriceFx-jwt' cookies to be preserved after each test.
    Cypress.Cookies.preserveOnce('X-PriceFx-Csrf-Token', 'X-PriceFx-jwt');
    // Restore the logged in status by restoring the local storage
    cy.restoreLocalStorage().then(() => {
      cy.waitForSpinner();
    });
  });

  //1) Find PL id 112, Label = Cypress 
  //2) open PL and check strategy for product MB-003 (data-row-key = 112.PL) and check, that strategy is Competitor based 
  //3) Go to PP table, open PriceStrategy table and change 1st strategy strategy on row "Meatball" from "Competitor based" to "CostPlus" 
  //4) Go back to PL and recalculate our "cypress" PL 
  //5) Open PL and check, that strategy has been changed to "CostPlus" 
  //6) Go back to PP table PriceStrategy and change again row "Meatball" to previous state (from "CostPlus" to "Competitor based") 
  //7) Go back to LPG and recalculate our "cypress" PL 

  //1) Find PL id 112, Label = Cypress 
  it('PL', () => {
    cy.visit('/#/pb/pl');
    cy.waitForSpinner();

    cy.contains('.ucTableHeaderColumnContextMenu', 'ID')
      .find('[data-test="quickFilter-input"]')//click on the quick filter
      .type(ID + '{enter}', { force: true });
    cy.waitForSpinner();

    //2) open PL and check strategy for product MB-003 (data-row-key = 112.PL) and check, that strategy is Competitor based 
    cy.get(`[data-row-key="${TypeID}"]`)//find row key for our PL/LPG
      .contains(ID)
      .click({ force: true });
    cy.waitForSpinner();

    cy.get(`[data-row-key="${ProductTypeID}"] [data-test-column="${attribute}"]`).should('contain', 'Competitor Based');


    //3) Go to PP table, open PriceStrategy table and change 1st strategy strategy on row "Meatball" from "Competitor based" to "CostPlus" 
    cy.visit('/#/md/priceparameters/2366');
    cy.url().should('contain', '/#/md/priceparameters/2366');
    cy.waitForSpinner();
    cy.get('[data-row-key="193.MLTV"]')
      .contains('Competitor Based').dblclick({ force: true })
    cy.contains('li', 'Cost Plus').click({ force: true });
    cy.contains('tr', 'Meatball').should('contain', 'Cost Plus');


    //4) Go back to PL and recalculate our "cypress" PL 
    cy.visit('/#/pb/pb');
    cy.waitForSpinner();

    cy.contains('.ucTableHeaderColumnContextMenu', 'ID')
      .find('[data-test="quickFilter-input"]')//click on the quick filter
      .type(ID + '{enter}', { force: true });
    cy.waitForSpinner();

    cy.get(`[data-row-key="${TypeID}"]`)//select
      .click({ force: true });
    cy.contains('button', 'Calculate')
      .click({ force: true });
    cy.get(`[data-row-key="${TypeID}"]`)//uncheck
      .click({ force: true });
    cy.waitForSpinner();
    cy.waitForCalculation();

    //5) Open PL and check, that strategy has been changed to "CostPlus" 
    cy.get(`[data-row-key="${TypeID}"]`)//find row key for our PL/LPG
      .contains(ID)//find string on this row key
      .click({ force: true });
    cy.waitForSpinner();

    cy.get(`[data-row-key="${ProductTypeID}"] [data-test-column="${attribute}"]`).should('contain', 'Cost Plus');


    //6) Go back to PP table PriceStrategy and change again row "Meatball" to previous state (from "CostPlus" to "Competitor based") 
    cy.visit('/#/md/priceparameters/2366');
    cy.url().should('contain', '/#/md/priceparameters/2366');
    cy.waitForSpinner();

    cy.get('[data-row-key="193.MLTV"]')
      .contains('Cost Plus').dblclick({ force: true })
    cy.contains('li', 'Competitor Based').click({ force: true });
    cy.contains('tr', 'Meatball').should('contain', 'Competitor Based');

    //7) Go back to LPG and recalculate our "cypress" PL 

    cy.visit('/#/pb/pl');
    cy.waitForSpinner();

    cy.contains('.ucTableHeaderColumnContextMenu', 'ID')
      .find('[data-test="quickFilter-input"]')//click on the quick filter
      .type(ID + '{enter}', { force: true });
    cy.waitForSpinner();

    cy.get(`[data-row-key="${TypeID}"]`)//select
      .click({ force: true });
    cy.contains('button', 'Calculate')
      .click({ force: true });
    cy.get(`[data-row-key="${TypeID}"]`)//uncheck
      .click({ force: true });
    cy.waitForSpinner();
    cy.waitForCalculation();

  });
});

Download test

  • No labels