refactor: streamline filter panel tests with parameterized test cases
gitea/salix-front/pipeline/pr-dev This commit is unstable
Details
gitea/salix-front/pipeline/pr-dev This commit is unstable
Details
This commit is contained in:
parent
2f47bb10aa
commit
da31d6db3b
|
@ -29,94 +29,104 @@ describe('Monitor Tickets Table', () => {
|
|||
cy.clickOption();
|
||||
});
|
||||
});
|
||||
it('should filter by filter panel', () => {
|
||||
// Client id - clientFk
|
||||
cy.dataCy('Client id_input').type('1101');
|
||||
it.only('should filter by filter panel', () => {
|
||||
const testCases = [
|
||||
{
|
||||
name: 'Client id',
|
||||
selector: 'Client id_input',
|
||||
value: '1101',
|
||||
urlParam: 'clientFk',
|
||||
rows: 7,
|
||||
intercept: () => interceptFilterClient(),
|
||||
wait: '@filterClient',
|
||||
},
|
||||
{
|
||||
name: 'Order id',
|
||||
selector: 'Order id_input',
|
||||
value: '7',
|
||||
urlParam: 'orderFk',
|
||||
rows: 1,
|
||||
},
|
||||
{
|
||||
name: 'Days onward',
|
||||
selector: 'Days onward_input',
|
||||
value: '2',
|
||||
urlParam: 'scopeDays',
|
||||
rows: 27,
|
||||
},
|
||||
// ... resto de casos como selects
|
||||
{
|
||||
name: 'Agency',
|
||||
selector: 'Agency_select',
|
||||
value: 'inhouse pickup',
|
||||
urlParam: 'agencyModeFk',
|
||||
rows: 6,
|
||||
isSelect: true,
|
||||
},
|
||||
{
|
||||
name: 'State',
|
||||
selector: 'State_select',
|
||||
value: 'Libre',
|
||||
urlParam: 'state',
|
||||
rows: 13,
|
||||
isSelect: true,
|
||||
},
|
||||
{
|
||||
name: 'Grouped State',
|
||||
selector: 'Grouped State_select',
|
||||
value: 'Free',
|
||||
urlParam: 'alertLevel',
|
||||
rows: 18,
|
||||
isSelect: true,
|
||||
},
|
||||
{
|
||||
name: 'Warehouse',
|
||||
selector: 'Warehouse_select',
|
||||
value: 'Warehouse Two',
|
||||
urlParam: 'warehouseFk',
|
||||
rows: 1,
|
||||
isSelect: true,
|
||||
},
|
||||
{
|
||||
name: 'ITP',
|
||||
selector: 'ITP_select',
|
||||
value: 'H',
|
||||
urlParam: 'packing',
|
||||
rows: 5,
|
||||
isSelect: true,
|
||||
},
|
||||
];
|
||||
|
||||
testCases.forEach(
|
||||
({ name, selector, value, urlParam, rows, intercept, wait, isSelect }) => {
|
||||
cy.log(`Testing ${name}`);
|
||||
|
||||
if (intercept) intercept();
|
||||
|
||||
if (isSelect) {
|
||||
cy.dataCy(selector).click();
|
||||
cy.get('.q-item__label').contains(value).click();
|
||||
} else {
|
||||
cy.dataCy(selector).type(value);
|
||||
}
|
||||
|
||||
cy.searchInFilterPanel();
|
||||
cy.url().should('include', 'clientFk');
|
||||
cy.countTableRows('eq', 7);
|
||||
//
|
||||
cy.cleanFilterPanel();
|
||||
// Order id - orderFk
|
||||
cy.dataCy('Order id_input').type(7);
|
||||
cy.searchInFilterPanel();
|
||||
cy.url().should('include', 'orderFk');
|
||||
cy.countTableRows('eq', 1);
|
||||
//
|
||||
cy.cleanFilterPanel();
|
||||
// Days onward - scopeDays
|
||||
cy.dataCy('Days onward_input').type(2);
|
||||
cy.searchInFilterPanel();
|
||||
cy.url().should('include', 'scopeDays');
|
||||
cy.countTableRows('eq', 27);
|
||||
//
|
||||
cy.cleanFilterPanel();
|
||||
// Nickname
|
||||
cy.dataCy('Nickname_input').type('test');
|
||||
cy.searchInFilterPanel();
|
||||
cy.url().should('include', 'nickname');
|
||||
cy.countTableRows('eq', 2);
|
||||
//
|
||||
cy.cleanFilterPanel();
|
||||
// Invoice
|
||||
cy.dataCy('Invoice_input').type('test');
|
||||
cy.searchInFilterPanel();
|
||||
cy.url().should('include', 'refFk');
|
||||
cy.countTableRows('eq', 0);
|
||||
//
|
||||
cy.cleanFilterPanel();
|
||||
// Agency
|
||||
cy.dataCy('Agency_select').click();
|
||||
cy.get('.q-item__label').contains('inhouse pickup').click();
|
||||
cy.searchInFilterPanel();
|
||||
cy.url().should('include', 'agencyModeFk');
|
||||
cy.countTableRows('eq', 6);
|
||||
//
|
||||
cy.cleanFilterPanel();
|
||||
// State
|
||||
cy.dataCy('State_select').click();
|
||||
cy.get('.q-item__label').contains('Libre').click();
|
||||
cy.searchInFilterPanel();
|
||||
cy.url().should('include', 'stateFk');
|
||||
cy.countTableRows('eq', 13);
|
||||
//
|
||||
cy.cleanFilterPanel();
|
||||
// AlertLevel
|
||||
cy.dataCy('Grouped State_select').click();
|
||||
cy.get('.q-item__label').contains('Free').click();
|
||||
cy.searchInFilterPanel();
|
||||
cy.url().should('include', 'alertLevel');
|
||||
cy.countTableRows('eq', 18);
|
||||
//
|
||||
cy.cleanFilterPanel();
|
||||
// Country
|
||||
cy.dataCy('Country_select').click();
|
||||
cy.get('.q-item__label').contains('España').click();
|
||||
cy.searchInFilterPanel();
|
||||
cy.url().should('include', 'countryFk');
|
||||
cy.countTableRows('eq', 28);
|
||||
//
|
||||
cy.cleanFilterPanel();
|
||||
// Province
|
||||
cy.dataCy('Warehouse_select').click();
|
||||
cy.get('.q-item__label').contains('Warehouse Two').click();
|
||||
cy.searchInFilterPanel();
|
||||
cy.url().should('include', 'warehouseFk');
|
||||
cy.countTableRows('eq', 1);
|
||||
//
|
||||
cy.url().should('include', urlParam);
|
||||
|
||||
if (wait) {
|
||||
cy.waitRequest(wait, () => cy.countTableRows('eq', rows));
|
||||
} else {
|
||||
cy.countTableRows('eq', rows);
|
||||
}
|
||||
|
||||
cy.cleanFilterPanel();
|
||||
},
|
||||
);
|
||||
// Department
|
||||
cy.selectOption('[data-cy="Department_select"]', 'EQUIPO ESPAÑA LEVANTE');
|
||||
cy.searchInFilterPanel();
|
||||
cy.url().should('include', 'departmentFk');
|
||||
//
|
||||
cy.cleanFilterPanel();
|
||||
// ITP
|
||||
cy.dataCy('ITP_select').click();
|
||||
cy.get('.q-item__label').contains('H').click();
|
||||
cy.searchInFilterPanel();
|
||||
cy.url().should('include', 'packing');
|
||||
cy.countTableRows('eq', 5);
|
||||
});
|
||||
|
||||
it('Cols', () => {
|
||||
|
@ -171,3 +181,10 @@ function checkScopeDays(scopeDays) {
|
|||
);
|
||||
});
|
||||
}
|
||||
|
||||
function interceptFilterClient() {
|
||||
cy.intercept('GET', '**/Clients*').as('filterClient');
|
||||
}
|
||||
function waitRequest() {
|
||||
cy.wait('@filterClient');
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue