salix-front/test/cypress/integration/vnSearchBar.spec.js

37 lines
1.1 KiB
JavaScript
Raw Normal View History

2024-01-09 11:06:17 +00:00
/// <reference types="cypress" />
describe('VnSearchBar', () => {
const employeeId = ' #1';
const salesPersonId = ' #18';
const idGap = '.q-item > .q-item__label';
2024-07-01 07:29:55 +00:00
const vnTableRow = '.q-virtual-scroll__content';
2024-01-09 11:06:17 +00:00
beforeEach(() => {
cy.login('developer');
cy.visit('#/customer/list');
});
it('should redirect to customer summary page', () => {
searchAndCheck('1', employeeId);
searchAndCheck('salesPerson', salesPersonId);
});
it('should stay on the list page if there are several results or none', () => {
cy.writeSearchbar('salesA{enter}');
2024-07-01 07:29:55 +00:00
checkTableLength(2);
cy.clearSearchbar();
cy.writeSearchbar('0{enter}');
2024-07-01 07:29:55 +00:00
checkTableLength(0);
2024-01-09 11:06:17 +00:00
});
const searchAndCheck = (searchTerm, expectedText) => {
cy.clearSearchbar();
cy.writeSearchbar(`${searchTerm}{enter}`);
cy.get(idGap).should('have.text', expectedText);
};
2024-07-01 07:29:55 +00:00
const checkTableLength = (expectedLength) => {
cy.get(vnTableRow).find('tr').should('have.length', expectedLength);
};
2024-01-09 11:20:56 +00:00
});