I'm facing an issue which I couldn't solve yet and wanted to get some opinions from you. I've a selector which has two options in total and I'm using select to switch between them. I wasn't sure about the code so I added url check as well, which works successfully.
However, the page loads with the first selection so the api call has already been made, but, in the second part (items section) when I select Items it throws 401 error and logs out which breaks all the following tests.
What can I do/improve here? This flow works perfectly on my local but Cypress fails.
Things I've tried:
0 and 1 without value names.https://www.youtube.com/watch?v=b8aoVh6IdCgThanks in advance!
it('verifies there are only orders, drafts and/or return orders on all orders grid', () => {
ordersPage.ordersSelector().trigger('click')
cy.get('select').select('orders').should('have.value', 'orders');
cy.url()
.should('include', 'orders');
const orderNumberPrefix = ['DRAFT-', 'SO0', 'S0-', 'R0']
cy.get('.ag-center-cols-container div[row-index]')
.each($row =>{
const $col = $row.find('[col-id="orderNumber"]')
const orderNumber = $col.text().trim()
const correctOrderNumberPrefix = orderNumberPrefix.some(prefix => {
return orderNumber.startsWith(prefix)
})
expect(correctOrderNumberPrefix).to.be.true;
});
})
it('verifies there are only orders on items grid', () => {
ordersPage.ordersSelector()
cy.get('select').select('items').should('have.value', 'items'); //fails here
cy.url()
.should('include', 'items');
const orderNumberPrefix = ['SO0']
cy.get('.ag-center-cols-container div[row-index]')
.each($row =>{
const $col = $row.find('[col-id="orderNumber"]')
const orderNumber = $col.text().trim()
const correctOrderNumberPrefix = orderNumberPrefix.some(prefix => {
return orderNumber.startsWith(prefix)
})
expect(correctOrderNumberPrefix).to.be.true;
});
})