/// <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('show');
        cy.intercept('POST', /\/api\/ExpeditionStates\/addExpeditionState/).as('add');

        cy.wait('@show');
        cy.selectRows([1, 2]);
        cy.selectOption('[data-cy="change-state"]', 'Perdida');
        cy.wait('@add');

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