salix-front/test/cypress/integration/vnComponent/VnSearchBar.spec.js

40 lines
1.2 KiB
JavaScript
Raw Permalink Normal View History

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