/// <reference types="cypress" />
describe('Ticket descriptor', () => {
    const toCloneOpt = '[role="menu"] .q-list > :nth-child(5)';
    const warehouseValue = ':nth-child(1) > :nth-child(6) > .value > span';
    const summaryHeader = '.summaryHeader > div';

    beforeEach(() => {
        const ticketId = 1;

        cy.login('developer');
        cy.visit(`/#/ticket/${ticketId}/summary`);
    });

    it('should clone the ticket without warehouse', () => {
        cy.openLeftMenu();
        cy.openActionsDescriptor();
        cy.get(toCloneOpt).click();
        cy.clickConfirm();
        cy.get(warehouseValue).contains('-');
        cy.get(summaryHeader)
            .invoke('text')
            .then((text) => {
                const [, owner] = text.split('-');
                cy.wrap(owner.trim()).should('eq', 'Bruce Wayne (1101)');
            });
    });
});