/// <reference types="cypress" />
describe('InvoiceOut list', () => {
    const invoice = {
        Ticket: { val: '8' },
        Serial: { val: 'EspaƱola rapida', type: 'select' },
    };
    const invoiceError = {
        Ticket: { val: '1' },
        Serial: { val: 'EspaƱola rapida', type: 'select' },
    };

    beforeEach(() => {
        cy.viewport(1920, 1080);
        cy.login('developer');
        cy.visit(`/#/invoice-out/list`);
        cy.typeSearchbar('{enter}');
    });

    it('should search and filter an invoice and enter to the summary', () => {
        cy.typeSearchbar('1{enter}');
        cy.get('.q-virtual-scroll__content > :nth-child(2) > :nth-child(7)').click();
        cy.get('.header > a.q-btn > .q-btn__content').click();
        cy.typeSearchbar('{enter}');
        cy.dataCy('InvoiceOutFilterAmountBtn').find('input').type('8.88{enter}');
    });

    it('should download all pdfs', () => {
        cy.get('.bg-header > :nth-child(1) > .q-checkbox > .q-checkbox__inner').click();
        cy.dataCy('InvoiceOutDownloadPdfBtn').click();
        cy.get('.bg-header > :nth-child(1) > .q-checkbox > .q-checkbox__inner').click();
    });

    it('should give an error when manual invoicing a ticket that is already invoiced', () => {
        cy.dataCy('vnTableCreateBtn').click();
        cy.fillInForm(invoiceError);
        cy.dataCy('FormModelPopup_save').click();
        cy.checkNotification('This ticket is already invoiced');
    });

    it('should create a manual invoice and enter to its summary', () => {
        cy.dataCy('vnTableCreateBtn').click();
        cy.fillInForm(invoice);
        cy.dataCy('FormModelPopup_save').click();
        cy.checkNotification('Data created');
    });
});