/// <reference types="cypress" />
describe('InvoiceInIntrastat', () => {
    const inputBtns = 'label button';
    const thirdRow = 'tbody > :nth-child(3)';
    const firstLineCode = 'tbody > :nth-child(1) > :nth-child(2)';

    beforeEach(() => {
        cy.login('developer');
        cy.visit(`/#/invoice-in/1/intrastat`);
    });

    it('should edit the first line', () => {
        cy.selectOption(firstLineCode, 'Plantas vivas: Esqueje/injerto, Vid');

        cy.get(inputBtns).eq(1).click();

        cy.saveCard();
        cy.visit(`/#/invoice-in/1/intrastat`);

        cy.getValue(firstLineCode).should(
            'equal',
            'Plantas vivas: Esqueje/injerto, Vid'
        );
    });

    it('should add a new row', () => {
        const rowData = [false, 'Plantas vivas: Esqueje/injerto, Vid', 30, 10, 5, 'FR'];

        cy.addRow();
        cy.fillRow(thirdRow, rowData);
        cy.saveCard();
        cy.get('.q-notification__message').should('have.text', 'Data saved');
    });

    it('should remove the first line', () => {
        cy.removeRow(1);
    });
});
