/// <reference types="cypress" />
describe('InvoiceOut summary', () => {
    const transferInvoice = {
        Client: { val: 'employee', type: 'select' },
        Type: { val: 'Error in customer data', type: 'select' },
    };

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

    it('should generate the invoice PDF', () => {
        cy.typeSearchbar('T1111111{enter}');
        cy.dataCy('descriptor-more-opts').click();
        cy.get('.q-menu > .q-list > :nth-child(6)').click();
        cy.dataCy('VnConfirm_confirm').click();
        cy.checkNotification('The invoice PDF document has been regenerated');
    });

    it('should refund the invoice ', () => {
        cy.typeSearchbar('T1111111{enter}');
        cy.dataCy('descriptor-more-opts').click();
        cy.get('.q-menu > .q-list > :nth-child(7)').click();
        cy.get('#q-portal--menu--3 > .q-menu > .q-list > :nth-child(2)').click();
        cy.checkNotification('The following refund ticket have been created 1000000');
    });

    it('should delete an invoice ', () => {
        cy.typeSearchbar('T2222222{enter}');
        cy.dataCy('descriptor-more-opts').click();
        cy.get('.q-menu > .q-list > :nth-child(4)').click();
        cy.dataCy('VnConfirm_confirm').click();
        cy.checkNotification('InvoiceOut deleted');
    });

    it('should transfer the invoice ', () => {
        cy.typeSearchbar('T1111111{enter}');
        cy.dataCy('descriptor-more-opts').click();
        cy.get('.q-menu > .q-list > :nth-child(1)').click();
        cy.fillInForm(transferInvoice);
        cy.get('.q-mt-lg > .q-btn').click();
        cy.checkNotification('Transferred invoice');
    });
});
