Skip to end of metadata
Go to start of metadata

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

Compare with Current View Version History

« Previous Version 4 Current »

Precondition

  • You need to have login and correct struncture of the .spec.js file in your test (API or FE) - see this page: NEW-Login

How to open LPG

From LPG main page

  1. write “cypress“ into label

  2. find data-row-key and on this row find label “cypress“

  3. click on label “cypress“

  it('LPG', () => {
    cy.visit('/#/pb/lpgs');
    cy.url().should('contain', '/#/pb/lpgs'); //assert
    cy.waitForSpinner();

    //Open LPG with label "cypress"
    const LPGlabel = 'cypress';

    cy.contains('.ucTableHeaderColumnContextMenu', 'Label')
      .find('[data-test="quickFilter-input"]')//click on the quick filter
      .type(LPGlabel + '{enter}', { force: true }); //variable
      cy.waitForSpinner();
      cy.get('[data-row-key="16.PG"]')//find row key for our LPG
      .contains(LPGlabel)//find string on this row key
      .click({ force: true });//click
  cy.waitForSpinner();
  cy.contains('[data-test=ucBreadcrumbs]', LPGlabel);//assert for breadcrumbs
  });

Open LPG via URL

  1. put URL of the LPG

  2. Check that URL is successfully loaded and breadcrumbs contains name of the LPG

  it('LPG', () => {
    const LPGlabel = 'cypress';
    
    cy.visit('/#/pb/lpgs/16/detail');
    cy.url().should('contain', '/#/pb/lpgs/16/detail'); //assert
    cy.waitForSpinner();
  cy.contains('[data-test=ucBreadcrumbs]', LPGlabel);//assert for breadcrumbs
  });

Test cases

Test case

  //Products
  //1) Find LPG id 16, Lable = cypress
  //2) open LPG and check strategy for product MB-0028 (data-row-key = 272.PGI) and check, that strategy is Aggressive
  //3) Go to PP table, open OnlineStrategy table and change strategy on row "Beef" from "aggressive" to "moderate"
  //4) Go back to LPG and recalculate our "cypress" LPG
  //5) Open LPG and check, that strategy has been changed to "moderate"
  //6) Go back to PP table OnlineStrategy and change again row "Beef" to previous state (from "moderate" to "aggressive")
  //7) Go back to LPG and recalculate our "cypress" LPG

Code

  • variables are using in the test.

  • Needs to be changed only on one place

const TypeID = '16.PG';//Type ID of the PL or LPG
const LPGlabel = 'cypress';
const ProductTypeID = '272.PGI';//TypeId (hidden column) of the product
const attribute = 'attribute5';//column attribute which we want to check on PL/LPG


//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('React - Products', () => {
  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();
    });
  });

  //Products
  //1) Find LPG id 16, Lable = cypress
  //2) open LPG and check strategy for product MB-0028 (data-row-key = 272.PGI) and check, that strategy is Aggressive
  //3) Go to PP table, open OnlineStrategy table and change strategy on row "Beef" from "aggressive" to "moderate"
  //4) Go back to LPG and recalculate our "cypress" LPG
  //5) Open LPG and check, that strategy has been changed to "moderate"
  //6) Go back to PP table OnlineStrategy and change again row "Beef" to previous state (from "moderate" to "aggressive")
  //7) Go back to LPG and recalculate our "cypress" LPG

  //1) Find LPG id 16, Lable = cypress
  it('LPG', () => {
    cy.visit('/#/pb/lpgs');
    cy.waitForSpinner();


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

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

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


    //3) Go to PP table, open OnlineStrategy table and change strategy on row "Beef" from "aggressive" to "moderate"
    cy.visit('/#/md/priceparameters/2378');
    cy.url().should('contain', '/#/md/priceparameters/2378');
    cy.waitForSpinner();
    cy.get('[data-row-key="220.MLTV"]')
      .contains('Aggressive').dblclick({ force: true })
    cy.contains('li', 'Moderate').click({ force: true });
    cy.contains('tr', 'Beef').should('contain', 'Moderate');


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

    cy.contains('.ucTableHeaderColumnContextMenu', 'Label')
      .find('[data-test="quickFilter-input"]')//click on the quick filter
      .type(LPGlabel + '{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 LPG and check, that strategy has been changed to "moderate"
    cy.get(`[data-row-key="${TypeID}"]`)//find row key for our PL/LPG
      .contains(LPGlabel)
      .click({ force: true });
    cy.waitForSpinner();

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

    //6) Go back to PP table OnlineStrategy and change again row "Beef" to previous state (from "moderate" to "aggressive")
    cy.visit('/#/md/priceparameters/2378'); //2344 is PP table TargetMargin
    cy.url().should('contain', '/#/md/priceparameters/2378'); //assert
    cy.waitForSpinner();

    cy.get('[data-row-key="220.MLTV"]')
      .contains('Moderate').dblclick({ force: true })
    cy.contains('li', 'Aggressive').click({ force: true });
    cy.contains('tr', 'Beef').should('contain', 'Aggressive');

    //7) Go back to LPG and recalculate our "cypress" LPG
    cy.visit('/#/pb/lpgs');
    cy.waitForSpinner();

    cy.contains('.ucTableHeaderColumnContextMenu', 'Label')
      .find('[data-test="quickFilter-input"]')//click on the quick filter
      .type(LPGlabel + '{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