const TypeID = '113.PL';//Type ID of the PL or LPG
const ID = '113';//ID of the PL or LPG
const ProductTypeID = '4846.PLI';//ypeId (hidden column) of the product
const attribute = 'resultPrice';//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-submit,approve,revoke', () => {
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) open PL and change price (manual override)
//2) go back to PL overview and submit our PL
//3) open PL and check, that manual override is now not possible
//4) go back to PL overview and Approve out PL
//5) open PL and check, that manual override is now not possible
//6) go back to PL overview and revoke our PL
//7) open PL and change price (manual override)
//-------------------------------------------//
//1) open PL and change price (manual override)
//-------------------------------------------//
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();
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="manualResultPrice"]`).as('manualResultPrice');
//override it's price
cy.get('@manualResultPrice').dblclick();
cy.get('.ant-input-number-input')
.clear()
.type('5' + '{enter}');
//verify the new price
cy.get('[data-test=module-header-button-menu] > :nth-child(5)').click();
cy.waitForSpinner();
cy.get('@manualResultPrice').should('contain', '5.00');
cy.get(`[data-row-key="${ProductTypeID}"] [data-test-column="${attribute}"]`).should('contain', '5.00 EUR');
//-------------------------------------------//
//2) go back to PL overview and submit our PL
//-------------------------------------------//
cy.contains('a', 'Price Lists').click({ force: true });
cy.waitForSpinner();
//click on button submit
cy.contains('button', 'Submit')
.click({ force: true });
//click on Yes and check that item has workFlowStatus = Submited
cy.get('.ant-modal-body')
.contains('button', 'Yes').click({ force: true });
cy.waitForSpinner();
cy.get(`[data-row-key="${TypeID}"] [data-test-column="workflowStatus"]`).should('contain', 'Submitted');
//-------------------------------------------//
//3) open PL and check, that manual override is now not possible
//-------------------------------------------//
cy.get(`[data-row-key="${TypeID}"]`)//find row key for our PL/LPG
.contains(ID)
.click({ force: true });
cy.waitForSpinner();
//check that manual override is not possible
cy.get('@manualResultPrice').dblclick(); //@manualResulPrice is alias described above in 1. step
cy.get('.ant-input-number-input').should('not.be.visible');
//-------------------------------------------//
//4) go back to PL overview and Approve out PL
//-------------------------------------------//
cy.contains('a', 'Price Lists').click({ force: true });
cy.waitForSpinner();
//click on button submit
cy.contains('button', 'View Workflow')
.click({ force: true });
cy.waitForSpinner();
cy.get('.ant-table-fixed-right')
.find('[data-test-column="approve"]').click();
cy.waitForSpinner();
cy.contains('button', 'OK')
.click({ force: true });
cy.waitForSpinner();
cy.get('.ant-modal-close-x').first().click({ force: true });
//-------------------------------------------//
//5) open PL and check, that manual override is now not possible
//-------------------------------------------//
cy.get(`[data-row-key="${TypeID}"] [data-test-column="workflowStatus"]`).should('contain', 'Approved');
cy.get(`[data-row-key="${TypeID}"]`)//find row key for our PL/LPG
.contains(ID)
.click({ force: true });
cy.waitForSpinner();
//check that manual override is not possible
cy.get('@manualResultPrice').dblclick(); //@manualResulPrice is alias described above in 1. step
cy.get('.ant-input-number-input').should('not.be.visible');
//-------------------------------------------//
//6) go back to PL overview and revoke our PL
//-------------------------------------------//
cy.contains('a', 'Price Lists').click({ force: true });
cy.waitForSpinner();
cy.get(`[data-row-key="${TypeID}"]`)//select
.click({ force: true });
cy.contains('button', 'Revoke')
.click({ force: true });
cy.waitForSpinner();
cy.get(`[data-row-key="${TypeID}"] [data-test-column="approvalState"]`).should('contain', 'Not approved');
//-------------------------------------------//
//7) open PL and change price (manual override)
//-------------------------------------------//
cy.get(`[data-row-key="${TypeID}"]`)//find row key for our PL/LPG
.contains(ID)
.click({ force: true });
cy.waitForSpinner();
//override it's price
cy.get('@manualResultPrice').dblclick();
cy.get('.ant-input-number-input')
.clear()
.type('6' + '{enter}');
//verify the new price
cy.get('[data-test=module-header-button-menu] > :nth-child(5)').click();
cy.waitForSpinner();
cy.get('@manualResultPrice').should('contain', '6.00');
cy.get(`[data-row-key="${ProductTypeID}"] [data-test-column="${attribute}"]`).should('contain', '6.00 EUR');
});
});
|