/// <reference types="cypress" />

describe('Ticket expedtion', () => {
    const tableContent = '.q-table .q-virtual-scroll__content';
    const stateTd = 'td:nth-child(9)';

    beforeEach(() => {
        cy.login('developer');
        cy.viewport(1920, 1080);
    });

    it('should change the state', () => {
        cy.visit('#/ticket/1/expedition');
        cy.intercept('GET', /\/api\/Expeditions\/filter/).as('expeditions');
        cy.intercept('POST', /\/api\/Expeditions\/crud/).as('crud');

        cy.wait('@expeditions');

        cy.selectRows([1, 2]);
        cy.get('#subToolbar [aria-controls]:nth-child(1)').click();
        cy.get('.q-menu .q-item').contains('Perdida').click();
        cy.wait('@crud');

        cy.get(`${tableContent} tr:nth-child(-n+2) ${stateTd}`).each(($el) => {
            cy.wrap($el).contains('Perdida');
        });
    });
});
