|
|
|
@ -1,83 +1,25 @@
|
|
|
|
|
const firstRow = (field, index = 1) =>
|
|
|
|
|
`:nth-child(${index}) > [data-col-field="${field}"]`;
|
|
|
|
|
|
|
|
|
|
describe('Monitor Tickets Table', () => {
|
|
|
|
|
beforeEach(() => {
|
|
|
|
|
cy.login('developer');
|
|
|
|
|
cy.viewport(1920, 720);
|
|
|
|
|
cy.visit('/#/monitor/tickets');
|
|
|
|
|
cy.domContentLoad();
|
|
|
|
|
cy.waitForElement('.q-page');
|
|
|
|
|
cy.intercept('GET', '**/SalesMonitors/salesFilter*').as('filterRequest');
|
|
|
|
|
cy.openFilterPanel();
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
it('should filter by column headers and update URL params', () => {
|
|
|
|
|
// Interceptar las llamadas de filtrado
|
|
|
|
|
it.only('should filter by column headers and update URL params', () => {
|
|
|
|
|
cy.intercept('GET', '**/SalesMonitors/salesFilter*').as('filterRequest');
|
|
|
|
|
|
|
|
|
|
// Array de pruebas para diferentes columnas
|
|
|
|
|
const testCases = [
|
|
|
|
|
// {
|
|
|
|
|
// columnName: 'id',
|
|
|
|
|
// value: '123',
|
|
|
|
|
// expectedParam: { id: '123' },
|
|
|
|
|
// },
|
|
|
|
|
{
|
|
|
|
|
columnName: 'clientFk',
|
|
|
|
|
value: 'cave',
|
|
|
|
|
expectedParam: { clientFk: { like: '%cave%' } },
|
|
|
|
|
},
|
|
|
|
|
// {
|
|
|
|
|
// columnName: 'packing',
|
|
|
|
|
// value: 'H',
|
|
|
|
|
// expectedParam: { packing: 'H' },
|
|
|
|
|
// },
|
|
|
|
|
];
|
|
|
|
|
|
|
|
|
|
// Probar cada columna
|
|
|
|
|
// testCases.forEach(({ columnName, value, expectedParam }) => {
|
|
|
|
|
// // Encontrar el input del filtro y escribir el valor
|
|
|
|
|
// cy.get(`[data-cy="column-filter-${columnName}"]`)
|
|
|
|
|
// .click()
|
|
|
|
|
// .type(`${value}{enter}`);
|
|
|
|
|
|
|
|
|
|
// Verificar que la URL se actualizó con el parámetro
|
|
|
|
|
// cy.url().should('include', encodeURIComponent(JSON.stringify(expectedParam)));
|
|
|
|
|
|
|
|
|
|
// Verificar que la petición HTTP incluye el parámetro correcto
|
|
|
|
|
// cy.wait('@filterRequest').then((interception) => {
|
|
|
|
|
// expect(interception.request.url).to.include(
|
|
|
|
|
// encodeURIComponent(JSON.stringify(expectedParam)),
|
|
|
|
|
// );
|
|
|
|
|
// });
|
|
|
|
|
|
|
|
|
|
// Limpiar el filtro para la siguiente prueba
|
|
|
|
|
// cy.get(`[data-cy="column-filter-${columnName}"]`).clear();
|
|
|
|
|
// });
|
|
|
|
|
/* ==== Generated with Cypress Studio ==== */ cy.get(
|
|
|
|
|
'[data-cy="column-filter-id"] > [data-v-532139db=""] > .column > [dense="true"] > .q-field > .q-field__inner > .q-field__control > .q-field__control-container > [data-cy="_input"]',
|
|
|
|
|
).type('13');
|
|
|
|
|
cy.get(
|
|
|
|
|
'[data-cy="column-filter-id"] > [data-v-532139db=""] > .column > [dense="true"] > .q-field > .q-field__inner > .q-field__control > .q-field__append > .q-icon',
|
|
|
|
|
).click();
|
|
|
|
|
// cy.get(
|
|
|
|
|
// '[data-cy="column-filter-clientFk"] > [data-v-532139db=""] > .column > .q-field > .q-field__inner > .q-field__control > .q-field__control-container > .q-field__native > [data-cy="_select"]',
|
|
|
|
|
// ).clear('cave{enter}');
|
|
|
|
|
// cy.get(
|
|
|
|
|
// '[data-cy="column-filter-clientFk"] > [data-v-532139db=""] > .column > .q-field > .q-field__inner > .q-field__control > .q-field__control-container > .q-field__native > [data-cy="_select"]',
|
|
|
|
|
// ).type('cave{enter}');
|
|
|
|
|
// cy.get(
|
|
|
|
|
// '[data-cy="column-filter-clientFk"] > [data-v-532139db=""] > .column > .q-field > .q-field__inner > .q-field__control > .q-field__control-container > .q-field__native > [data-cy="_select"]',
|
|
|
|
|
// ).clear('c');
|
|
|
|
|
// cy.get(
|
|
|
|
|
// '[data-cy="column-filter-clientFk"] > [data-v-532139db=""] > .column > .q-field > .q-field__inner > .q-field__control > .q-field__control-container > .q-field__native > [data-cy="_select"]',
|
|
|
|
|
// ).type('Bar');
|
|
|
|
|
// cy.get(
|
|
|
|
|
// '[data-cy="column-filter-clientFk"] > [data-v-532139db=""] > .column > .q-field > .q-field__inner > .q-field__control > .q-field__control-container > .q-field__native > [data-cy="_select"]',
|
|
|
|
|
// ).clear('Ba');
|
|
|
|
|
cy.dataCy('vnTable_filter_btn').click();
|
|
|
|
|
cy.get(
|
|
|
|
|
'[data-cy="column-filter-clientFk"] > [data-v-532139db=""] > .column > .q-field > .q-field__inner > .q-field__control > .q-field__control-container > .q-field__native > [data-cy="_select"]',
|
|
|
|
|
{ timeout: 3000 },
|
|
|
|
|
).type('1101', { timeout: 3000, force: true });
|
|
|
|
|
cy.dataCy('column-filter-id').find(' [data-cy="_input"]').type('13');
|
|
|
|
|
cy.dataCy('column-filter-id').find(' .q-icon').click();
|
|
|
|
|
cy.openRightMenu();
|
|
|
|
|
cy.dataCy('column-filter-clientFk')
|
|
|
|
|
.find('[data-cy="_select"]', { timeout: 3000 })
|
|
|
|
|
.type('1101', { timeout: 3000, force: true });
|
|
|
|
|
cy.get('[role="listbox"]')
|
|
|
|
|
.find('.q-item')
|
|
|
|
|
.find('.q-item__label')
|
|
|
|
@ -91,8 +33,6 @@ describe('Monitor Tickets Table', () => {
|
|
|
|
|
'[data-cy="column-filter-id"] > [data-v-532139db=""] > .column > [dense="true"] > .q-field > .q-field__inner > .q-field__control > .q-field__control-container > [data-cy="_input"]',
|
|
|
|
|
).clear('1');
|
|
|
|
|
|
|
|
|
|
/* ==== End Cypress Studio ==== */
|
|
|
|
|
/* ==== Generated with Cypress Studio ==== */
|
|
|
|
|
cy.get(
|
|
|
|
|
'[data-cy="column-filter-clientFk"] > [data-v-532139db=""] > .column > .q-field > .q-field__inner > .q-field__control > .q-field__control-container > .q-field__native > [data-cy="_select"]',
|
|
|
|
|
).clear('1');
|
|
|
|
@ -171,7 +111,7 @@ describe('Monitor Tickets Table', () => {
|
|
|
|
|
countRows('eq', 2);
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
it.only('refFk', () => {
|
|
|
|
|
it('refFk', () => {
|
|
|
|
|
// Invoice
|
|
|
|
|
cy.get('[data-cy="Invoice_input"]').type('test');
|
|
|
|
|
cy.searchInFilterPanel();
|
|
|
|
@ -252,18 +192,36 @@ describe('Monitor Tickets Table', () => {
|
|
|
|
|
countRows('eq', 5);
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
it('Cols', () => {
|
|
|
|
|
cy.get(firstRow('totalProblems'));
|
|
|
|
|
cy.get(firstRow('id')).find('span').should('have.class', 'link').click();
|
|
|
|
|
cy.dataCy('TicketDescriptor').should('exist');
|
|
|
|
|
cy.get(firstRow('clientFk')).find('span').should('have.class', 'link').click();
|
|
|
|
|
cy.dataCy('CustomerDescriptor').should('exist');
|
|
|
|
|
|
|
|
|
|
cy.get(firstRow('salesPersonFk'))
|
|
|
|
|
.find('span')
|
|
|
|
|
.should('have.class', 'link')
|
|
|
|
|
.click();
|
|
|
|
|
cy.dataCy('WorkerDescriptor').should('exist');
|
|
|
|
|
cy.get(firstRow('zoneFk')).find('span').should('have.class', 'link').click();
|
|
|
|
|
cy.dataCy('ZoneDescriptor').should('exist');
|
|
|
|
|
cy.get(firstRow('shippedDate')).find('.q-badge');
|
|
|
|
|
cy.get(
|
|
|
|
|
':nth-child(1) > .q-table--col-auto-width > [data-cy="tableAction-0"] > .q-btn__content > .q-icon',
|
|
|
|
|
).click({ ctrlKey: true });
|
|
|
|
|
cy.get(
|
|
|
|
|
':nth-child(1) > .q-table--col-auto-width > [data-cy="tableAction-1"] > .q-btn__content > .q-icon',
|
|
|
|
|
).click();
|
|
|
|
|
cy.get('.summaryHeader').should('exist');
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
function requestParams(key, value, options = { inWhere: false, like: false }) {
|
|
|
|
|
// cy.wait(2000);
|
|
|
|
|
cy.wait('@filterRequest').then((interception) => {
|
|
|
|
|
if (!key) return;
|
|
|
|
|
const { query } = interception.request;
|
|
|
|
|
cy.log('Request query:', query, options);
|
|
|
|
|
if (!options.inWhere)
|
|
|
|
|
// Verificamos que existe la propiedad clientFk y su valor
|
|
|
|
|
expect(query).to.have.property(key, value);
|
|
|
|
|
if (!options.inWhere) expect(query).to.have.property(key, value);
|
|
|
|
|
else {
|
|
|
|
|
// Verificamos que existe la propiedad where y dentro de ella la propiedad clientFk y su valor
|
|
|
|
|
const filter = JSON.parse(query.filter);
|
|
|
|
|
if (options.like)
|
|
|
|
|
expect(filter.where).to.have.deep.property(key, {
|
|
|
|
@ -274,31 +232,20 @@ function requestParams(key, value, options = { inWhere: false, like: false }) {
|
|
|
|
|
expect(filter.where).to.have.property(key, value);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
// Verificación adicional del formato completo si es necesario
|
|
|
|
|
// expect(interception.request.query).to.deep.include({
|
|
|
|
|
// filter: expect.any(String),
|
|
|
|
|
// from: expect.any(String),
|
|
|
|
|
// to: expect.any(String),
|
|
|
|
|
// scopeDays: expect.any(String),
|
|
|
|
|
// });
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
function countRows(operator = 'gt', value = 0) {
|
|
|
|
|
// Obtener el último data-row-index para saber el total de filas
|
|
|
|
|
const element = 'data-row-index';
|
|
|
|
|
cy.get('body').then(($body) => {
|
|
|
|
|
const hasRows = $body.find(`td[${element}]`).length > 0;
|
|
|
|
|
cy.log('hasRows:', hasRows);
|
|
|
|
|
if (!hasRows) expect(0).to.be[operator](value);
|
|
|
|
|
else
|
|
|
|
|
cy.get(`td[${element}]`)
|
|
|
|
|
.last()
|
|
|
|
|
.invoke('attr', element)
|
|
|
|
|
.then((lastIndex) => {
|
|
|
|
|
const totalRows = parseInt(lastIndex) + 1; // Sumamos 1 porque el índice empieza en 0
|
|
|
|
|
cy.log(`Total de filas: ${totalRows}`);
|
|
|
|
|
const totalRows = parseInt(lastIndex) + 1;
|
|
|
|
|
expect(totalRows).to.be[operator](value);
|
|
|
|
|
// expect(totalRows).to.be.gt(0);
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
should open the descriptorProxy and SummaryPopup. (o algo así)