/// const firstRow = 'tr.cursor-pointer > :nth-child(1)'; const ticketId = 1000000; const clickNotificationAction = () => { const notification = '.q-notification'; cy.waitForElement(notification); cy.get(notification).should('be.visible'); cy.get('.q-notification__actions > .q-btn').click(); cy.get('@open').should((openStub) => { expect(openStub).to.be.called; const firstArg = openStub.args[0][0]; expect(firstArg).to.match(/\/ticket\/\d+\/sale/); expect(firstArg).to.include(`/ticket/${ticketId}/sale`); }); }; describe.skip('Ticket Lack detail', { testIsolation: true }, () => { beforeEach(() => { cy.viewport(1980, 1020); cy.login('developer'); cy.intercept('GET', /\/api\/Tickets\/itemLack\/88.*$/).as('getItemLack'); cy.visit('/#/ticket/negative/88'); cy.window().then((win) => { cy.stub(win, 'open').as('open'); }); cy.wait('@getItemLack').then((interception) => { const { query } = interception.request; const filter = JSON.parse(query.filter); expect(filter).to.have.property('where'); expect(filter.where).to.have.property('alertLevelCode', 'FREE'); }); }); describe('Table detail', () => { it('should open descriptors', () => { cy.get('.q-table').should('be.visible'); cy.colField('zoneName').click(); cy.dataCy('ZoneDescriptor').should('be.visible'); cy.get('.q-item > .q-item__label').should('have.text', ' #1'); cy.colField('ticketFk').click(); cy.dataCy('TicketDescriptor').should('be.visible'); cy.get('.q-item > .q-item__label').should('have.text', ` #${ticketId}`); cy.colField('nickname').find('.link').click(); cy.waitForElement('[data-cy="CustomerDescriptor"]'); cy.dataCy('CustomerDescriptor').should('be.visible'); cy.get('.q-item > .q-item__label').should('have.text', ' #1'); }); it('should display only one row in the lack list', () => { cy.dataCy('changeItem').should('be.disabled'); cy.dataCy('changeState').should('be.disabled'); cy.dataCy('changeQuantity').should('be.disabled'); cy.dataCy('itemProposal').should('be.disabled'); cy.dataCy('transferLines').should('be.disabled'); cy.get('tr.cursor-pointer > :nth-child(1)').click(); cy.dataCy('changeItem').should('be.enabled'); cy.dataCy('changeState').should('be.enabled'); cy.dataCy('changeQuantity').should('be.enabled'); cy.dataCy('itemProposal').should('be.enabled'); cy.dataCy('transferLines').should('be.enabled'); }); }); describe('Split', () => { beforeEach(() => { cy.get(firstRow).click(); cy.dataCy('transferLines').click(); }); it('Split', () => { cy.dataCy('ticketTransferPopup').find('.flex > .q-btn').click(); cy.checkNotification(`Ticket ${ticketId}: No split`); }); }); describe('change quantity', () => { beforeEach(() => { cy.get(firstRow).click(); cy.dataCy('changeQuantity').click(); }); it('by popup', () => { cy.dataCy('New quantity_input').type(10); cy.get('.q-btn--unelevated > .q-btn__content > .block').click(); clickNotificationAction(); }); }); describe('Change state', () => { beforeEach(() => { cy.get(firstRow).click(); cy.dataCy('changeState').click(); }); it('by popup', () => { cy.dataCy('New state_select').should('be.visible'); cy.selectOption('[data-cy="New state_select"]', 'OK'); cy.get('.q-btn--unelevated > .q-btn__content > .block').click(); clickNotificationAction(); }); }); describe('Change Item', () => { beforeEach(() => { cy.get(firstRow).click(); cy.dataCy('changeItem').click(); }); it('by popup', () => { cy.dataCy('New item_select').should('be.visible'); cy.selectOption('[data-cy="New item_select"]', 'Palito rojo'); cy.get('.q-btn--unelevated > .q-btn__content > .block').click(); cy.checkNotification('Ticket 1000000: price retrieval failed'); cy.dataCy('changeItem').click(); cy.selectOption('[data-cy="New item_select"]', 'Ranged weapon longbow 200cm'); cy.get('.q-btn--unelevated > .q-btn__content > .block').click(); clickNotificationAction(); }); after(() => { cy.visit(`/#/ticket/${ticketId}/sale`); const quantity = Math.floor(Math.random() * 100) + 1; const rowIndex = 1; cy.dataCy('ticketSaleQuantityInput') .find('input') .eq(rowIndex) .clear() .type(`${quantity}{enter}`); cy.dataCy('ticketSaleQuantityInput') .find('input') .eq(rowIndex) .should('have.value', `${quantity}`); }); }); describe('Item proposal', () => { beforeEach(() => { cy.get(firstRow).click(); cy.dataCy('itemProposal').click(); }); describe('Replace item if', () => { it('Quantity is less than available', () => { const index = 2; cy.colField('tag7', index).click(); cy.checkNotification('Not available for replacement'); }); it('item proposal cells', () => { const index = 1; cy.colField('longName', index) .find('.no-padding > .q-td > .middle') .should('have.class', 'proposal-primary'); cy.colField('tag5', index) .find('.no-padding > .match') .should('have.class', 'match'); cy.colField('tag6', index) .find('.no-padding > .match') .should('have.class', 'match'); cy.colField('tag7', index).click(); clickNotificationAction(); }); }); }); });