2024-01-09 11:06:17 +00:00
|
|
|
/// <reference types="cypress" />
|
|
|
|
describe('VnSearchBar', () => {
|
2024-03-27 10:14:54 +00:00
|
|
|
const employeeId = ' #1';
|
|
|
|
const salesPersonId = ' #18';
|
|
|
|
const idGap = '.q-item > .q-item__label';
|
|
|
|
const cardList = '.vn-card-list';
|
|
|
|
|
|
|
|
let url;
|
2024-01-09 11:06:17 +00:00
|
|
|
beforeEach(() => {
|
|
|
|
cy.login('developer');
|
2024-03-27 10:14:54 +00:00
|
|
|
cy.visit('#/customer/list');
|
|
|
|
cy.url().then((currentUrl) => (url = currentUrl));
|
|
|
|
});
|
|
|
|
|
|
|
|
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}');
|
|
|
|
checkCardListAndUrl(2);
|
|
|
|
|
|
|
|
cy.clearSearchbar();
|
|
|
|
|
|
|
|
cy.writeSearchbar('0{enter}');
|
|
|
|
checkCardListAndUrl(0);
|
2024-01-09 11:06:17 +00:00
|
|
|
});
|
|
|
|
|
2024-03-27 10:14:54 +00:00
|
|
|
const searchAndCheck = (searchTerm, expectedText) => {
|
|
|
|
cy.clearSearchbar();
|
|
|
|
cy.writeSearchbar(`${searchTerm}{enter}`);
|
|
|
|
cy.get(idGap).should('have.text', expectedText);
|
|
|
|
};
|
|
|
|
|
|
|
|
const checkCardListAndUrl = (expectedLength) => {
|
|
|
|
cy.get(cardList).then(($cardList) => {
|
|
|
|
expect($cardList.find('.q-card').length).to.equal(expectedLength);
|
2024-04-08 13:15:18 +00:00
|
|
|
cy.url().then((currentUrl) => expect(currentUrl).to.contain(url));
|
2024-01-09 11:06:17 +00:00
|
|
|
});
|
2024-03-27 10:14:54 +00:00
|
|
|
};
|
2024-01-09 11:20:56 +00:00
|
|
|
});
|