diff --git a/e2e/helpers/extensions.js b/e2e/helpers/extensions.js index f02c4edd8..92ce1d665 100644 --- a/e2e/helpers/extensions.js +++ b/e2e/helpers/extensions.js @@ -1,47 +1,49 @@ +/* eslint no-invalid-this: "off" */ + import config from './config.js'; import Nightmare from 'nightmare'; import {URL} from 'url'; Nightmare.action('login', function(userName, done) { this.goto(`${config.url}auth/?apiKey=salix`) - .wait(`vn-login input[name=user]`) - .write(`vn-login input[name=user]`, userName) - .write(`vn-login input[name=password]`, 'nightmare') - .click(`vn-login input[type=submit]`) + .wait(`vn-login input[name=user]`) + .write(`vn-login input[name=user]`, userName) + .write(`vn-login input[name=password]`, 'nightmare') + .click(`vn-login input[type=submit]`) // FIXME: Wait for dom to be ready: https://github.com/segmentio/nightmare/issues/481 - .wait(1000) - .then(done); + .wait(1000) + .then(done); }); Nightmare.action('changeLanguageToEnglish', function(done) { this.wait('#lang') - .evaluate(selector => { - return document.querySelector(selector).title; - }, '#lang') - .then(title => { - if (title === 'Change language') { - this.then(done); - } else { - this.click('#lang') - .click('vn-main-menu [vn-id="langs-menu"] ul > li[name="en"]') - .then(done); - } - }); + .evaluate((selector) => { + return document.querySelector(selector).title; + }, '#lang') + .then((title) => { + if (title === 'Change language') { + this.then(done); + } else { + this.click('#lang') + .click('vn-main-menu [vn-id="langs-menu"] ul > li[name="en"]') + .then(done); + } + }); }); Nightmare.action('waitForLogin', function(userName, done) { this.login(userName) - .waitForURL('#!/') - .url() - .changeLanguageToEnglish() - .then(done); + .waitForURL('#!/') + .url() + .changeLanguageToEnglish() + .then(done); }); Nightmare.action('parsedUrl', function(done) { this.url() - .then(url => { - done(null, new URL(url)); - }); + .then((url) => { + done(null, new URL(url)); + }); }); Nightmare.action('getProperty', function(selector, property, done) { @@ -50,107 +52,116 @@ Nightmare.action('getProperty', function(selector, property, done) { }, done, selector, property); }); +Nightmare.action('waitPropertyLength', function(selector, property, minLength, done) { + this.wait((selector, property, minLength) => { + const element = document.querySelector(selector); + return element && element[property] != null && element[property] !== '' && element[property].length >= minLength; + }, selector, property, minLength) + .getProperty(selector, property) + .then((result) => done(null, result), done); +}); + Nightmare.action('waitProperty', function(selector, property, done) { this.wait((selector, property) => { - let element = document.querySelector(selector); + const element = document.querySelector(selector); return element && element[property] != null && element[property] !== ''; }, selector, property) - .getProperty(selector, property) - .then(result => done(null, result), done); + .getProperty(selector, property) + .then((result) => done(null, result), done); }); Nightmare.action('getInnerText', function(selector, done) { this.wait(selector) - .evaluate_now(function(elementToSelect) { - return document.querySelector(elementToSelect).innerText; - }, done, selector); + .evaluate_now(function(elementToSelect) { + return document.querySelector(elementToSelect).innerText; + }, done, selector); }); Nightmare.action('getInputValue', function(selector, done) { this.wait(selector) - .evaluate_now(function(elementToSelect) { - return document.querySelector(elementToSelect).value; - }, done, selector); + .evaluate_now(function(elementToSelect) { + return document.querySelector(elementToSelect).value; + }, done, selector); }); Nightmare.action('clearInput', function(selector, done) { - let backSpaces = []; + const backSpaces = []; for (let i = 0; i < 50; i += 1) { backSpaces.push('\u0008'); } this.wait(selector) - .type(selector, backSpaces.join('')) - .then(done); + .type(selector, backSpaces.join('')) + .then(done); }); Nightmare.action('write', function(selector, text, done) { this.wait(selector) - .type(selector, text) - .then(done); + .type(selector, text) + .then(done); }); Nightmare.action('waitToClick', function(selector, done) { this.wait(selector) - .click(selector) - .then(done); + .click(selector) + .then(done); }); Nightmare.action('isVisible', function(selector, done) { this.wait(selector) - .evaluate_now(elementSelector => { - const selectorMatches = document.querySelectorAll(elementSelector); - const element = selectorMatches[0]; - if (selectorMatches.length > 1) { - throw new Error(`multiple matches of ${elementSelector} found`); - } - let isVisible = false; - if (element) { - const eventHandler = event => { - event.preventDefault(); - isVisible = true; - }; - element.addEventListener('mouseover', eventHandler); - const elementBoundaries = element.getBoundingClientRect(); - const x = elementBoundaries.left + element.offsetWidth / 2; - const y = elementBoundaries.top + element.offsetHeight / 2; - const elementInCenter = document.elementFromPoint(x, y); - const elementInTopLeft = document.elementFromPoint(elementBoundaries.left, elementBoundaries.top); - const elementInBottomRight = document.elementFromPoint(elementBoundaries.right, elementBoundaries.bottom); - const e = new MouseEvent('mouseover', { - view: window, - bubbles: true, - cancelable: true - }); - if (elementInCenter) { - elementInCenter.dispatchEvent(e); + .evaluate_now((elementSelector) => { + const selectorMatches = document.querySelectorAll(elementSelector); + const element = selectorMatches[0]; + if (selectorMatches.length > 1) { + throw new Error(`multiple matches of ${elementSelector} found`); } - if (elementInTopLeft) { - elementInTopLeft.dispatchEvent(e); + let isVisible = false; + if (element) { + const eventHandler = (event) => { + event.preventDefault(); + isVisible = true; + }; + element.addEventListener('mouseover', eventHandler); + const elementBoundaries = element.getBoundingClientRect(); + const x = elementBoundaries.left + element.offsetWidth / 2; + const y = elementBoundaries.top + element.offsetHeight / 2; + const elementInCenter = document.elementFromPoint(x, y); + const elementInTopLeft = document.elementFromPoint(elementBoundaries.left, elementBoundaries.top); + const elementInBottomRight = document.elementFromPoint(elementBoundaries.right, elementBoundaries.bottom); + const e = new MouseEvent('mouseover', { + view: window, + bubbles: true, + cancelable: true, + }); + if (elementInCenter) { + elementInCenter.dispatchEvent(e); + } + if (elementInTopLeft) { + elementInTopLeft.dispatchEvent(e); + } + if (elementInBottomRight) { + elementInBottomRight.dispatchEvent(e); + } + element.removeEventListener('mouseover', eventHandler); } - if (elementInBottomRight) { - elementInBottomRight.dispatchEvent(e); - } - element.removeEventListener('mouseover', eventHandler); - } - return isVisible; - }, done, selector); + return isVisible; + }, done, selector); }); Nightmare.action('selectText', function(selector, done) { this.wait(selector) - .evaluate(elementToSelect => { - const range = document.createRange(); - range.selectNodeContents(document.querySelector(elementToSelect)); - const sel = window.getSelection(); - sel.removeAllRanges(); - sel.addRange(range); - }, selector) - .mouseup(selector) - .then(done); + .evaluate((elementToSelect) => { + const range = document.createRange(); + range.selectNodeContents(document.querySelector(elementToSelect)); + const sel = window.getSelection(); + sel.removeAllRanges(); + sel.addRange(range); + }, selector) + .mouseup(selector) + .then(done); }); Nightmare.action('countElement', function(selector, done) { - this.evaluate_now(selector => { + this.evaluate_now((selector) => { return document.querySelectorAll(selector).length; }, done, selector); }); @@ -159,103 +170,103 @@ Nightmare.action('waitForNumberOfElements', function(selector, count, done) { this.wait((resultSelector, expectedCount) => { return document.querySelectorAll(resultSelector).length === expectedCount; }, selector, count) - .then(done); + .then(done); }); Nightmare.action('waitForClassNotPresent', function(selector, className, done) { this.wait(selector) - .wait((resultSelector, targetClass) => { - if (!document.querySelector(resultSelector).classList.contains(targetClass)) { - return true; - } - }, selector, className) - .then(done); + .wait((resultSelector, targetClass) => { + if (!document.querySelector(resultSelector).classList.contains(targetClass)) { + return true; + } + }, selector, className) + .then(done); }); Nightmare.action('waitForClassPresent', function(selector, className, done) { this.wait(selector) - .wait((resultSelector, targetClass) => { - if (document.querySelector(resultSelector).classList.contains(targetClass)) { - return true; - } - }, selector, className) - .then(done); + .wait((resultSelector, targetClass) => { + if (document.querySelector(resultSelector).classList.contains(targetClass)) { + return true; + } + }, selector, className) + .then(done); }); Nightmare.action('waitForTextInElement', function(selector, name, done) { this.wait(selector) - .wait((resultSelector, expectedText) => { - return document.querySelector(resultSelector).innerText.toLowerCase().includes(expectedText.toLowerCase()); - }, selector, name) - .then(done); + .wait((resultSelector, expectedText) => { + return document.querySelector(resultSelector).innerText.toLowerCase().includes(expectedText.toLowerCase()); + }, selector, name) + .then(done); }); Nightmare.action('waitForTextInInput', function(selector, name, done) { this.wait(selector) - .wait((resultSelector, expectedText) => { - return document.querySelector(resultSelector).value.toLowerCase().includes(expectedText.toLowerCase()); - }, selector, name) - .then(done); + .wait((resultSelector, expectedText) => { + return document.querySelector(resultSelector).value.toLowerCase().includes(expectedText.toLowerCase()); + }, selector, name) + .then(done); }); Nightmare.action('waitForInnerText', function(selector, done) { this.wait(selector) - .wait(selector => { - let innerText = document.querySelector(selector).innerText; - return innerText != null && innerText != ''; - }, selector) - .evaluate_now(selector => { - return document.querySelector(selector).innerText; - }, done, selector); + .wait((selector) => { + const innerText = document.querySelector(selector).innerText; + return innerText != null && innerText != ''; + }, selector) + .evaluate_now((selector) => { + return document.querySelector(selector).innerText; + }, done, selector); }); Nightmare.action('waitForEmptyInnerText', function(selector, done) { - this.wait(selector => { + this.wait((selector) => { return document.querySelector(selector).innerText == ''; }, selector) - .then(done); + .then(done); }); Nightmare.action('waitForURL', function(hashURL, done) { - this.wait(hash => { + this.wait((hash) => { return document.location.hash.includes(hash); }, hashURL) - .then(done); + .then(done); }); Nightmare.action('waitForShapes', function(selector, done) { this.wait(selector) - .evaluate_now(selector => { - let shapes = document.querySelectorAll(selector); - let shapesList = []; + .evaluate_now((selector) => { + const shapes = document.querySelectorAll(selector); + const shapesList = []; - for (let shape of shapes) { - shapesList.push(shape.innerText); - } + for (const shape of shapes) { + shapesList.push(shape.innerText); + } - return shapesList; - }, done, selector); + return shapesList; + }, done, selector); }); Nightmare.action('waitForSnackbar', function(done) { this.wait(500).waitForShapes('vn-snackbar .shape .text') - .then(shapes => { - done(null, shapes); - }); + .then((shapes) => { + done(null, shapes); + }); }); Nightmare.action('waitForLastShape', function(selector, done) { this.wait(selector) - .evaluate_now(selector => { - let shape = document.querySelector(selector); + .evaluate_now((selector) => { + const shape = document.querySelector(selector); - return shape.innerText; - }, done, selector); + return shape.innerText; + }, done, selector); }); Nightmare.action('waitForLastSnackbar', function(done) { this.wait(500).waitForLastShape('vn-snackbar .shape .text') - .then(shapes => { - done(null, shapes); - }); + .then((shapes) => { + done(null, shapes); + }); }); diff --git a/e2e/helpers/selectors.js b/e2e/helpers/selectors.js index 5bf636d9c..39f64c919 100644 --- a/e2e/helpers/selectors.js +++ b/e2e/helpers/selectors.js @@ -1,5 +1,3 @@ -// eslint max-len: ["error", 500] -// eslint key-spacing: ["error", 500] import components from './components_selectors.js'; export default { @@ -9,18 +7,18 @@ export default { applicationsMenuVisible: `vn-main-menu [vn-id="apps-menu"] ul`, clientsButton: `vn-main-menu [vn-id="apps-menu"] ul > li[ui-sref="client.index"]`, ticketsButton: `vn-main-menu [vn-id="apps-menu"] ul > li[ui-sref="ticket.index"]`, - claimsButton: `vn-main-menu [vn-id="apps-menu"] ul > li[ui-sref="claim.index"]` + claimsButton: `vn-main-menu [vn-id="apps-menu"] ul > li[ui-sref="claim.index"]`, }, moduleAccessView: { clientsSectionButton: `vn-home a[ui-sref="client.index"]`, itemsSectionButton: `vn-home a[ui-sref="item.index"]`, - ticketsSectionButton: `vn-home a[ui-sref="ticket.index"]` + ticketsSectionButton: `vn-home a[ui-sref="ticket.index"]`, }, clientsIndex: { searchClientInput: `${components.vnTextfield}`, searchButton: `vn-searchbar vn-icon[icon="search"]`, searchResult: `vn-item-client a`, - createClientButton: `${components.vnFloatButton}` + createClientButton: `${components.vnFloatButton}`, }, createClientView: { name: `${components.vnTextfield}[name="name"]`, @@ -31,7 +29,7 @@ export default { salesPersonInput: `vn-autocomplete[field="$ctrl.client.salesPersonFk"] input`, salesBruceBannerOption: `vn-autocomplete[field="$ctrl.client.salesPersonFk"] vn-drop-down ul > li:nth-child(1)`, createButton: `${components.vnSubmit}`, - cancelButton: `vn-button[href="#!/client/index"]` + cancelButton: `vn-button[href="#!/client/index"]`, }, clientBasicData: { basicDataButton: `vn-menu-item a[ui-sref="client.card.basicData"]`, @@ -46,7 +44,7 @@ export default { channelInput: `vn-autocomplete[field="$ctrl.client.contactChannelFk"] input`, channelMetropolisOption: `vn-autocomplete[field="$ctrl.client.contactChannelFk"] vn-drop-down ul > li:nth-child(3)`, channelRumorsOption: `vn-autocomplete[field="$ctrl.client.contactChannelFk"] vn-drop-down ul > li:nth-child(4)`, - saveButton: `${components.vnSubmit}` + saveButton: `${components.vnSubmit}`, }, clientFiscalData: { fiscalDataButton: `vn-menu-item a[ui-sref="client.card.fiscalData"]`, @@ -73,7 +71,7 @@ export default { invoiceByMailCheckboxLabel: `vn-check[label='Invoice by mail'] > label`, invoiceByMailCheckboxInput: `vn-check[label='Invoice by mail'] input`, viesCheckboxInput: `vn-check[label='Vies'] > label > input`, - saveButton: `${components.vnSubmit}` + saveButton: `${components.vnSubmit}`, }, clientPayMethod: { payMethodButton: `vn-menu-item a[ui-sref="client.card.billingData"]`, @@ -90,7 +88,7 @@ export default { newBankEntityName: 'vn-client-billing-data > vn-dialog vn-textfield[label="Name"] input', newBankEntityBIC: 'vn-client-billing-data > vn-dialog vn-textfield[label="Swift / BIC"] input', acceptBankEntityButton: 'vn-client-billing-data > vn-dialog button[response="ACCEPT"]', - saveButton: `${components.vnSubmit}` + saveButton: `${components.vnSubmit}`, }, clientAddresses: { addressesButton: `vn-menu-item a[ui-sref="client.card.address.index"]`, @@ -123,27 +121,27 @@ export default { thirdObservationDescriptionInput: `vn-client-address-edit [name=observations] :nth-child(3) [model="observation.description"] input`, addObservationButton: `vn-client-address-edit vn-icon-button[icon="add_circle"]`, saveButton: `${components.vnSubmit}`, - cancelButton: `button[ui-sref="client.card.address.index"]` + cancelButton: `button[ui-sref="client.card.address.index"]`, }, clientWebAccess: { webAccessButton: `vn-menu-item a[ui-sref="client.card.webAccess"]`, enableWebAccessCheckbox: `vn-check[label='Enable web access'] > label > input`, userNameInput: `${components.vnTextfield}[name="name"]`, - saveButton: `${components.vnSubmit}` + saveButton: `${components.vnSubmit}`, }, clientNotes: { notesButton: `vn-menu-item a[ui-sref="client.card.note.index"]`, addNoteFloatButton: `${components.vnFloatButton}`, noteInput: `vn-textarea[label="Note"]`, saveButton: `${components.vnSubmit}`, - firstNoteText: 'vn-client-note .text' + firstNoteText: 'vn-client-note .text', }, clientCredit: { creditButton: `vn-menu-item a[ui-sref="client.card.credit.index"]`, addCreditFloatButton: `${components.vnFloatButton}`, creditInput: `${components.vnTextfield}[name="credit"]`, saveButton: `${components.vnSubmit}`, - firstCreditText: 'vn-client-credit-index vn-card > div vn-table vn-tbody > vn-tr' + firstCreditText: 'vn-client-credit-index vn-card > div vn-table vn-tbody > vn-tr', }, clientGreuge: { greugeButton: `vn-menu-item a[ui-sref="client.card.greuge.index"]`, @@ -153,15 +151,15 @@ export default { typeInput: `vn-autocomplete[field="$ctrl.greuge.greugeTypeFk"] input`, typeSecondOption: `vn-autocomplete[field="$ctrl.greuge.greugeTypeFk"] vn-drop-down ul > li`, saveButton: `${components.vnSubmit}`, - firstGreugeText: 'vn-client-greuge-index vn-card > div vn-table vn-tbody > vn-tr' + firstGreugeText: 'vn-client-greuge-index vn-card > div vn-table vn-tbody > vn-tr', }, clientMandate: { mandateButton: `vn-menu-item a[ui-sref="client.card.mandate"]`, - firstMandateText: 'vn-client-mandate vn-card > div vn-table vn-tbody > vn-tr' + firstMandateText: 'vn-client-mandate vn-card > div vn-table vn-tbody > vn-tr', }, clientInvoices: { invoicesButton: `vn-menu-item a[ui-sref="client.card.invoice"]`, - firstInvoiceText: 'vn-client-invoice vn-card > div vn-table vn-tbody > vn-tr' + firstInvoiceText: 'vn-client-invoice vn-card > div vn-table vn-tbody > vn-tr', }, itemsIndex: { goBackToModuleIndexButton: `vn-ticket-descriptor a[href="#!/ticket/index"]`, @@ -172,7 +170,7 @@ export default { acceptClonationAlertButton: `vn-item-index [vn-id="clone"] [response="ACCEPT"]`, searchItemInput: `${components.vnTextfield}`, searchButton: `vn-searchbar vn-icon[icon="search"]`, - closeItemSummaryPreview: 'vn-item-index [vn-id="preview"] button.close' + closeItemSummaryPreview: 'vn-item-index [vn-id="preview"] button.close', }, itemCreateView: { name: `${components.vnTextfield}[name="name"]`, @@ -183,7 +181,7 @@ export default { originSelect: `vn-autocomplete[field="$ctrl.item.originFk"] input`, originSelectOptionOne: `vn-autocomplete[field="$ctrl.item.originFk"] vn-drop-down ul > li:nth-child(2)`, createButton: `${components.vnSubmit}`, - cancelButton: `button[ui-sref="item.index"]` + cancelButton: `button[ui-sref="item.index"]`, }, itemBasicData: { @@ -201,7 +199,7 @@ export default { expenceSelectOptionThree: `vn-autocomplete[field="$ctrl.item.expenceFk"] vn-drop-down ul > li:nth-child(3)`, longNameInput: `vn-textfield[label="Full name"] input`, isActiveCheckbox: `vn-check[label='Active'] > label > input`, - submitBasicDataButton: `${components.vnSubmit}` + submitBasicDataButton: `${components.vnSubmit}`, }, itemTags: { goToItemIndexButton: 'vn-item-descriptor [ui-sref="item.index"]', @@ -231,7 +229,7 @@ export default { seventhValueInput: `vn-item-tags vn-horizontal:nth-child(8) > vn-textfield[label="Value"] input`, seventhRelevancyInput: `vn-horizontal:nth-child(8) > vn-textfield[label="Relevancy"] input`, addItemTagButton: `vn-icon-button[icon="add_circle"]`, - submitItemTagsButton: `${components.vnSubmit}` + submitItemTagsButton: `${components.vnSubmit}`, }, itemTax: { taxButton: `vn-menu-item a[ui-sref="item.card.tax"]`, @@ -241,14 +239,14 @@ export default { secondClassSelectOptionOne: `vn-horizontal:nth-child(3) > vn-autocomplete vn-drop-down ul > li:nth-child(1)`, thirdClassSelect: `vn-horizontal:nth-child(4) > vn-autocomplete[field="tax.taxClassFk"] input`, thirdClassSelectOptionTwo: `vn-horizontal:nth-child(4) > vn-autocomplete vn-drop-down ul > li:nth-child(2)`, - submitTaxButton: `${components.vnSubmit}` + submitTaxButton: `${components.vnSubmit}`, }, itemBarcodes: { barcodeButton: `vn-menu-item a[ui-sref="item.card.itemBarcode"]`, addBarcodeButton: `vn-icon[icon="add_circle"]`, thirdCodeInput: `vn-item-barcode vn-horizontal:nth-child(4) > ${components.vnTextfield}`, submitBarcodesButton: `${components.vnSubmit}`, - firstCodeRemoveButton: `vn-item-barcode vn-horizontal vn-none vn-icon[icon="remove_circle_outline"]` + firstCodeRemoveButton: `vn-item-barcode vn-horizontal vn-none vn-icon[icon="remove_circle_outline"]`, }, itemNiches: { nicheButton: `vn-menu-item a[ui-sref="item.card.niche"]`, @@ -262,7 +260,7 @@ export default { thirdWarehouseSelect: `vn-horizontal:nth-child(4) > vn-autocomplete[field="niche.warehouseFk"] input`, thirdWarehouseSelectFourthOption: `vn-horizontal:nth-child(4) > vn-autocomplete[field="niche.warehouseFk"] vn-drop-down ul > li:nth-child(4)`, thirdCodeInput: `vn-horizontal:nth-child(4) > vn-textfield[label="Code"] input`, - submitNichesButton: `${components.vnSubmit}` + submitNichesButton: `${components.vnSubmit}`, }, itemBotanical: { botanicalButton: `vn-menu-item a[ui-sref="item.card.botanical"]`, @@ -273,7 +271,7 @@ export default { speciesSelect: `vn-autocomplete[field="$ctrl.botanical.specieFk"] input`, speciesSelectOptionOne: `vn-autocomplete[field="$ctrl.botanical.specieFk"] vn-drop-down ul > li:nth-child(1)`, speciesSelectOptionTwo: `vn-autocomplete[field="$ctrl.botanical.specieFk"] vn-drop-down ul > li:nth-child(2)`, - submitBotanicalButton: `${components.vnSubmit}` + submitBotanicalButton: `${components.vnSubmit}`, }, itemSummary: { basicData: `vn-item-summary vn-vertical[name="basicData"]`, @@ -281,14 +279,14 @@ export default { tags: `vn-item-summary vn-vertical[name="tags"]`, niche: `vn-item-summary vn-vertical[name="niche"]`, botanical: `vn-item-summary vn-vertical[name="botanical"]`, - barcode: `vn-item-summary vn-vertical[name="barcode"]` + barcode: `vn-item-summary vn-vertical[name="barcode"]`, }, ticketsIndex: { searchResult: `vn-ticket-index vn-card > div > vn-table > div > vn-tbody > a.vn-tr`, searchResultDate: `vn-ticket-index vn-table vn-tbody > a:nth-child(1) > vn-td:nth-child(4)`, searchResultAddress: `vn-ticket-index vn-table vn-tbody > a:nth-child(1) > vn-td:nth-child(6)`, searchTicketInput: `vn-ticket-index ${components.vnTextfield}`, - searchButton: `vn-ticket-index vn-searchbar vn-icon[icon="search"]` + searchButton: `vn-ticket-index vn-searchbar vn-icon[icon="search"]`, }, ticketNotes: { notesButton: `vn-menu-item a[ui-sref="ticket.card.observation"]`, @@ -297,12 +295,12 @@ export default { firstNoteSelect: `vn-autocomplete[field="observation.observationTypeFk"] input`, firstNoteSelectSecondOption: `vn-autocomplete[field="observation.observationTypeFk"] vn-drop-down ul > li:nth-child(2)`, firstDescriptionInput: `vn-textfield[label="Description"] input`, - submitNotesButton: `${components.vnSubmit}` + submitNotesButton: `${components.vnSubmit}`, }, ticketExpedition: { expeditionButton: `vn-menu-item a[ui-sref="ticket.card.expedition"]`, secondExpeditionRemoveButton: `vn-ticket-expedition vn-table div > vn-tbody > vn-tr:nth-child(2) > vn-td:nth-child(1) > vn-icon-button[icon="delete"]`, - secondExpeditionText: `vn-ticket-expedition vn-table div > vn-tbody > vn-tr:nth-child(2)` + secondExpeditionText: `vn-ticket-expedition vn-table div > vn-tbody > vn-tr:nth-child(2)`, }, ticketPackages: { packagesButton: `vn-menu-item a[ui-sref="ticket.card.package.index"]`, @@ -312,7 +310,7 @@ export default { firstRemovePackageButton: `vn-icon[vn-tooltip="Remove package"]`, addPackageButton: `vn-icon-button[vn-tooltip="Add package"]`, clearPackageSelectButton: `vn-autocomplete[label="Package"] > div > div > div > vn-icon > i`, - savePackagesButton: `${components.vnSubmit}` + savePackagesButton: `${components.vnSubmit}`, }, ticketSales: { saleLine: `vn-table div > vn-tbody > vn-tr`, @@ -360,7 +358,7 @@ export default { moreMenuUnmarkResevedOption: 'vn-ticket-sale vn-drop-down > vn-popover ul > li:nth-child(5)', moreMenuUpdateDiscount: 'vn-ticket-sale vn-drop-down > vn-popover ul > li:nth-child(6)', moreMenuUpdateDiscountInput: 'vn-ticket-sale vn-dialog.shown vn-ticket-sale-edit-discount input', - moreMenuCreateClaim: 'vn-ticket-sale vn-drop-down > vn-popover ul > li:nth-child(1)' + moreMenuCreateClaim: 'vn-ticket-sale vn-drop-down > vn-popover ul > li:nth-child(1)', }, ticketTracking: { trackingButton: `vn-left-menu a[ui-sref="ticket.card.tracking.index"]`, @@ -368,7 +366,7 @@ export default { stateSelect: 'vn-ticket-tracking-edit vn-autocomplete[field="$ctrl.ticket.stateFk"] input', stateSelectInput: 'vn-ticket-tracking-edit vn-autocomplete > vn-drop-down > vn-popover vn-textfield input', stateSelectFirstResult: 'vn-ticket-tracking-edit vn-autocomplete > vn-drop-down > vn-popover ul > li:nth-child(1)', - saveButton: `${components.vnSubmit}` + saveButton: `${components.vnSubmit}`, }, ticketBasicData: { basicDataButton: `vn-menu-item a[ui-sref="ticket.card.data.stepOne"]`, @@ -383,18 +381,24 @@ export default { stepTwoTotalPriceDif: `vn-ticket-data-step-two > form > vn-card > div > vn-horizontal > table > tfoot > tr > td:nth-child(4)`, chargesReason: `vn-autocomplete[field="$ctrl.ticket.option"] input`, chargesReasonFourthOption: `vn-autocomplete[field="$ctrl.ticket.option"] vn-drop-down ul > li:nth-child(4)`, - chargesReasonFirstOption: `vn-autocomplete[field="$ctrl.ticket.option"] vn-drop-down ul > li:nth-child(1)` + chargesReasonFirstOption: `vn-autocomplete[field="$ctrl.ticket.option"] vn-drop-down ul > li:nth-child(1)`, + }, + ticketComponents: { + componentsButton: `vn-menu-item a[ui-sref="ticket.card.components"]`, + base: 'vn-ticket-components tfoot > tr:nth-child(1) > td', + margin: 'vn-ticket-components tfoot > tr:nth-child(2) > td', + total: 'vn-ticket-components tfoot > tr:nth-child(3) > td', }, createStateView: { stateInput: `vn-autocomplete[field="$ctrl.ticket.stateFk"] > div > div > input`, stateInputOptionOne: `vn-autocomplete[field="$ctrl.ticket.stateFk"] vn-drop-down ul > li:nth-child(1)`, clearStateInputButton: `vn-autocomplete[field="$ctrl.ticket.stateFk"] > div > div > div > vn-icon > i`, - saveStateButton: `${components.vnSubmit}` + saveStateButton: `${components.vnSubmit}`, }, claimsIndex: { searchClaimInput: `vn-claim-index ${components.vnTextfield}`, searchResult: `vn-claim-index vn-card > div > vn-table > div > vn-tbody > vn-tr`, - searchButton: `vn-claim-index vn-searchbar vn-icon[icon="search"]` + searchButton: `vn-claim-index vn-searchbar vn-icon[icon="search"]`, }, claimBasicData: { basicDataButton: `vn-menu-item a[ui-sref="claim.card.basicData"]`, @@ -404,10 +408,10 @@ export default { isPaidWithManaCheckbox: `vn-check[field="$ctrl.claim.isChargedToMana"] > label > input`, responsabilityInputRange: `vn-input-range`, observationInput: `vn-textarea[label="Observation"] textarea`, - saveButton: `${components.vnSubmit}` + saveButton: `${components.vnSubmit}`, }, claimDetails: { detailsButton: `vn-menu-item a[ui-sref="claim.card.detail"]`, - addItemButton: `vn-claim-detail a vn-float-button` - } + addItemButton: `vn-claim-detail a vn-float-button`, + }, }; diff --git a/e2e/paths/client-module/01_create_client.spec.js b/e2e/paths/client-module/01_create_client.spec.js index 2fee6e1b0..5d0b0c32d 100644 --- a/e2e/paths/client-module/01_create_client.spec.js +++ b/e2e/paths/client-module/01_create_client.spec.js @@ -3,122 +3,122 @@ import createNightmare from '../../helpers/nightmare'; describe('Client', () => { describe('create path', () => { - let nightmare = createNightmare(); + const nightmare = createNightmare(); beforeAll(() => { return nightmare - .waitForLogin('employee'); + .waitForLogin('employee'); }); - it('should access to the clients index by clicking the clients button', async() => { - let url = await nightmare - .click(selectors.moduleAccessView.clientsSectionButton) - .wait(selectors.clientsIndex.createClientButton) - .parsedUrl(); - + it('should access to the clients index by clicking the clients button', async () => { + const url = await nightmare + .click(selectors.moduleAccessView.clientsSectionButton) + .wait(selectors.clientsIndex.createClientButton) + .parsedUrl(); + expect(url.hash).toEqual('#!/client/index'); }); - it(`should search for the user Carol Danvers to confirm it isn't created yet`, async() => { - let result = await nightmare - .wait(selectors.clientsIndex.searchResult) - .type(selectors.clientsIndex.searchClientInput, 'Carol Danvers') - .click(selectors.clientsIndex.searchButton) - .waitForNumberOfElements(selectors.clientsIndex.searchResult, 0) - .countElement(selectors.clientsIndex.searchResult); - + it(`should search for the user Carol Danvers to confirm it isn't created yet`, async () => { + const result = await nightmare + .wait(selectors.clientsIndex.searchResult) + .type(selectors.clientsIndex.searchClientInput, 'Carol Danvers') + .click(selectors.clientsIndex.searchButton) + .waitForNumberOfElements(selectors.clientsIndex.searchResult, 0) + .countElement(selectors.clientsIndex.searchResult); + expect(result).toEqual(0); }); - it('should access to the create client view by clicking the create-client floating button', async() => { - let url = await nightmare - .click(selectors.clientsIndex.createClientButton) - .wait(selectors.createClientView.createButton) - .parsedUrl(); - + it('should access to the create client view by clicking the create-client floating button', async () => { + const url = await nightmare + .click(selectors.clientsIndex.createClientButton) + .wait(selectors.createClientView.createButton) + .parsedUrl(); + expect(url.hash).toEqual('#!/client/create'); }); - it('should return to the client index by clicking the cancel button', async() => { - let url = await nightmare - .click(selectors.createClientView.cancelButton) - .wait(selectors.clientsIndex.createClientButton) - .parsedUrl(); - + it('should return to the client index by clicking the cancel button', async () => { + const url = await nightmare + .click(selectors.createClientView.cancelButton) + .wait(selectors.clientsIndex.createClientButton) + .parsedUrl(); + expect(url.hash).toEqual('#!/client/index'); }); - it('should now access to the create client view by clicking the create-client floating button', async() => { - let url = await nightmare - .click(selectors.clientsIndex.createClientButton) - .wait(selectors.createClientView.createButton) - .parsedUrl(); - + it('should now access to the create client view by clicking the create-client floating button', async () => { + const url = await nightmare + .click(selectors.clientsIndex.createClientButton) + .wait(selectors.createClientView.createButton) + .parsedUrl(); + expect(url.hash).toEqual('#!/client/create'); }); - it('should receive an error when clicking the create button having all the form fields empty', async() => { - let result = await nightmare - .click(selectors.createClientView.createButton) - .waitForLastSnackbar(); - - expect(result).toEqual('Some fields are invalid'); - }); - - it('should receive an error when clicking the create button having name and Business name fields empty', async() => { - let result = await nightmare - .type(selectors.createClientView.taxNumber, '74451390E') - .type(selectors.createClientView.userName, 'CaptainMarvel') - .type(selectors.createClientView.email, 'CarolDanvers@verdnatura.es') - .waitToClick(selectors.createClientView.salesPersonInput) - .waitToClick(selectors.createClientView.salesBruceBannerOption) - .click(selectors.createClientView.createButton) - .waitForLastSnackbar(); + it('should receive an error when clicking the create button having all the form fields empty', async () => { + const result = await nightmare + .click(selectors.createClientView.createButton) + .waitForLastSnackbar(); expect(result).toEqual('Some fields are invalid'); }); - it(`should attempt to create a new user with all it's data but wrong email`, async() => { - let result = await nightmare - .type(selectors.createClientView.name, 'Carol Danvers') - .type(selectors.createClientView.socialName, 'AVG tax') - .clearInput(selectors.createClientView.email) - .type(selectors.createClientView.email, 'incorrect email format') - .click(selectors.createClientView.createButton) - .waitForLastSnackbar(); - + it('should receive an error when clicking the create button having name and Business name fields empty', async () => { + const result = await nightmare + .type(selectors.createClientView.taxNumber, '74451390E') + .type(selectors.createClientView.userName, 'CaptainMarvel') + .type(selectors.createClientView.email, 'CarolDanvers@verdnatura.es') + .waitToClick(selectors.createClientView.salesPersonInput) + .waitToClick(selectors.createClientView.salesBruceBannerOption) + .click(selectors.createClientView.createButton) + .waitForLastSnackbar(); + expect(result).toEqual('Some fields are invalid'); }); - it(`should create a new user with all correct data`, async() => { - let result = await nightmare - .clearInput(selectors.createClientView.email) - .type(selectors.createClientView.email, 'caroldanvers@verdnatura.es') - .click(selectors.createClientView.createButton) - .waitForLastSnackbar(); - + it(`should attempt to create a new user with all it's data but wrong email`, async () => { + const result = await nightmare + .type(selectors.createClientView.name, 'Carol Danvers') + .type(selectors.createClientView.socialName, 'AVG tax') + .clearInput(selectors.createClientView.email) + .type(selectors.createClientView.email, 'incorrect email format') + .click(selectors.createClientView.createButton) + .waitForLastSnackbar(); + + expect(result).toEqual('Some fields are invalid'); + }); + + it(`should create a new user with all correct data`, async () => { + const result = await nightmare + .clearInput(selectors.createClientView.email) + .type(selectors.createClientView.email, 'caroldanvers@verdnatura.es') + .click(selectors.createClientView.createButton) + .waitForLastSnackbar(); + expect(result).toEqual('Data saved!'); }); - it('should click on the Clients button of the top bar menu', async() => { - let url = await nightmare - .waitToClick(selectors.globalItems.applicationsMenuButton) - .wait(selectors.globalItems.applicationsMenuVisible) - .waitToClick(selectors.globalItems.clientsButton) - .wait(selectors.clientsIndex.createClientButton) - .parsedUrl(); - + it('should click on the Clients button of the top bar menu', async () => { + const url = await nightmare + .waitToClick(selectors.globalItems.applicationsMenuButton) + .wait(selectors.globalItems.applicationsMenuVisible) + .waitToClick(selectors.globalItems.clientsButton) + .wait(selectors.clientsIndex.createClientButton) + .parsedUrl(); + expect(url.hash).toEqual('#!/client/index'); }); - it(`should search for the user Carol Danvers to confirm it exists`, async() => { - let result = await nightmare - .wait(selectors.clientsIndex.searchResult) - .type(selectors.clientsIndex.searchClientInput, 'Carol Danvers') - .click(selectors.clientsIndex.searchButton) - .waitForNumberOfElements(selectors.clientsIndex.searchResult, 1) - .countElement(selectors.clientsIndex.searchResult); - + it(`should search for the user Carol Danvers to confirm it exists`, async () => { + const result = await nightmare + .wait(selectors.clientsIndex.searchResult) + .type(selectors.clientsIndex.searchClientInput, 'Carol Danvers') + .click(selectors.clientsIndex.searchButton) + .waitForNumberOfElements(selectors.clientsIndex.searchResult, 1) + .countElement(selectors.clientsIndex.searchResult); + expect(result).toEqual(1); }); }); diff --git a/e2e/paths/ticket-module/01_create_ticket_observations.spec.js b/e2e/paths/ticket-module/01_create_ticket_observations.spec.js index 0d4a989d0..f6564f998 100644 --- a/e2e/paths/ticket-module/01_create_ticket_observations.spec.js +++ b/e2e/paths/ticket-module/01_create_ticket_observations.spec.js @@ -7,76 +7,76 @@ describe('Ticket', () => { beforeAll(() => { return nightmare - .waitForLogin('employee'); + .waitForLogin('employee'); }); - it('should access to the tickets index by clicking the tickets button', done => { + it('should access to the tickets index by clicking the tickets button', (done) => { return nightmare - .click(selectors.moduleAccessView.ticketsSectionButton) - .wait(selectors.ticketsIndex.searchResult) - .parsedUrl() - .then(url => { - expect(url.hash).toEqual('#!/ticket/index'); - done(); - }).catch(done.fail); + .click(selectors.moduleAccessView.ticketsSectionButton) + .wait(selectors.ticketsIndex.searchResult) + .parsedUrl() + .then((url) => { + expect(url.hash).toEqual('#!/ticket/index'); + done(); + }).catch(done.fail); }); - it('should search for the ticket with id 1', done => { + it('should search for the ticket with id 1', (done) => { return nightmare - .wait(selectors.ticketsIndex.searchTicketInput) - .type(selectors.ticketsIndex.searchTicketInput, 'id:1') - .click(selectors.ticketsIndex.searchButton) - .waitForNumberOfElements(selectors.ticketsIndex.searchResult, 1) - .countElement(selectors.ticketsIndex.searchResult) - .then(result => { - expect(result).toEqual(1); - done(); - }).catch(done.fail); + .wait(selectors.ticketsIndex.searchTicketInput) + .type(selectors.ticketsIndex.searchTicketInput, 'id:1') + .click(selectors.ticketsIndex.searchButton) + .waitForNumberOfElements(selectors.ticketsIndex.searchResult, 1) + .countElement(selectors.ticketsIndex.searchResult) + .then((result) => { + expect(result).toEqual(1); + done(); + }).catch(done.fail); }); - it(`should click on the search result to access to the ticket notes`, done => { + it(`should click on the search result to access to the ticket notes`, (done) => { return nightmare - .waitForTextInElement(selectors.ticketsIndex.searchResult, '1') - .waitToClick(selectors.ticketsIndex.searchResult) - .waitToClick(selectors.ticketNotes.notesButton) - .waitForURL('observation') - .url() - .then(url => { - expect(url).toContain('observation'); - done(); - }).catch(done.fail); + .waitForTextInElement(selectors.ticketsIndex.searchResult, '1') + .waitToClick(selectors.ticketsIndex.searchResult) + .waitToClick(selectors.ticketNotes.notesButton) + .waitForURL('observation') + .url() + .then((url) => { + expect(url).toContain('observation'); + done(); + }).catch(done.fail); }); - it(`should click create a new note and delete a former one`, done => { + it(`should click create a new note and delete a former one`, (done) => { return nightmare - .waitToClick(selectors.ticketNotes.firstNoteRemoveButton) - .waitToClick(selectors.ticketNotes.addNoteButton) - .waitToClick(selectors.ticketNotes.firstNoteSelect) - .waitToClick(selectors.ticketNotes.firstNoteSelectSecondOption) - .type(selectors.ticketNotes.firstDescriptionInput, 'description') - .click(selectors.ticketNotes.submitNotesButton) - .waitForLastSnackbar() - .then(result => { - expect(result).toEqual('Data saved!'); - done(); - }).catch(done.fail); + .waitToClick(selectors.ticketNotes.firstNoteRemoveButton) + .waitToClick(selectors.ticketNotes.addNoteButton) + .waitToClick(selectors.ticketNotes.firstNoteSelect) + .waitToClick(selectors.ticketNotes.firstNoteSelectSecondOption) + .type(selectors.ticketNotes.firstDescriptionInput, 'description') + .click(selectors.ticketNotes.submitNotesButton) + .waitForLastSnackbar() + .then((result) => { + expect(result).toEqual('Data saved!'); + done(); + }).catch(done.fail); }); - it(`should confirm the note is the expected one`, done => { + it(`should confirm the note is the expected one`, (done) => { return nightmare - .click(selectors.ticketPackages.packagesButton) - .wait(selectors.ticketPackages.firstPackageSelect) - .click(selectors.ticketNotes.notesButton) - .waitProperty(selectors.ticketNotes.firstNoteSelect, 'value') - .then(result => { - expect(result).toEqual('observation one'); - return nightmare - .getProperty(selectors.ticketNotes.firstDescriptionInput, 'value'); - }) - .then(result => { - expect(result).toEqual('description'); - done(); - }).catch(done.fail); + .click(selectors.ticketPackages.packagesButton) + .wait(selectors.ticketPackages.firstPackageSelect) + .click(selectors.ticketNotes.notesButton) + .waitProperty(selectors.ticketNotes.firstNoteSelect, 'value') + .then((result) => { + expect(result).toEqual('observation one'); + return nightmare + .getProperty(selectors.ticketNotes.firstDescriptionInput, 'value'); + }) + .then((result) => { + expect(result).toEqual('description'); + done(); + }).catch(done.fail); }); }); }); diff --git a/e2e/paths/ticket-module/02_delete_ticket_expeditions.spec.js b/e2e/paths/ticket-module/02_delete_ticket_expeditions.spec.js index 4e21884f9..ba2015511 100644 --- a/e2e/paths/ticket-module/02_delete_ticket_expeditions.spec.js +++ b/e2e/paths/ticket-module/02_delete_ticket_expeditions.spec.js @@ -7,59 +7,59 @@ describe('Ticket', () => { beforeAll(() => { return nightmare - .waitForLogin('production'); + .waitForLogin('production'); }); - it('should access to the tickets index by clicking the tickets button', done => { + it('should access to the tickets index by clicking the tickets button', (done) => { return nightmare - .click(selectors.moduleAccessView.ticketsSectionButton) - .wait(selectors.ticketsIndex.searchResult) - .parsedUrl() - .then(url => { - expect(url.hash).toEqual('#!/ticket/index'); - done(); - }).catch(done.fail); + .click(selectors.moduleAccessView.ticketsSectionButton) + .wait(selectors.ticketsIndex.searchResult) + .parsedUrl() + .then((url) => { + expect(url.hash).toEqual('#!/ticket/index'); + done(); + }).catch(done.fail); }); - it('should search for the ticket with id 1', done => { + it('should search for the ticket with id 1', (done) => { return nightmare - .wait(selectors.ticketsIndex.searchTicketInput) - .type(selectors.ticketsIndex.searchTicketInput, 'id:1') - .click(selectors.ticketsIndex.searchButton) - .waitForNumberOfElements(selectors.ticketsIndex.searchResult, 1) - .countElement(selectors.ticketsIndex.searchResult) - .then(result => { - expect(result).toEqual(1); - done(); - }).catch(done.fail); + .wait(selectors.ticketsIndex.searchTicketInput) + .type(selectors.ticketsIndex.searchTicketInput, 'id:1') + .click(selectors.ticketsIndex.searchButton) + .waitForNumberOfElements(selectors.ticketsIndex.searchResult, 1) + .countElement(selectors.ticketsIndex.searchResult) + .then((result) => { + expect(result).toEqual(1); + done(); + }).catch(done.fail); }); - it(`should click on the search result to access to the ticket expeditions`, done => { + it(`should click on the search result to access to the ticket expeditions`, (done) => { return nightmare - .waitForTextInElement(selectors.ticketsIndex.searchResult, '1') - .waitToClick(selectors.ticketsIndex.searchResult) - .waitToClick(selectors.ticketExpedition.expeditionButton) - .waitForURL('expedition') - .url() - .then(url => { - expect(url).toContain('expedition'); - done(); - }).catch(done.fail); + .waitForTextInElement(selectors.ticketsIndex.searchResult, '1') + .waitToClick(selectors.ticketsIndex.searchResult) + .waitToClick(selectors.ticketExpedition.expeditionButton) + .waitForURL('expedition') + .url() + .then((url) => { + expect(url).toContain('expedition'); + done(); + }).catch(done.fail); }); - it(`should delete a former expedition and confirm the remaining expedition is the expected one`, done => { + it(`should delete a former expedition and confirm the remaining expedition is the expected one`, (done) => { return nightmare - .waitToClick(selectors.ticketExpedition.secondExpeditionRemoveButton) - .click(selectors.ticketPackages.packagesButton) - .wait(selectors.ticketPackages.firstPackageSelect) - .click(selectors.ticketExpedition.expeditionButton) - .wait(selectors.ticketExpedition.secondExpeditionText) - .getInnerText(selectors.ticketExpedition.secondExpeditionText) - .then(value => { - expect(value).toContain('Iron Patriot'); - expect(value).toContain('root'); - done(); - }).catch(done.fail); + .waitToClick(selectors.ticketExpedition.secondExpeditionRemoveButton) + .click(selectors.ticketPackages.packagesButton) + .wait(selectors.ticketPackages.firstPackageSelect) + .click(selectors.ticketExpedition.expeditionButton) + .wait(selectors.ticketExpedition.secondExpeditionText) + .getInnerText(selectors.ticketExpedition.secondExpeditionText) + .then((value) => { + expect(value).toContain('Iron Patriot'); + expect(value).toContain('root'); + done(); + }).catch(done.fail); }); }); }); diff --git a/e2e/paths/ticket-module/03_list_sale.spec.js b/e2e/paths/ticket-module/03_list_sale.spec.js index 556dc6851..2fae92db6 100644 --- a/e2e/paths/ticket-module/03_list_sale.spec.js +++ b/e2e/paths/ticket-module/03_list_sale.spec.js @@ -6,135 +6,111 @@ describe('Ticket List sale path', () => { beforeAll(() => { return nightmare - .waitForLogin('employee'); + .waitForLogin('employee'); }); - it('should click on the Tickets button of the top bar menu', done => { - return nightmare - .waitToClick(selectors.globalItems.applicationsMenuButton) - .wait(selectors.globalItems.applicationsMenuVisible) - .waitToClick(selectors.globalItems.ticketsButton) - .wait(selectors.ticketsIndex.searchResult) - .parsedUrl() - .then(url => { - expect(url.hash).toEqual('#!/ticket/index'); - done(); - }).catch(done.fail); + it('should click on the Tickets button of the top bar menu', async () => { + const url = await nightmare + .waitToClick(selectors.globalItems.applicationsMenuButton) + .wait(selectors.globalItems.applicationsMenuVisible) + .waitToClick(selectors.globalItems.ticketsButton) + .wait(selectors.ticketsIndex.searchResult) + .parsedUrl(); + + expect(url.hash).toEqual('#!/ticket/index'); }); - it('should search for the ticket 1', done => { - return nightmare - .wait(selectors.ticketsIndex.searchResult) - .type(selectors.ticketsIndex.searchTicketInput, 'id:1') - .click(selectors.ticketsIndex.searchButton) - .waitForNumberOfElements(selectors.ticketsIndex.searchResult, 1) - .countElement(selectors.ticketsIndex.searchResult) - .then(result => { - expect(result).toEqual(1); - done(); - }).catch(done.fail); + it('should search for the ticket 1', async () => { + const result = await nightmare + .wait(selectors.ticketsIndex.searchResult) + .type(selectors.ticketsIndex.searchTicketInput, 'id:1') + .click(selectors.ticketsIndex.searchButton) + .waitForNumberOfElements(selectors.ticketsIndex.searchResult, 1) + .countElement(selectors.ticketsIndex.searchResult); + + expect(result).toEqual(1); }); - it(`should click on the search result to access to the ticket's sale`, done => { - return nightmare - .waitForTextInElement(selectors.ticketsIndex.searchResult, 'address 21') - .waitToClick(selectors.ticketsIndex.searchResult) - .waitToClick(selectors.ticketSales.saleButton) - .waitForURL('sale') - .url() - .then(url => { - expect(url).toContain('sale'); - done(); - }).catch(done.fail); + it(`should click on the search result to access to the ticket's sale`, async () => { + const url = await nightmare + .waitForTextInElement(selectors.ticketsIndex.searchResult, 'address 21') + .waitToClick(selectors.ticketsIndex.searchResult) + .waitToClick(selectors.ticketSales.saleButton) + .waitForURL('sale') + .url(); + + expect(url).toContain('sale'); }); - it('should confirm the first ticket sale contains the colour', done => { - return nightmare - .wait(selectors.ticketSales.firstSaleText) - .getInnerText(selectors.ticketSales.firstSaleColour) - .then(value => { - expect(value).toContain('Yellow'); - done(); - }).catch(done.fail); + it('should confirm the first ticket sale contains the colour', async () => { + const value = await nightmare + .wait(selectors.ticketSales.firstSaleText) + .getInnerText(selectors.ticketSales.firstSaleColour); + + expect(value).toContain('Yellow'); }); - it('should confirm the first ticket sale contains the lenght', done => { - return nightmare - .wait(selectors.ticketSales.firstSaleText) - .getInnerText(selectors.ticketSales.firstSaleText) - .then(value => { - expect(value).toContain('5'); - done(); - }).catch(done.fail); + it('should confirm the first ticket sale contains the lenght', async () => { + const value = await nightmare + .wait(selectors.ticketSales.firstSaleText) + .getInnerText(selectors.ticketSales.firstSaleText); + + expect(value).toContain('5'); }); - it('should confirm the first ticket sale contains the price', done => { - return nightmare - .wait(selectors.ticketSales.firstSaleText) - .getInnerText(selectors.ticketSales.firstSalePrice) - .then(value => { - expect(value).toContain('9.10'); - done(); - }).catch(done.fail); + it('should confirm the first ticket sale contains the price', async () => { + const value = await nightmare + .wait(selectors.ticketSales.firstSaleText) + .getInnerText(selectors.ticketSales.firstSalePrice); + + expect(value).toContain('9.10'); }); - it('should confirm the first ticket sale contains the discount', done => { - return nightmare - .wait(selectors.ticketSales.firstSaleText) - .getInnerText(selectors.ticketSales.firstSaleDiscount) - .then(value => { - expect(value).toContain('0 %'); - done(); - }).catch(done.fail); + it('should confirm the first ticket sale contains the discount', async () => { + const value = await nightmare + .wait(selectors.ticketSales.firstSaleText) + .getInnerText(selectors.ticketSales.firstSaleDiscount); + + expect(value).toContain('0 %'); }); - it('should confirm the first ticket sale contains the total import', done => { - return nightmare - .wait(selectors.ticketSales.firstSaleText) - .getInnerText(selectors.ticketSales.firstSaleImport) - .then(value => { - expect(value).toContain('45.50'); - done(); - }).catch(done.fail); + it('should confirm the first ticket sale contains the total import', async () => { + const value = await nightmare + .wait(selectors.ticketSales.firstSaleText) + .getInnerText(selectors.ticketSales.firstSaleImport); + + expect(value).toContain('45.50'); }); - it('should confirm the second ticket sale contains the colour', done => { - return nightmare - .wait(selectors.ticketSales.secondSaleText) - .getInnerText(selectors.ticketSales.secondSaleColour) - .then(value => { - expect(value).toContain('Red'); - done(); - }).catch(done.fail); + it('should confirm the second ticket sale contains the colour', async () => { + const value = await nightmare + .wait(selectors.ticketSales.secondSaleText) + .getInnerText(selectors.ticketSales.secondSaleColour); + + expect(value).toContain('Red'); }); - it('should confirm the second ticket sale contains the price', done => { - return nightmare - .wait(selectors.ticketSales.secondSaleText) - .getInnerText(selectors.ticketSales.secondSalePrice) - .then(value => { - expect(value).toContain('1.07'); - done(); - }).catch(done.fail); + it('should confirm the second ticket sale contains the price', async () => { + const value = await nightmare + .wait(selectors.ticketSales.secondSaleText) + .getInnerText(selectors.ticketSales.secondSalePrice); + + expect(value).toContain('1.07'); }); - it('should confirm the second ticket sale contains the discount', done => { - return nightmare - .wait(selectors.ticketSales.secondSaleText) - .getInnerText(selectors.ticketSales.secondSaleDiscount) - .then(value => { - expect(value).toContain('0 %'); - done(); - }).catch(done.fail); + it('should confirm the second ticket sale contains the discount', async () => { + const value = await nightmare + .wait(selectors.ticketSales.secondSaleText) + .getInnerText(selectors.ticketSales.secondSaleDiscount); + + expect(value).toContain('0 %'); }); - it('should confirm the second ticket sale contains the total import', done => { - return nightmare - .wait(selectors.ticketSales.secondSaleText) - .getInnerText(selectors.ticketSales.secondSaleImport) - .then(value => { - expect(value).toContain('10.70'); - done(); - }).catch(done.fail); + it('should confirm the second ticket sale contains the total import', async () => { + const value = await nightmare + .wait(selectors.ticketSales.secondSaleText) + .getInnerText(selectors.ticketSales.secondSaleImport); + + expect(value).toContain('10.70'); }); }); diff --git a/e2e/paths/ticket-module/04_create_ticket_packages.spec.js b/e2e/paths/ticket-module/04_create_ticket_packages.spec.js index 802533820..ad9a52830 100644 --- a/e2e/paths/ticket-module/04_create_ticket_packages.spec.js +++ b/e2e/paths/ticket-module/04_create_ticket_packages.spec.js @@ -6,131 +6,131 @@ describe('Ticket Create packages path', () => { beforeAll(() => { return nightmare - .waitForLogin('employee'); + .waitForLogin('employee'); }); - it('should click on the Tickets button of the top bar menu', done => { + it('should click on the Tickets button of the top bar menu', (done) => { return nightmare - .waitToClick(selectors.globalItems.applicationsMenuButton) - .wait(selectors.globalItems.applicationsMenuVisible) - .waitToClick(selectors.globalItems.ticketsButton) - .wait(selectors.ticketsIndex.searchResult) - .parsedUrl() - .then(url => { - expect(url.hash).toEqual('#!/ticket/index'); - done(); - }).catch(done.fail); + .waitToClick(selectors.globalItems.applicationsMenuButton) + .wait(selectors.globalItems.applicationsMenuVisible) + .waitToClick(selectors.globalItems.ticketsButton) + .wait(selectors.ticketsIndex.searchResult) + .parsedUrl() + .then((url) => { + expect(url.hash).toEqual('#!/ticket/index'); + done(); + }).catch(done.fail); }); - it('should search for the ticket 1', done => { + it('should search for the ticket 1', (done) => { return nightmare - .wait(selectors.ticketsIndex.searchResult) - .type(selectors.ticketsIndex.searchTicketInput, 'id:1') - .click(selectors.ticketsIndex.searchButton) - .waitForNumberOfElements(selectors.ticketsIndex.searchResult, 1) - .countElement(selectors.ticketsIndex.searchResult) - .then(result => { - expect(result).toEqual(1); - done(); - }).catch(done.fail); + .wait(selectors.ticketsIndex.searchResult) + .type(selectors.ticketsIndex.searchTicketInput, 'id:1') + .click(selectors.ticketsIndex.searchButton) + .waitForNumberOfElements(selectors.ticketsIndex.searchResult, 1) + .countElement(selectors.ticketsIndex.searchResult) + .then((result) => { + expect(result).toEqual(1); + done(); + }).catch(done.fail); }); - it(`should click on the search result to access to the ticket packages`, done => { + it(`should click on the search result to access to the ticket packages`, (done) => { return nightmare - .waitForTextInElement(selectors.ticketsIndex.searchResultAddress, 'address 21') - .waitToClick(selectors.ticketsIndex.searchResult) - .waitToClick(selectors.ticketPackages.packagesButton) - .waitForURL('package/index') - .url() - .then(url => { - expect(url).toContain('package/index'); - done(); - }).catch(done.fail); + .waitForTextInElement(selectors.ticketsIndex.searchResultAddress, 'address 21') + .waitToClick(selectors.ticketsIndex.searchResult) + .waitToClick(selectors.ticketPackages.packagesButton) + .waitForURL('package/index') + .url() + .then((url) => { + expect(url).toContain('package/index'); + done(); + }).catch(done.fail); }); - it(`should delete the first package and receive and error to save a new one with blank quantity`, done => { + it(`should delete the first package and receive and error to save a new one with blank quantity`, (done) => { return nightmare - .waitToClick(selectors.ticketPackages.firstRemovePackageButton) - .waitToClick(selectors.ticketPackages.addPackageButton) - .waitToClick(selectors.ticketPackages.firstPackageSelect) - .waitToClick(selectors.ticketPackages.firstPackageSelectOptionTwo) - .click(selectors.ticketPackages.savePackagesButton) - .waitForLastSnackbar() - .then(result => { - expect(result).toEqual('Some fields are invalid'); - done(); - }).catch(done.fail); + .waitToClick(selectors.ticketPackages.firstRemovePackageButton) + .waitToClick(selectors.ticketPackages.addPackageButton) + .waitToClick(selectors.ticketPackages.firstPackageSelect) + .waitToClick(selectors.ticketPackages.firstPackageSelectOptionTwo) + .click(selectors.ticketPackages.savePackagesButton) + .waitForLastSnackbar() + .then((result) => { + expect(result).toEqual('Some fields are invalid'); + done(); + }).catch(done.fail); }); - it(`should attempt create a new package but receive an error if quantity is a string`, done => { + it(`should attempt create a new package but receive an error if quantity is a string`, (done) => { return nightmare - .type(selectors.ticketPackages.firstQuantityInput, 'ninety 9') - .click(selectors.ticketPackages.savePackagesButton) - .waitForLastSnackbar() - .then(result => { - expect(result).toEqual('Some fields are invalid'); - done(); - }).catch(done.fail); + .type(selectors.ticketPackages.firstQuantityInput, 'ninety 9') + .click(selectors.ticketPackages.savePackagesButton) + .waitForLastSnackbar() + .then((result) => { + expect(result).toEqual('Some fields are invalid'); + done(); + }).catch(done.fail); }); - it(`should attempt create a new package but receive an error if quantity is 0`, done => { + it(`should attempt create a new package but receive an error if quantity is 0`, (done) => { return nightmare - .clearInput(selectors.ticketPackages.firstQuantityInput) - .type(selectors.ticketPackages.firstQuantityInput, 0) - .click(selectors.ticketPackages.savePackagesButton) - .waitForLastSnackbar() - .then(result => { - expect(result).toEqual('Some fields are invalid'); - done(); - }).catch(done.fail); + .clearInput(selectors.ticketPackages.firstQuantityInput) + .type(selectors.ticketPackages.firstQuantityInput, 0) + .click(selectors.ticketPackages.savePackagesButton) + .waitForLastSnackbar() + .then((result) => { + expect(result).toEqual('Some fields are invalid'); + done(); + }).catch(done.fail); }); - it(`should attempt create a new package but receive an error if package is blank`, done => { + it(`should attempt create a new package but receive an error if package is blank`, (done) => { return nightmare - .clearInput(selectors.ticketPackages.firstQuantityInput) - .type(selectors.ticketPackages.firstQuantityInput, 99) - .click(selectors.ticketPackages.clearPackageSelectButton) - .click(selectors.ticketPackages.savePackagesButton) - .waitForLastSnackbar() - .then(result => { - expect(result).toEqual('Package cannot be blank'); - done(); - }).catch(done.fail); + .clearInput(selectors.ticketPackages.firstQuantityInput) + .type(selectors.ticketPackages.firstQuantityInput, 99) + .click(selectors.ticketPackages.clearPackageSelectButton) + .click(selectors.ticketPackages.savePackagesButton) + .waitForLastSnackbar() + .then((result) => { + expect(result).toEqual('Package cannot be blank'); + done(); + }).catch(done.fail); }); - it(`should create a new package with correct data`, done => { + it(`should create a new package with correct data`, (done) => { return nightmare - .waitToClick(selectors.ticketPackages.firstPackageSelect) - .waitToClick(selectors.ticketPackages.firstPackageSelectOptionTwo) - .waitForTextInInput(selectors.ticketPackages.firstPackageSelect, 'Legendary Box') - .click(selectors.ticketPackages.savePackagesButton) - .waitForLastSnackbar() - .then(result => { - expect(result).toEqual('Data saved!'); - done(); - }).catch(done.fail); + .waitToClick(selectors.ticketPackages.firstPackageSelect) + .waitToClick(selectors.ticketPackages.firstPackageSelectOptionTwo) + .waitForTextInInput(selectors.ticketPackages.firstPackageSelect, 'Legendary Box') + .click(selectors.ticketPackages.savePackagesButton) + .waitForLastSnackbar() + .then((result) => { + expect(result).toEqual('Data saved!'); + done(); + }).catch(done.fail); }); - it(`should confirm the first select is the expected one`, done => { + it(`should confirm the first select is the expected one`, (done) => { return nightmare - .click(selectors.ticketSales.saleButton) - .wait(selectors.ticketSales.firstPackageSelect) - .click(selectors.ticketPackages.packagesButton) - .waitForTextInInput(selectors.ticketPackages.firstPackageSelect, 'Legendary Box') - .getInputValue(selectors.ticketPackages.firstPackageSelect) - .then(result => { - expect(result).toEqual('Legendary Box'); - done(); - }).catch(done.fail); + .click(selectors.ticketSales.saleButton) + .wait(selectors.ticketSales.firstPackageSelect) + .click(selectors.ticketPackages.packagesButton) + .waitForTextInInput(selectors.ticketPackages.firstPackageSelect, 'Legendary Box') + .getInputValue(selectors.ticketPackages.firstPackageSelect) + .then((result) => { + expect(result).toEqual('Legendary Box'); + done(); + }).catch(done.fail); }); - it(`should confirm the first quantity is the expected one`, done => { + it(`should confirm the first quantity is the expected one`, (done) => { return nightmare - .waitForTextInInput(selectors.ticketPackages.firstQuantityInput, '99') - .getInputValue(selectors.ticketPackages.firstQuantityInput) - .then(result => { - expect(result).toEqual('99'); - done(); - }).catch(done.fail); + .waitForTextInInput(selectors.ticketPackages.firstQuantityInput, '99') + .getInputValue(selectors.ticketPackages.firstQuantityInput) + .then((result) => { + expect(result).toEqual('99'); + done(); + }).catch(done.fail); }); }); diff --git a/e2e/paths/ticket-module/05_create_new_tracking_state.spec.js b/e2e/paths/ticket-module/05_create_new_tracking_state.spec.js index d7678514c..aace93d8c 100644 --- a/e2e/paths/ticket-module/05_create_new_tracking_state.spec.js +++ b/e2e/paths/ticket-module/05_create_new_tracking_state.spec.js @@ -7,103 +7,103 @@ describe('Ticket', () => { beforeAll(() => { return nightmare - .waitForLogin('production'); + .waitForLogin('production'); }); - it('should click on the Tickets button of the top bar menu', done => { + it('should click on the Tickets button of the top bar menu', (done) => { return nightmare - .waitToClick(selectors.globalItems.applicationsMenuButton) - .wait(selectors.globalItems.applicationsMenuVisible) - .waitToClick(selectors.globalItems.ticketsButton) - .wait(selectors.ticketsIndex.searchResult) - .parsedUrl() - .then(url => { - expect(url.hash).toEqual('#!/ticket/index'); - done(); - }).catch(done.fail); + .waitToClick(selectors.globalItems.applicationsMenuButton) + .wait(selectors.globalItems.applicationsMenuVisible) + .waitToClick(selectors.globalItems.ticketsButton) + .wait(selectors.ticketsIndex.searchResult) + .parsedUrl() + .then((url) => { + expect(url.hash).toEqual('#!/ticket/index'); + done(); + }).catch(done.fail); }); - it('should search for the ticket 1', done => { + it('should search for the ticket 1', (done) => { return nightmare - .wait(selectors.ticketsIndex.searchResult) - .type(selectors.ticketsIndex.searchTicketInput, 'id:1') - .click(selectors.ticketsIndex.searchButton) - .waitForNumberOfElements(selectors.ticketsIndex.searchResult, 1) - .countElement(selectors.ticketsIndex.searchResult) - .then(result => { - expect(result).toEqual(1); - done(); - }).catch(done.fail); + .wait(selectors.ticketsIndex.searchResult) + .type(selectors.ticketsIndex.searchTicketInput, 'id:1') + .click(selectors.ticketsIndex.searchButton) + .waitForNumberOfElements(selectors.ticketsIndex.searchResult, 1) + .countElement(selectors.ticketsIndex.searchResult) + .then((result) => { + expect(result).toEqual(1); + done(); + }).catch(done.fail); }); - it(`should click on the search result to access to the ticket Tracking`, done => { + it(`should click on the search result to access to the ticket Tracking`, (done) => { return nightmare - .waitForTextInElement(selectors.ticketsIndex.searchResult, 'address 21') - .waitToClick(selectors.ticketsIndex.searchResult) - .waitToClick(selectors.ticketTracking.trackingButton) - .waitForURL('tracking/index') - .url() - .then(url => { - expect(url).toContain('tracking/index'); - done(); - }).catch(done.fail); + .waitForTextInElement(selectors.ticketsIndex.searchResult, 'address 21') + .waitToClick(selectors.ticketsIndex.searchResult) + .waitToClick(selectors.ticketTracking.trackingButton) + .waitForURL('tracking/index') + .url() + .then((url) => { + expect(url).toContain('tracking/index'); + done(); + }).catch(done.fail); }); - it('should access to the create state view by clicking the create floating button', done => { + it('should access to the create state view by clicking the create floating button', (done) => { return nightmare - .click(selectors.ticketTracking.createStateButton) - .wait(selectors.createStateView.stateInput) - .parsedUrl() - .then(url => { - expect(url.hash).toContain('tracking/edit'); - done(); - }).catch(done.fail); + .click(selectors.ticketTracking.createStateButton) + .wait(selectors.createStateView.stateInput) + .parsedUrl() + .then((url) => { + expect(url.hash).toContain('tracking/edit'); + done(); + }).catch(done.fail); }); - it(`should attempt create a new state but receive an error if state is empty`, done => { + it(`should attempt create a new state but receive an error if state is empty`, (done) => { return nightmare - .click(selectors.createStateView.saveStateButton) - .waitForLastSnackbar() - .then(result => { - expect(result).toEqual('No changes to save'); - done(); - }).catch(done.fail); + .click(selectors.createStateView.saveStateButton) + .waitForLastSnackbar() + .then((result) => { + expect(result).toEqual('No changes to save'); + done(); + }).catch(done.fail); }); - it(`should attempt create a new state then clear and save it`, done => { + it(`should attempt create a new state then clear and save it`, (done) => { return nightmare - .waitToClick(selectors.createStateView.stateInput) - .waitToClick(selectors.createStateView.stateInputOptionOne) - .waitToClick(selectors.createStateView.clearStateInputButton) - .click(selectors.createStateView.saveStateButton) - .waitForLastSnackbar() - .then(result => { - expect(result).toEqual('Data saved!'); - done(); - }).catch(done.fail); + .waitToClick(selectors.createStateView.stateInput) + .waitToClick(selectors.createStateView.stateInputOptionOne) + .waitToClick(selectors.createStateView.clearStateInputButton) + .click(selectors.createStateView.saveStateButton) + .waitForLastSnackbar() + .then((result) => { + expect(result).toEqual('Data saved!'); + done(); + }).catch(done.fail); }); - it('should again access to the create state view by clicking the create floating button', done => { + it('should again access to the create state view by clicking the create floating button', (done) => { return nightmare - .click(selectors.ticketTracking.createStateButton) - .wait(selectors.createStateView.stateInput) - .parsedUrl() - .then(url => { - expect(url.hash).toContain('tracking/edit'); - done(); - }).catch(done.fail); + .click(selectors.ticketTracking.createStateButton) + .wait(selectors.createStateView.stateInput) + .parsedUrl() + .then((url) => { + expect(url.hash).toContain('tracking/edit'); + done(); + }).catch(done.fail); }); - it(`should create a new state`, done => { + it(`should create a new state`, (done) => { return nightmare - .waitToClick(selectors.createStateView.stateInput) - .waitToClick(selectors.createStateView.stateInputOptionOne) - .click(selectors.createStateView.saveStateButton) - .waitForLastSnackbar() - .then(result => { - expect(result).toEqual('Data saved!'); - done(); - }).catch(done.fail); + .waitToClick(selectors.createStateView.stateInput) + .waitToClick(selectors.createStateView.stateInputOptionOne) + .click(selectors.createStateView.saveStateButton) + .waitForLastSnackbar() + .then((result) => { + expect(result).toEqual('Data saved!'); + done(); + }).catch(done.fail); }); }); }); diff --git a/e2e/paths/ticket-module/06_edit_basic_data_steps.spec.js b/e2e/paths/ticket-module/06_edit_basic_data_steps.spec.js index 5c6d32d41..cd999ff1b 100644 --- a/e2e/paths/ticket-module/06_edit_basic_data_steps.spec.js +++ b/e2e/paths/ticket-module/06_edit_basic_data_steps.spec.js @@ -7,156 +7,156 @@ describe('Ticket', () => { beforeAll(() => { return nightmare - .waitForLogin('employee'); + .waitForLogin('employee'); }); - it('should click on the Tickets button of the top bar menu', done => { + it('should click on the Tickets button of the top bar menu', (done) => { return nightmare - .waitToClick(selectors.globalItems.applicationsMenuButton) - .wait(selectors.globalItems.applicationsMenuVisible) - .waitToClick(selectors.globalItems.ticketsButton) - .wait(selectors.ticketsIndex.searchResult) - .parsedUrl() - .then(url => { - expect(url.hash).toEqual('#!/ticket/index'); - done(); - }).catch(done.fail); + .waitToClick(selectors.globalItems.applicationsMenuButton) + .wait(selectors.globalItems.applicationsMenuVisible) + .waitToClick(selectors.globalItems.ticketsButton) + .wait(selectors.ticketsIndex.searchResult) + .parsedUrl() + .then((url) => { + expect(url.hash).toEqual('#!/ticket/index'); + done(); + }).catch(done.fail); }); - it('should search for the ticket 11', done => { + it('should search for the ticket 11', (done) => { return nightmare - .wait(selectors.ticketsIndex.searchResult) - .type(selectors.ticketsIndex.searchTicketInput, 'id:11') - .click(selectors.ticketsIndex.searchButton) - .waitForNumberOfElements(selectors.ticketsIndex.searchResult, 1) - .countElement(selectors.ticketsIndex.searchResult) - .then(result => { - expect(result).toEqual(1); - done(); - }).catch(done.fail); + .wait(selectors.ticketsIndex.searchResult) + .type(selectors.ticketsIndex.searchTicketInput, 'id:11') + .click(selectors.ticketsIndex.searchButton) + .waitForNumberOfElements(selectors.ticketsIndex.searchResult, 1) + .countElement(selectors.ticketsIndex.searchResult) + .then((result) => { + expect(result).toEqual(1); + done(); + }).catch(done.fail); }); - it(`should click on the search result to access to the ticket Basic Data`, done => { + it(`should click on the search result to access to the ticket Basic Data`, (done) => { return nightmare - .waitForTextInElement(selectors.ticketsIndex.searchResult, 'address 21') // should be Bruce Wayne - .waitToClick(selectors.ticketsIndex.searchResult) - .waitToClick(selectors.ticketBasicData.basicDataButton) - .waitForURL('data/step-one') - .url() - .then(url => { - expect(url).toContain('data/step-one'); - done(); - }).catch(done.fail); + .waitForTextInElement(selectors.ticketsIndex.searchResult, 'address 21') // should be Bruce Wayne + .waitToClick(selectors.ticketsIndex.searchResult) + .waitToClick(selectors.ticketBasicData.basicDataButton) + .waitForURL('data/step-one') + .url() + .then((url) => { + expect(url).toContain('data/step-one'); + done(); + }).catch(done.fail); }); - it(`should edit the client and address of the ticket then click next`, done => { + it(`should edit the client and address of the ticket then click next`, (done) => { return nightmare - .waitToClick(selectors.ticketBasicData.clientSelect) - .waitToClick(selectors.ticketBasicData.clientSelectThirdOption) - .wait(500) - .waitToClick(selectors.ticketBasicData.addressSelect) - .waitToClick(selectors.ticketBasicData.addressSelectSecondOption) - .waitForTextInInput(selectors.ticketBasicData.addressSelect, 'Charles Xavier') - .click(selectors.ticketBasicData.nextStepButton) - .waitForURL('data/step-two') - .url() - .then(url => { - expect(url).toContain('data/step-two'); - done(); - }).catch(done.fail); + .waitToClick(selectors.ticketBasicData.clientSelect) + .waitToClick(selectors.ticketBasicData.clientSelectThirdOption) + .wait(500) + .waitToClick(selectors.ticketBasicData.addressSelect) + .waitToClick(selectors.ticketBasicData.addressSelectSecondOption) + .waitForTextInInput(selectors.ticketBasicData.addressSelect, 'Charles Xavier') + .click(selectors.ticketBasicData.nextStepButton) + .waitForURL('data/step-two') + .url() + .then((url) => { + expect(url).toContain('data/step-two'); + done(); + }).catch(done.fail); }); - it(`should have no price diference`, done => { + it(`should have no price diference`, (done) => { return nightmare - .getInnerText(selectors.ticketBasicData.stepTwoTotalPriceDif) - .then(result => { - expect(result).toContain('0'); - done(); - }).catch(done.fail); + .getInnerText(selectors.ticketBasicData.stepTwoTotalPriceDif) + .then((result) => { + expect(result).toContain('0'); + done(); + }).catch(done.fail); }); - it(`should click next to move on to step three`, done => { + it(`should click next to move on to step three`, (done) => { return nightmare - .click(selectors.ticketBasicData.nextStepButton) - .waitForURL('data/step-three') - .url() - .then(url => { - expect(url).toContain('data/step-three'); - done(); - }).catch(done.fail); + .click(selectors.ticketBasicData.nextStepButton) + .waitForURL('data/step-three') + .url() + .then((url) => { + expect(url).toContain('data/step-three'); + done(); + }).catch(done.fail); }); - it(`should select a reason for the changes made then click on finalize`, done => { + it(`should select a reason for the changes made then click on finalize`, (done) => { return nightmare - .waitToClick(selectors.ticketBasicData.chargesReason) - .waitToClick(selectors.ticketBasicData.chargesReasonFourthOption) - .waitForTextInInput(selectors.ticketBasicData.chargesReason, 'No realizar modificaciones en precios') - .click(selectors.ticketBasicData.finalizeButton) - .waitForURL('summary') - .url() - .then(url => { - expect(url).toContain('summary'); - done(); - }).catch(done.fail); + .waitToClick(selectors.ticketBasicData.chargesReason) + .waitToClick(selectors.ticketBasicData.chargesReasonFourthOption) + .waitForTextInInput(selectors.ticketBasicData.chargesReason, 'No realizar modificaciones en precios') + .click(selectors.ticketBasicData.finalizeButton) + .waitForURL('summary') + .url() + .then((url) => { + expect(url).toContain('summary'); + done(); + }).catch(done.fail); }); - it(`should go back to ticket.basicData section`, done => { + it(`should go back to ticket.basicData section`, (done) => { return nightmare - .waitToClick(selectors.ticketBasicData.basicDataButton) - .waitForURL('data/step-one') - .url() - .then(url => { - expect(url).toContain('data/step-one'); - done(); - }).catch(done.fail); + .waitToClick(selectors.ticketBasicData.basicDataButton) + .waitForURL('data/step-one') + .url() + .then((url) => { + expect(url).toContain('data/step-one'); + done(); + }).catch(done.fail); }); - it(`should edit the ticket agency then click next`, done => { + it(`should edit the ticket agency then click next`, (done) => { return nightmare - .waitToClick(selectors.ticketBasicData.agencySelect) - .waitToClick(selectors.ticketBasicData.agencySelectOptionSix) - .waitForTextInInput(selectors.ticketBasicData.agencySelect, 'Expensive') - .click(selectors.ticketBasicData.nextStepButton) - .waitForURL('data/step-two') - .url() - .then(url => { - expect(url).toContain('data/step-two'); - done(); - }).catch(done.fail); + .waitToClick(selectors.ticketBasicData.agencySelect) + .waitToClick(selectors.ticketBasicData.agencySelectOptionSix) + .waitForTextInInput(selectors.ticketBasicData.agencySelect, 'Expensive') + .click(selectors.ticketBasicData.nextStepButton) + .waitForURL('data/step-two') + .url() + .then((url) => { + expect(url).toContain('data/step-two'); + done(); + }).catch(done.fail); }); - it(`should have a price diference`, done => { + it(`should have a price diference`, (done) => { return nightmare - .getInnerText(selectors.ticketBasicData.stepTwoTotalPriceDif) - .then(result => { - expect(result).toContain('-20.65'); - done(); - }).catch(done.fail); + .getInnerText(selectors.ticketBasicData.stepTwoTotalPriceDif) + .then((result) => { + expect(result).toContain('-20.65'); + done(); + }).catch(done.fail); }); - it(`should then click next to move on to step three`, done => { + it(`should then click next to move on to step three`, (done) => { return nightmare - .click(selectors.ticketBasicData.nextStepButton) - .waitForURL('data/step-three') - .url() - .then(url => { - expect(url).toContain('data/step-three'); - done(); - }).catch(done.fail); + .click(selectors.ticketBasicData.nextStepButton) + .waitForURL('data/step-three') + .url() + .then((url) => { + expect(url).toContain('data/step-three'); + done(); + }).catch(done.fail); }); - it(`should select a new reason for the changes made then click on finalize`, done => { + it(`should select a new reason for the changes made then click on finalize`, (done) => { return nightmare - .waitToClick(selectors.ticketBasicData.chargesReason) - .waitToClick(selectors.ticketBasicData.chargesReasonFirstOption) - .waitForTextInInput(selectors.ticketBasicData.chargesReason, 'Cambiar los precios en el ticket') - .click(selectors.ticketBasicData.finalizeButton) - .waitForURL('summary') - .url() - .then(url => { - expect(url).toContain('summary'); - done(); - }).catch(done.fail); + .waitToClick(selectors.ticketBasicData.chargesReason) + .waitToClick(selectors.ticketBasicData.chargesReasonFirstOption) + .waitForTextInInput(selectors.ticketBasicData.chargesReason, 'Cambiar los precios en el ticket') + .click(selectors.ticketBasicData.finalizeButton) + .waitForURL('summary') + .url() + .then((url) => { + expect(url).toContain('summary'); + done(); + }).catch(done.fail); }); }); }); diff --git a/e2e/paths/ticket-module/07_edit_sale.spec.js b/e2e/paths/ticket-module/07_edit_sale.spec.js index 795d67d75..d51a454a5 100644 --- a/e2e/paths/ticket-module/07_edit_sale.spec.js +++ b/e2e/paths/ticket-module/07_edit_sale.spec.js @@ -6,531 +6,531 @@ describe('Ticket Edit sale path', () => { beforeAll(() => { return nightmare - .waitForLogin('salesPerson'); + .waitForLogin('salesPerson'); }); - it('should click on the Tickets button of the top bar menu', done => { + it('should click on the Tickets button of the top bar menu', (done) => { return nightmare - .waitToClick(selectors.globalItems.applicationsMenuButton) - .wait(selectors.globalItems.applicationsMenuVisible) - .waitToClick(selectors.globalItems.ticketsButton) - .wait(selectors.ticketsIndex.searchResult) - .parsedUrl() - .then(url => { - expect(url.hash).toEqual('#!/ticket/index'); - done(); - }).catch(done.fail); + .waitToClick(selectors.globalItems.applicationsMenuButton) + .wait(selectors.globalItems.applicationsMenuVisible) + .waitToClick(selectors.globalItems.ticketsButton) + .wait(selectors.ticketsIndex.searchResult) + .parsedUrl() + .then((url) => { + expect(url.hash).toEqual('#!/ticket/index'); + done(); + }).catch(done.fail); }); - it('should search for a specific ticket', done => { + it('should search for a specific ticket', (done) => { return nightmare - .wait(selectors.ticketsIndex.searchResult) - .type(selectors.ticketsIndex.searchTicketInput, 'id:16') - .click(selectors.ticketsIndex.searchButton) - .waitForNumberOfElements(selectors.ticketsIndex.searchResult, 1) - .countElement(selectors.ticketsIndex.searchResult) - .then(result => { - expect(result).toEqual(1); - done(); - }).catch(done.fail); + .wait(selectors.ticketsIndex.searchResult) + .type(selectors.ticketsIndex.searchTicketInput, 'id:16') + .click(selectors.ticketsIndex.searchButton) + .waitForNumberOfElements(selectors.ticketsIndex.searchResult, 1) + .countElement(selectors.ticketsIndex.searchResult) + .then((result) => { + expect(result).toEqual(1); + done(); + }).catch(done.fail); }); - it(`should click on the search result to access to the ticket Sale`, done => { + it(`should click on the search result to access to the ticket Sale`, (done) => { return nightmare - .waitForTextInElement(selectors.ticketsIndex.searchResult, 'address 21') - .waitToClick(selectors.ticketsIndex.searchResult) - .waitToClick(selectors.ticketSales.saleButton) - .waitForURL('/sale') - .url() - .then(url => { - expect(url).toContain('/sale'); - done(); - }).catch(done.fail); + .waitForTextInElement(selectors.ticketsIndex.searchResult, 'address 21') + .waitToClick(selectors.ticketsIndex.searchResult) + .waitToClick(selectors.ticketSales.saleButton) + .waitForURL('/sale') + .url() + .then((url) => { + expect(url).toContain('/sale'); + done(); + }).catch(done.fail); }); - it(`should check the zoomed image isnt present`, done => { + it(`should check the zoomed image isnt present`, (done) => { return nightmare - .countElement(selectors.ticketSales.firstSaleZoomedImage) - .then(result => { - expect(result).toEqual(0); - done(); - }).catch(done.fail); + .countElement(selectors.ticketSales.firstSaleZoomedImage) + .then((result) => { + expect(result).toEqual(0); + done(); + }).catch(done.fail); }); - it(`should click on the thumbnail image of the 1st sale and see the zoomed image`, done => { + it(`should click on the thumbnail image of the 1st sale and see the zoomed image`, (done) => { return nightmare - .waitToClick(selectors.ticketSales.firstSaleThumbnailImage) - .countElement(selectors.ticketSales.firstSaleZoomedImage) - .then(result => { - expect(result).toEqual(1); - done(); - }).catch(done.fail); + .waitToClick(selectors.ticketSales.firstSaleThumbnailImage) + .countElement(selectors.ticketSales.firstSaleZoomedImage) + .then((result) => { + expect(result).toEqual(1); + done(); + }).catch(done.fail); }); - it(`should click on the zoomed image to close it`, done => { + it(`should click on the zoomed image to close it`, (done) => { return nightmare - .waitToClick(selectors.ticketSales.firstSaleZoomedImage) - .countElement(selectors.ticketSales.firstSaleZoomedImage) - .then(result => { - expect(result).toEqual(0); - done(); - }).catch(done.fail); + .waitToClick(selectors.ticketSales.firstSaleZoomedImage) + .countElement(selectors.ticketSales.firstSaleZoomedImage) + .then((result) => { + expect(result).toEqual(0); + done(); + }).catch(done.fail); }); - it(`should confirm the item descriptor insnt visible yet`, done => { + it(`should confirm the item descriptor insnt visible yet`, (done) => { return nightmare - .isVisible(selectors.ticketSales.saleDescriptorPopover) - .then(visible => { - expect(visible).toBeFalsy(); - done(); - }).catch(done.fail); + .isVisible(selectors.ticketSales.saleDescriptorPopover) + .then((visible) => { + expect(visible).toBeFalsy(); + done(); + }).catch(done.fail); }); - it(`should click on the first sale ID making the item descriptor visible`, done => { + it(`should click on the first sale ID making the item descriptor visible`, (done) => { return nightmare - .waitToClick(selectors.ticketSales.firstSaleID) - .wait(1000) - .isVisible(selectors.ticketSales.saleDescriptorPopover) - .then(visible => { - expect(visible).toBeTruthy(); - done(); - }).catch(done.fail); + .waitToClick(selectors.ticketSales.firstSaleID) + .wait(1000) + .isVisible(selectors.ticketSales.saleDescriptorPopover) + .then((visible) => { + expect(visible).toBeTruthy(); + done(); + }).catch(done.fail); }); - it(`should click on the descriptor image of the 1st sale and see the zoomed image`, done => { + it(`should click on the descriptor image of the 1st sale and see the zoomed image`, (done) => { return nightmare - .waitToClick('vn-item-descriptor img') - .countElement(selectors.ticketSales.firstSaleZoomedImage) - .then(result => { - expect(result).toEqual(1); - done(); - }).catch(done.fail); + .waitToClick('vn-item-descriptor img') + .countElement(selectors.ticketSales.firstSaleZoomedImage) + .then((result) => { + expect(result).toEqual(1); + done(); + }).catch(done.fail); }); - it(`should click on the zoomed image to close it`, done => { + it(`should click on the zoomed image to close it`, (done) => { return nightmare - .waitToClick(selectors.ticketSales.firstSaleZoomedImage) - .countElement(selectors.ticketSales.firstSaleZoomedImage) - .then(result => { - expect(result).toEqual(0); - done(); - }).catch(done.fail); + .waitToClick(selectors.ticketSales.firstSaleZoomedImage) + .countElement(selectors.ticketSales.firstSaleZoomedImage) + .then((result) => { + expect(result).toEqual(0); + done(); + }).catch(done.fail); }); - it(`should click on the summary icon of the item-descriptor to access to the item summary`, done => { + it(`should click on the summary icon of the item-descriptor to access to the item summary`, (done) => { return nightmare - .waitToClick(selectors.ticketSales.saleDescriptorPopoverSummaryButton) - .waitForURL('/summary') - .url() - .then(url => { - expect(url).toContain('/summary'); - done(); - }).catch(done.fail); + .waitToClick(selectors.ticketSales.saleDescriptorPopoverSummaryButton) + .waitForURL('/summary') + .url() + .then((url) => { + expect(url).toContain('/summary'); + done(); + }).catch(done.fail); }); - it('should return to ticket sales section', done => { + it('should return to ticket sales section', (done) => { return nightmare - .waitToClick(selectors.globalItems.applicationsMenuButton) - .wait(selectors.globalItems.applicationsMenuVisible) - .waitToClick(selectors.globalItems.ticketsButton) - .wait(selectors.ticketsIndex.searchResult) - .type(selectors.ticketsIndex.searchTicketInput, 'id:16') - .click(selectors.ticketsIndex.searchButton) - .waitForNumberOfElements(selectors.ticketsIndex.searchResult, 1) - .waitForTextInElement(selectors.ticketsIndex.searchResult, 'address 21') - .waitToClick(selectors.ticketsIndex.searchResult) - .waitToClick(selectors.ticketSales.saleButton) - .waitForURL('/sale') - .url() - .then(url => { - expect(url).toContain('/sale'); - done(); - }).catch(done.fail); + .waitToClick(selectors.globalItems.applicationsMenuButton) + .wait(selectors.globalItems.applicationsMenuVisible) + .waitToClick(selectors.globalItems.ticketsButton) + .wait(selectors.ticketsIndex.searchResult) + .type(selectors.ticketsIndex.searchTicketInput, 'id:16') + .click(selectors.ticketsIndex.searchButton) + .waitForNumberOfElements(selectors.ticketsIndex.searchResult, 1) + .waitForTextInElement(selectors.ticketsIndex.searchResult, 'address 21') + .waitToClick(selectors.ticketsIndex.searchResult) + .waitToClick(selectors.ticketSales.saleButton) + .waitForURL('/sale') + .url() + .then((url) => { + expect(url).toContain('/sale'); + done(); + }).catch(done.fail); }); - it('should try to add a higher quantity value and then receive an error', done => { + it('should try to add a higher quantity value and then receive an error', (done) => { return nightmare - .waitToClick(selectors.ticketSales.firstSaleQuantityClearInput) - .type(selectors.ticketSales.firstSaleQuantity, '9\u000d') - .waitForLastSnackbar() - .then(result => { - expect(result).toEqual('The new quantity should be smaller than the old one'); - done(); - }).catch(done.fail); + .waitToClick(selectors.ticketSales.firstSaleQuantityClearInput) + .type(selectors.ticketSales.firstSaleQuantity, '9\u000d') + .waitForLastSnackbar() + .then((result) => { + expect(result).toEqual('The new quantity should be smaller than the old one'); + done(); + }).catch(done.fail); }); - it('should remove 1 from quantity', done => { + it('should remove 1 from quantity', (done) => { return nightmare - .waitToClick(selectors.ticketSales.firstSaleQuantityClearInput) - .type(selectors.ticketSales.firstSaleQuantity, '4\u000d') - .waitForLastSnackbar() - .then(result => { - expect(result).toEqual('Data saved!'); - done(); - }).catch(done.fail); + .waitToClick(selectors.ticketSales.firstSaleQuantityClearInput) + .type(selectors.ticketSales.firstSaleQuantity, '4\u000d') + .waitForLastSnackbar() + .then((result) => { + expect(result).toEqual('Data saved!'); + done(); + }).catch(done.fail); }); - it('should update the price', done => { + it('should update the price', (done) => { return nightmare - .waitToClick(selectors.ticketSales.firstSalePrice) - .wait(selectors.ticketSales.firstSalePriceInput) - .type(selectors.ticketSales.firstSalePriceInput, 5) - .type('body', '\u000d') // simulates enter - .waitForLastSnackbar() - .then(result => { - expect(result).toEqual('Data saved!'); - done(); - }).catch(done.fail); + .waitToClick(selectors.ticketSales.firstSalePrice) + .wait(selectors.ticketSales.firstSalePriceInput) + .type(selectors.ticketSales.firstSalePriceInput, 5) + .type('body', '\u000d') // simulates enter + .waitForLastSnackbar() + .then((result) => { + expect(result).toEqual('Data saved!'); + done(); + }).catch(done.fail); }); - it('should confirm the price have been updated', done => { + it('should confirm the price have been updated', (done) => { return nightmare - .getInnerText(selectors.ticketSales.firstSalePrice) - .then(result => { - expect(result).toContain('5.00'); - done(); - }).catch(done.fail); + .getInnerText(selectors.ticketSales.firstSalePrice) + .then((result) => { + expect(result).toContain('5.00'); + done(); + }).catch(done.fail); }); - it('should confirm the total price for that item have been updated', done => { + it('should confirm the total price for that item have been updated', (done) => { return nightmare - .getInnerText(selectors.ticketSales.firstSaleImport) - .then(result => { - expect(result).toContain('20.00'); - done(); - }).catch(done.fail); + .getInnerText(selectors.ticketSales.firstSaleImport) + .then((result) => { + expect(result).toContain('20.00'); + done(); + }).catch(done.fail); }); - it('should update the discount', done => { + it('should update the discount', (done) => { return nightmare - .waitToClick(selectors.ticketSales.firstSaleDiscount) - .wait('vn-textfield[label="Discount"] > div[class="container selected"]') // a function selects the text after it's loaded - .type(selectors.ticketSales.firstSaleDiscountInput, 50) - .type('body', '\u000d') // simulates enter - .waitForLastSnackbar() - .then(result => { - expect(result).toEqual('Data saved!'); - done(); - }).catch(done.fail); + .waitToClick(selectors.ticketSales.firstSaleDiscount) + .wait('vn-textfield[label="Discount"] > div[class="container selected"]') // a function selects the text after it's loaded + .type(selectors.ticketSales.firstSaleDiscountInput, 50) + .type('body', '\u000d') // simulates enter + .waitForLastSnackbar() + .then((result) => { + expect(result).toEqual('Data saved!'); + done(); + }).catch(done.fail); }); - it('should confirm the discount have been updated', done => { + it('should confirm the discount have been updated', (done) => { return nightmare - .waitForTextInElement(selectors.ticketSales.firstSaleDiscount, '50 %') - .getInnerText(selectors.ticketSales.firstSaleDiscount) - .then(result => { - expect(result).toContain('50 %'); - done(); - }).catch(done.fail); + .waitForTextInElement(selectors.ticketSales.firstSaleDiscount, '50 %') + .getInnerText(selectors.ticketSales.firstSaleDiscount) + .then((result) => { + expect(result).toContain('50 %'); + done(); + }).catch(done.fail); }); - it('should confirm the total import for that item have been updated', done => { + it('should confirm the total import for that item have been updated', (done) => { return nightmare - .waitForTextInElement(selectors.ticketSales.firstSaleImport, '10.00') - .getInnerText(selectors.ticketSales.firstSaleImport) - .then(result => { - expect(result).toContain('10.00'); - done(); - }).catch(done.fail); + .waitForTextInElement(selectors.ticketSales.firstSaleImport, '10.00') + .getInnerText(selectors.ticketSales.firstSaleImport) + .then((result) => { + expect(result).toContain('10.00'); + done(); + }).catch(done.fail); }); - it('should select the third sale and create a claim of it', done => { + it('should select the third sale and create a claim of it', (done) => { return nightmare - .waitToClick(selectors.ticketSales.thirdSaleCheckbox) - .waitToClick(selectors.ticketSales.moreMenuButton) - .waitToClick(selectors.ticketSales.moreMenuCreateClaim) - .waitForLogin('salesPerson') - .waitToClick(selectors.globalItems.applicationsMenuButton) - .wait(selectors.globalItems.applicationsMenuVisible) - .waitToClick(selectors.globalItems.claimsButton) - .wait(selectors.claimsIndex.searchResult) - .parsedUrl() - .then(url => { - expect(url.hash).toEqual('#!/claim/index'); - done(); - }).catch(done.fail); + .waitToClick(selectors.ticketSales.thirdSaleCheckbox) + .waitToClick(selectors.ticketSales.moreMenuButton) + .waitToClick(selectors.ticketSales.moreMenuCreateClaim) + .waitForLogin('salesPerson') + .waitToClick(selectors.globalItems.applicationsMenuButton) + .wait(selectors.globalItems.applicationsMenuVisible) + .waitToClick(selectors.globalItems.claimsButton) + .wait(selectors.claimsIndex.searchResult) + .parsedUrl() + .then((url) => { + expect(url.hash).toEqual('#!/claim/index'); + done(); + }).catch(done.fail); }); - it('should click on the Claims button of the top bar menu', done => { + it('should click on the Claims button of the top bar menu', (done) => { return nightmare - .waitToClick(selectors.globalItems.applicationsMenuButton) - .wait(selectors.globalItems.applicationsMenuVisible) - .waitToClick(selectors.globalItems.claimsButton) - .wait(selectors.claimsIndex.searchClaimInput) - .parsedUrl() - .then(url => { - expect(url.hash).toEqual('#!/claim/index'); - done(); - }).catch(done.fail); + .waitToClick(selectors.globalItems.applicationsMenuButton) + .wait(selectors.globalItems.applicationsMenuVisible) + .waitToClick(selectors.globalItems.claimsButton) + .wait(selectors.claimsIndex.searchClaimInput) + .parsedUrl() + .then((url) => { + expect(url.hash).toEqual('#!/claim/index'); + done(); + }).catch(done.fail); }); - it('should search for the claim with id 4', done => { + it('should search for the claim with id 4', (done) => { return nightmare - .wait(selectors.claimsIndex.searchResult) - .type(selectors.claimsIndex.searchClaimInput, 4) - .click(selectors.claimsIndex.searchButton) - .waitForNumberOfElements(selectors.claimsIndex.searchResult, 1) - .countElement(selectors.claimsIndex.searchResult) - .then(result => { - expect(result).toEqual(1); - done(); - }).catch(done.fail); + .wait(selectors.claimsIndex.searchResult) + .type(selectors.claimsIndex.searchClaimInput, 4) + .click(selectors.claimsIndex.searchButton) + .waitForNumberOfElements(selectors.claimsIndex.searchResult, 1) + .countElement(selectors.claimsIndex.searchResult) + .then((result) => { + expect(result).toEqual(1); + done(); + }).catch(done.fail); }); - it('should click the Tickets button of the top bar menu', done => { + it('should click the Tickets button of the top bar menu', (done) => { return nightmare - .waitToClick(selectors.globalItems.applicationsMenuButton) - .wait(selectors.globalItems.applicationsMenuVisible) - .waitToClick(selectors.globalItems.ticketsButton) - .wait(selectors.ticketsIndex.searchResult) - .parsedUrl() - .then(url => { - expect(url.hash).toEqual('#!/ticket/index'); - done(); - }).catch(done.fail); + .waitToClick(selectors.globalItems.applicationsMenuButton) + .wait(selectors.globalItems.applicationsMenuVisible) + .waitToClick(selectors.globalItems.ticketsButton) + .wait(selectors.ticketsIndex.searchResult) + .parsedUrl() + .then((url) => { + expect(url.hash).toEqual('#!/ticket/index'); + done(); + }).catch(done.fail); }); - it('should search the ticket', done => { + it('should search the ticket', (done) => { return nightmare - .wait(selectors.ticketsIndex.searchResult) - .type(selectors.ticketsIndex.searchTicketInput, 'id:16') - .click(selectors.ticketsIndex.searchButton) - .waitForNumberOfElements(selectors.ticketsIndex.searchResult, 1) - .countElement(selectors.ticketsIndex.searchResult) - .then(result => { - expect(result).toEqual(1); - done(); - }).catch(done.fail); + .wait(selectors.ticketsIndex.searchResult) + .type(selectors.ticketsIndex.searchTicketInput, 'id:16') + .click(selectors.ticketsIndex.searchButton) + .waitForNumberOfElements(selectors.ticketsIndex.searchResult, 1) + .countElement(selectors.ticketsIndex.searchResult) + .then((result) => { + expect(result).toEqual(1); + done(); + }).catch(done.fail); }); - it(`should click on the result to access to the ticket Sale`, done => { + it(`should click on the result to access to the ticket Sale`, (done) => { return nightmare - .waitForTextInElement(selectors.ticketsIndex.searchResult, 'address 21') - .waitToClick(selectors.ticketsIndex.searchResult) - .waitToClick(selectors.ticketSales.saleButton) - .waitForURL('/sale') - .url() - .then(url => { - expect(url).toContain('/sale'); - done(); - }).catch(done.fail); + .waitForTextInElement(selectors.ticketsIndex.searchResult, 'address 21') + .waitToClick(selectors.ticketsIndex.searchResult) + .waitToClick(selectors.ticketSales.saleButton) + .waitForURL('/sale') + .url() + .then((url) => { + expect(url).toContain('/sale'); + done(); + }).catch(done.fail); }); - it('should select the third sale and delete it', done => { + it('should select the third sale and delete it', (done) => { return nightmare - .waitToClick(selectors.ticketSales.thirdSaleCheckbox) - .waitToClick(selectors.ticketSales.deleteSaleButton) - .waitToClick(selectors.ticketSales.acceptDeleteLineButton) - .waitForLastSnackbar() - .then(result => { - expect(result).toEqual('Data saved!'); - done(); - }).catch(done.fail); + .waitToClick(selectors.ticketSales.thirdSaleCheckbox) + .waitToClick(selectors.ticketSales.deleteSaleButton) + .waitToClick(selectors.ticketSales.acceptDeleteLineButton) + .waitForLastSnackbar() + .then((result) => { + expect(result).toEqual('Data saved!'); + done(); + }).catch(done.fail); }); - it(`should confirm the third sale was deleted`, done => { + it(`should confirm the third sale was deleted`, (done) => { return nightmare - .countElement(selectors.ticketSales.saleLine) - .then(result => { - expect(result).toEqual(3); - done(); - }).catch(done.fail); + .countElement(selectors.ticketSales.saleLine) + .then((result) => { + expect(result).toEqual(3); + done(); + }).catch(done.fail); }); - it('should select the third sale and attempt to send it to a frozen client ticket', done => { + it('should select the third sale and attempt to send it to a frozen client ticket', (done) => { return nightmare - .waitToClick(selectors.ticketSales.thirdSaleCheckbox) - .waitToClick(selectors.ticketSales.transferSaleButton) - .wait(selectors.ticketSales.moveToTicketInput) - .type(selectors.ticketSales.moveToTicketInput, 2) - .waitToClick(selectors.ticketSales.moveToTicketButton) - .waitForLastSnackbar() - .then(result => { - expect(result).toEqual(`The sales of this ticket can't be modified`); - done(); - }).catch(done.fail); + .waitToClick(selectors.ticketSales.thirdSaleCheckbox) + .waitToClick(selectors.ticketSales.transferSaleButton) + .wait(selectors.ticketSales.moveToTicketInput) + .type(selectors.ticketSales.moveToTicketInput, 2) + .waitToClick(selectors.ticketSales.moveToTicketButton) + .waitForLastSnackbar() + .then((result) => { + expect(result).toEqual(`The sales of this ticket can't be modified`); + done(); + }).catch(done.fail); }); - it('should transfer the sale to a valid ticket', done => { + it('should transfer the sale to a valid ticket', (done) => { return nightmare - .waitToClick(selectors.ticketSales.moveToTicketInputClearButton) - .type(selectors.ticketSales.moveToTicketInput, 12) - .waitToClick(selectors.ticketSales.moveToTicketButton) - .waitForURL('ticket/12/sale') - .url() - .then(result => { - expect(result).toContain(`ticket/12/sale`); - done(); - }).catch(done.fail); + .waitToClick(selectors.ticketSales.moveToTicketInputClearButton) + .type(selectors.ticketSales.moveToTicketInput, 12) + .waitToClick(selectors.ticketSales.moveToTicketButton) + .waitForURL('ticket/12/sale') + .url() + .then((result) => { + expect(result).toContain(`ticket/12/sale`); + done(); + }).catch(done.fail); }); - it('should confirm the transfered line is the correct one', done => { + it('should confirm the transfered line is the correct one', (done) => { return nightmare - .wait(selectors.ticketSales.firstSaleText) - .getInnerText(selectors.ticketSales.firstSaleText) - .then(result => { - expect(result).toContain(`Mark I`); - done(); - }).catch(done.fail); + .wait(selectors.ticketSales.firstSaleText) + .getInnerText(selectors.ticketSales.firstSaleText) + .then((result) => { + expect(result).toContain(`Mark I`); + done(); + }).catch(done.fail); }); - it('should go back to the original ticket sales section', done => { + it('should go back to the original ticket sales section', (done) => { return nightmare - .waitToClick(selectors.itemsIndex.goBackToModuleIndexButton) - .wait(selectors.ticketsIndex.searchResult) - .type(selectors.ticketsIndex.searchTicketInput, 'id:16') - .click(selectors.ticketsIndex.searchButton) - .waitForNumberOfElements(selectors.ticketsIndex.searchResult, 1) - .waitForTextInElement(selectors.ticketsIndex.searchResult, 'address 21') - .waitToClick(selectors.ticketsIndex.searchResult) - .waitToClick(selectors.ticketSales.saleButton) - .waitForURL('/sale') - .url() - .then(url => { - expect(url).toContain('/sale'); - done(); - }).catch(done.fail); + .waitToClick(selectors.itemsIndex.goBackToModuleIndexButton) + .wait(selectors.ticketsIndex.searchResult) + .type(selectors.ticketsIndex.searchTicketInput, 'id:16') + .click(selectors.ticketsIndex.searchButton) + .waitForNumberOfElements(selectors.ticketsIndex.searchResult, 1) + .waitForTextInElement(selectors.ticketsIndex.searchResult, 'address 21') + .waitToClick(selectors.ticketsIndex.searchResult) + .waitToClick(selectors.ticketSales.saleButton) + .waitForURL('/sale') + .url() + .then((url) => { + expect(url).toContain('/sale'); + done(); + }).catch(done.fail); }); - it(`should confirm the original ticket has only two lines now`, done => { + it(`should confirm the original ticket has only two lines now`, (done) => { return nightmare - .wait(selectors.ticketSales.saleLine) - .countElement(selectors.ticketSales.saleLine) - .then(result => { - expect(result).toEqual(2); - done(); - }).catch(done.fail); + .wait(selectors.ticketSales.saleLine) + .countElement(selectors.ticketSales.saleLine) + .then((result) => { + expect(result).toEqual(2); + done(); + }).catch(done.fail); }); - it('should go back to the receiver ticket sales section', done => { + it('should go back to the receiver ticket sales section', (done) => { return nightmare - .waitToClick(selectors.itemsIndex.goBackToModuleIndexButton) - .wait(selectors.ticketsIndex.searchResult) - .type(selectors.ticketsIndex.searchTicketInput, 'id:12') - .click(selectors.ticketsIndex.searchButton) - .waitForNumberOfElements(selectors.ticketsIndex.searchResult, 1) - .waitForTextInElement(selectors.ticketsIndex.searchResult, 'address 21') - .waitToClick(selectors.ticketsIndex.searchResult) - .waitToClick(selectors.ticketSales.saleButton) - .waitForURL('/sale') - .url() - .then(url => { - expect(url).toContain('/sale'); - done(); - }).catch(done.fail); + .waitToClick(selectors.itemsIndex.goBackToModuleIndexButton) + .wait(selectors.ticketsIndex.searchResult) + .type(selectors.ticketsIndex.searchTicketInput, 'id:12') + .click(selectors.ticketsIndex.searchButton) + .waitForNumberOfElements(selectors.ticketsIndex.searchResult, 1) + .waitForTextInElement(selectors.ticketsIndex.searchResult, 'address 21') + .waitToClick(selectors.ticketsIndex.searchResult) + .waitToClick(selectors.ticketSales.saleButton) + .waitForURL('/sale') + .url() + .then((url) => { + expect(url).toContain('/sale'); + done(); + }).catch(done.fail); }); - it('should transfer the sale back to the original ticket', done => { + it('should transfer the sale back to the original ticket', (done) => { return nightmare - .waitToClick(selectors.ticketSales.firstSaleCheckbox) - .waitToClick(selectors.ticketSales.transferSaleButton) - .wait(selectors.ticketSales.moveToTicketInput) - .type(selectors.ticketSales.moveToTicketInput, 16) - .waitToClick(selectors.ticketSales.moveToTicketButton) - .waitForURL('ticket/16/sale') - .url() - .then(result => { - expect(result).toContain(`ticket/16/sale`); - done(); - }).catch(done.fail); + .waitToClick(selectors.ticketSales.firstSaleCheckbox) + .waitToClick(selectors.ticketSales.transferSaleButton) + .wait(selectors.ticketSales.moveToTicketInput) + .type(selectors.ticketSales.moveToTicketInput, 16) + .waitToClick(selectors.ticketSales.moveToTicketButton) + .waitForURL('ticket/16/sale') + .url() + .then((result) => { + expect(result).toContain(`ticket/16/sale`); + done(); + }).catch(done.fail); }); - it('should confirm the original ticket received the line', done => { + it('should confirm the original ticket received the line', (done) => { return nightmare - .wait(selectors.ticketSales.saleLine) - .countElement(selectors.ticketSales.saleLine) - .then(result => { - expect(result).toEqual(3); - done(); - }).catch(done.fail); + .wait(selectors.ticketSales.saleLine) + .countElement(selectors.ticketSales.saleLine) + .then((result) => { + expect(result).toEqual(3); + done(); + }).catch(done.fail); }); - it('should select the second and third sale and tranfer them to a new ticket then get to the ticket index', done => { + it('should select the second and third sale and tranfer them to a new ticket then get to the ticket index', (done) => { return nightmare - .waitToClick(selectors.ticketSales.secondSaleCheckbox) - .waitToClick(selectors.ticketSales.thirdSaleCheckbox) - .waitToClick(selectors.ticketSales.transferSaleButton) - .waitToClick(selectors.ticketSales.moveToNewTicketButton) - .waitForLogin('salesPerson') - .waitToClick(selectors.globalItems.applicationsMenuButton) - .wait(selectors.globalItems.applicationsMenuVisible) - .waitToClick(selectors.globalItems.ticketsButton) - .wait(selectors.ticketsIndex.searchResult) - .parsedUrl() - .then(url => { - expect(url.hash).toEqual('#!/ticket/index'); - done(); - }).catch(done.fail); + .waitToClick(selectors.ticketSales.secondSaleCheckbox) + .waitToClick(selectors.ticketSales.thirdSaleCheckbox) + .waitToClick(selectors.ticketSales.transferSaleButton) + .waitToClick(selectors.ticketSales.moveToNewTicketButton) + .waitForLogin('salesPerson') + .waitToClick(selectors.globalItems.applicationsMenuButton) + .wait(selectors.globalItems.applicationsMenuVisible) + .waitToClick(selectors.globalItems.ticketsButton) + .wait(selectors.ticketsIndex.searchResult) + .parsedUrl() + .then((url) => { + expect(url.hash).toEqual('#!/ticket/index'); + done(); + }).catch(done.fail); }); - it('should search for a specific created ticket', done => { + it('should search for a specific created ticket', (done) => { return nightmare - .wait(selectors.ticketsIndex.searchResult) - .type(selectors.ticketsIndex.searchTicketInput, 'id:22') - .click(selectors.ticketsIndex.searchButton) - .waitForNumberOfElements(selectors.ticketsIndex.searchResult, 1) - .countElement(selectors.ticketsIndex.searchResult) - .then(result => { - expect(result).toEqual(1); - done(); - }).catch(done.fail); + .wait(selectors.ticketsIndex.searchResult) + .type(selectors.ticketsIndex.searchTicketInput, 'id:22') + .click(selectors.ticketsIndex.searchButton) + .waitForNumberOfElements(selectors.ticketsIndex.searchResult, 1) + .countElement(selectors.ticketsIndex.searchResult) + .then((result) => { + expect(result).toEqual(1); + done(); + }).catch(done.fail); }); - it(`should click on the search result to access to the ticket Sale`, done => { + it(`should click on the search result to access to the ticket Sale`, (done) => { return nightmare - .waitForTextInElement(selectors.ticketsIndex.searchResult, 'address 21') - .waitToClick(selectors.ticketsIndex.searchResult) - .waitToClick(selectors.ticketSales.saleButton) - .waitForURL('/sale') - .url() - .then(url => { - expect(url).toContain('/sale'); - done(); - }).catch(done.fail); + .waitForTextInElement(selectors.ticketsIndex.searchResult, 'address 21') + .waitToClick(selectors.ticketsIndex.searchResult) + .waitToClick(selectors.ticketSales.saleButton) + .waitForURL('/sale') + .url() + .then((url) => { + expect(url).toContain('/sale'); + done(); + }).catch(done.fail); }); - it('should confirm the new ticket received both lines', done => { + it('should confirm the new ticket received both lines', (done) => { return nightmare - .countElement(selectors.ticketSales.saleLine) - .then(result => { - expect(result).toEqual(2); - done(); - }).catch(done.fail); + .countElement(selectors.ticketSales.saleLine) + .then((result) => { + expect(result).toEqual(2); + done(); + }).catch(done.fail); }); - it('should check the first sale reserved icon isnt visible', done => { + it('should check the first sale reserved icon isnt visible', (done) => { return nightmare - .isVisible(selectors.ticketSales.firstSaleReservedIcon) - .then(result => { - expect(result).toBeFalsy(); - done(); - }).catch(done.fail); + .isVisible(selectors.ticketSales.firstSaleReservedIcon) + .then((result) => { + expect(result).toBeFalsy(); + done(); + }).catch(done.fail); }); - it('should mark the first sale as reserved', done => { + it('should mark the first sale as reserved', (done) => { return nightmare - .waitToClick(selectors.ticketSales.firstSaleCheckbox) - .waitToClick(selectors.ticketSales.moreMenuButton) - .waitToClick(selectors.ticketSales.moreMenuReseveOption) - .waitForClassNotPresent(selectors.ticketSales.firstSaleReservedIcon, 'ng-hide') - .isVisible(selectors.ticketSales.firstSaleReservedIcon) - .then(result => { - expect(result).toBeTruthy(); - done(); - }).catch(done.fail); + .waitToClick(selectors.ticketSales.firstSaleCheckbox) + .waitToClick(selectors.ticketSales.moreMenuButton) + .waitToClick(selectors.ticketSales.moreMenuReseveOption) + .waitForClassNotPresent(selectors.ticketSales.firstSaleReservedIcon, 'ng-hide') + .isVisible(selectors.ticketSales.firstSaleReservedIcon) + .then((result) => { + expect(result).toBeTruthy(); + done(); + }).catch(done.fail); }); - it('should unmark the first sale as reserved', done => { + it('should unmark the first sale as reserved', (done) => { return nightmare - .waitToClick(selectors.ticketSales.firstSaleCheckbox) - .waitToClick(selectors.ticketSales.moreMenuButton) - .waitToClick(selectors.ticketSales.moreMenuUnmarkResevedOption) - .waitForClassPresent(selectors.ticketSales.firstSaleReservedIcon, 'ng-hide') - .isVisible(selectors.ticketSales.firstSaleReservedIcon) - .then(result => { - expect(result).toBeFalsy(); - done(); - }).catch(done.fail); + .waitToClick(selectors.ticketSales.firstSaleCheckbox) + .waitToClick(selectors.ticketSales.moreMenuButton) + .waitToClick(selectors.ticketSales.moreMenuUnmarkResevedOption) + .waitForClassPresent(selectors.ticketSales.firstSaleReservedIcon, 'ng-hide') + .isVisible(selectors.ticketSales.firstSaleReservedIcon) + .then((result) => { + expect(result).toBeFalsy(); + done(); + }).catch(done.fail); }); // #744 fix edit sale bug, boton MAS descuento @@ -550,241 +550,241 @@ describe('Ticket Edit sale path', () => { // }).catch(done.fail); // }); - it('should log in as Production role and go to the ticket index', done => { + it('should log in as Production role and go to the ticket index', (done) => { return nightmare - .waitToClick(selectors.globalItems.logOutButton) - .waitForLogin('production') - .waitToClick(selectors.globalItems.applicationsMenuButton) - .wait(selectors.globalItems.applicationsMenuVisible) - .waitToClick(selectors.globalItems.ticketsButton) - .wait(selectors.ticketsIndex.searchResult) - .parsedUrl() - .then(url => { - expect(url.hash).toEqual('#!/ticket/index'); - done(); - }).catch(done.fail); - }); - - it('should now search for a specific ticket', done => { - return nightmare - .wait(selectors.ticketsIndex.searchResult) - .type(selectors.ticketsIndex.searchTicketInput, 'id:16') - .click(selectors.ticketsIndex.searchButton) - .waitForNumberOfElements(selectors.ticketsIndex.searchResult, 1) - .countElement(selectors.ticketsIndex.searchResult) - .then(result => { - expect(result).toEqual(1); - done(); - }).catch(done.fail); - }); - - it(`should now click on the search result to access to the ticket Tracking`, done => { - return nightmare - .waitForTextInElement(selectors.ticketsIndex.searchResult, 'address 21') - .waitToClick(selectors.ticketsIndex.searchResult) - .waitToClick(selectors.ticketTracking.trackingButton) - .waitForURL('/tracking/index') - .url() - .then(url => { - expect(url).toContain('/tracking/index'); - done(); - }).catch(done.fail); - }); - - it(`should click on the edit ticket tracking state button`, done => { - return nightmare - .waitToClick(selectors.ticketTracking.createStateButton) - .waitForURL('/tracking/edit') - .url() - .then(url => { - expect(url).toContain('/tracking/edit'); - done(); - }).catch(done.fail); - }); - - it(`should set the state of the ticket to preparation`, done => { - return nightmare - .waitToClick(selectors.ticketTracking.stateSelect) - .wait(selectors.ticketTracking.stateSelectInput) - .type(selectors.ticketTracking.stateSelectInput, 'Preparación') - .waitToClick(selectors.ticketTracking.stateSelectFirstResult) - .waitForTextInInput(selectors.ticketTracking.stateSelectInput, 'Preparación') - .click(selectors.ticketTracking.saveButton) - .waitForURL('/tracking/index') - .url() - .then(url => { - expect(url).toContain('/tracking/index'); - done(); - }).catch(done.fail); - }); - - it(`should click on the ticket Sale menu button`, done => { - return nightmare - .waitToClick(selectors.ticketSales.saleButton) - .waitForURL('/sale') - .url() - .then(url => { - expect(url).toContain('/sale'); - done(); - }).catch(done.fail); - }); - - describe('when state is preparation and loged as Production', () => { - it(`should not be able to edit the sale price`, done => { - return nightmare - .waitToClick(selectors.ticketSales.firstSalePrice) - .exists(selectors.ticketSales.firstSalePriceInput) - .then(result => { - expect(result).toBeFalsy(); - done(); - }).catch(done.fail); - }); - - it(`should not be able to edit the sale discount`, done => { - return nightmare - .waitToClick(selectors.ticketSales.firstSaleDiscount) - .exists(selectors.ticketSales.firstSaleDiscountInput) - .then(result => { - expect(result).toBeFalsy(); - done(); - }).catch(done.fail); - }); - - it(`should not be able to edit the sale state`, done => { - return nightmare - .waitToClick(selectors.ticketSales.stateMenuButton) - .exists(selectors.ticketSales.stateMenuOptions) - .then(result => { - expect(result).toBeFalsy(); - done(); - }).catch(done.fail); - }); - - it('should log in as salesPerson role and go to the ticket index', done => { - return nightmare .waitToClick(selectors.globalItems.logOutButton) - .waitForLogin('salesPerson') + .waitForLogin('production') .waitToClick(selectors.globalItems.applicationsMenuButton) .wait(selectors.globalItems.applicationsMenuVisible) .waitToClick(selectors.globalItems.ticketsButton) .wait(selectors.ticketsIndex.searchResult) .parsedUrl() - .then(url => { + .then((url) => { expect(url.hash).toEqual('#!/ticket/index'); done(); }).catch(done.fail); - }); + }); - it('should again search for a specific ticket', done => { - return nightmare + it('should now search for a specific ticket', (done) => { + return nightmare .wait(selectors.ticketsIndex.searchResult) .type(selectors.ticketsIndex.searchTicketInput, 'id:16') .click(selectors.ticketsIndex.searchButton) .waitForNumberOfElements(selectors.ticketsIndex.searchResult, 1) .countElement(selectors.ticketsIndex.searchResult) - .then(result => { + .then((result) => { expect(result).toEqual(1); done(); }).catch(done.fail); - }); + }); - it(`should again click on the search result to access to the ticket Sales`, done => { - return nightmare + it(`should now click on the search result to access to the ticket Tracking`, (done) => { + return nightmare .waitForTextInElement(selectors.ticketsIndex.searchResult, 'address 21') .waitToClick(selectors.ticketsIndex.searchResult) + .waitToClick(selectors.ticketTracking.trackingButton) + .waitForURL('/tracking/index') + .url() + .then((url) => { + expect(url).toContain('/tracking/index'); + done(); + }).catch(done.fail); + }); + + it(`should click on the edit ticket tracking state button`, (done) => { + return nightmare + .waitToClick(selectors.ticketTracking.createStateButton) + .waitForURL('/tracking/edit') + .url() + .then((url) => { + expect(url).toContain('/tracking/edit'); + done(); + }).catch(done.fail); + }); + + it(`should set the state of the ticket to preparation`, (done) => { + return nightmare + .waitToClick(selectors.ticketTracking.stateSelect) + .wait(selectors.ticketTracking.stateSelectInput) + .type(selectors.ticketTracking.stateSelectInput, 'Preparación') + .waitToClick(selectors.ticketTracking.stateSelectFirstResult) + .waitForTextInInput(selectors.ticketTracking.stateSelectInput, 'Preparación') + .click(selectors.ticketTracking.saveButton) + .waitForURL('/tracking/index') + .url() + .then((url) => { + expect(url).toContain('/tracking/index'); + done(); + }).catch(done.fail); + }); + + it(`should click on the ticket Sale menu button`, (done) => { + return nightmare .waitToClick(selectors.ticketSales.saleButton) .waitForURL('/sale') .url() - .then(url => { + .then((url) => { expect(url).toContain('/sale'); done(); }).catch(done.fail); + }); + + describe('when state is preparation and loged as Production', () => { + it(`should not be able to edit the sale price`, (done) => { + return nightmare + .waitToClick(selectors.ticketSales.firstSalePrice) + .exists(selectors.ticketSales.firstSalePriceInput) + .then((result) => { + expect(result).toBeFalsy(); + done(); + }).catch(done.fail); + }); + + it(`should not be able to edit the sale discount`, (done) => { + return nightmare + .waitToClick(selectors.ticketSales.firstSaleDiscount) + .exists(selectors.ticketSales.firstSaleDiscountInput) + .then((result) => { + expect(result).toBeFalsy(); + done(); + }).catch(done.fail); + }); + + it(`should not be able to edit the sale state`, (done) => { + return nightmare + .waitToClick(selectors.ticketSales.stateMenuButton) + .exists(selectors.ticketSales.stateMenuOptions) + .then((result) => { + expect(result).toBeFalsy(); + done(); + }).catch(done.fail); + }); + + it('should log in as salesPerson role and go to the ticket index', (done) => { + return nightmare + .waitToClick(selectors.globalItems.logOutButton) + .waitForLogin('salesPerson') + .waitToClick(selectors.globalItems.applicationsMenuButton) + .wait(selectors.globalItems.applicationsMenuVisible) + .waitToClick(selectors.globalItems.ticketsButton) + .wait(selectors.ticketsIndex.searchResult) + .parsedUrl() + .then((url) => { + expect(url.hash).toEqual('#!/ticket/index'); + done(); + }).catch(done.fail); + }); + + it('should again search for a specific ticket', (done) => { + return nightmare + .wait(selectors.ticketsIndex.searchResult) + .type(selectors.ticketsIndex.searchTicketInput, 'id:16') + .click(selectors.ticketsIndex.searchButton) + .waitForNumberOfElements(selectors.ticketsIndex.searchResult, 1) + .countElement(selectors.ticketsIndex.searchResult) + .then((result) => { + expect(result).toEqual(1); + done(); + }).catch(done.fail); + }); + + it(`should again click on the search result to access to the ticket Sales`, (done) => { + return nightmare + .waitForTextInElement(selectors.ticketsIndex.searchResult, 'address 21') + .waitToClick(selectors.ticketsIndex.searchResult) + .waitToClick(selectors.ticketSales.saleButton) + .waitForURL('/sale') + .url() + .then((url) => { + expect(url).toContain('/sale'); + done(); + }).catch(done.fail); }); }); describe('when state is preparation and loged as salesPerson', () => { - it(`shouldnt be able to edit the sale price`, done => { + it(`shouldnt be able to edit the sale price`, (done) => { return nightmare - .waitToClick(selectors.ticketSales.firstSalePrice) - .exists(selectors.ticketSales.firstSalePriceInput) - .then(result => { - expect(result).toBeFalsy(); - done(); - }).catch(done.fail); + .waitToClick(selectors.ticketSales.firstSalePrice) + .exists(selectors.ticketSales.firstSalePriceInput) + .then((result) => { + expect(result).toBeFalsy(); + done(); + }).catch(done.fail); }); - it(`shouldnt be able to edit the sale discount`, done => { + it(`shouldnt be able to edit the sale discount`, (done) => { return nightmare - .waitToClick(selectors.ticketSales.firstSaleDiscount) - .exists(selectors.ticketSales.firstSaleDiscountInput) - .then(result => { - expect(result).toBeFalsy(); - done(); - }).catch(done.fail); + .waitToClick(selectors.ticketSales.firstSaleDiscount) + .exists(selectors.ticketSales.firstSaleDiscountInput) + .then((result) => { + expect(result).toBeFalsy(); + done(); + }).catch(done.fail); }); - it(`shouldnt be able to edit the sale state`, done => { + it(`shouldnt be able to edit the sale state`, (done) => { return nightmare - .waitToClick(selectors.ticketSales.stateMenuButton) - .exists(selectors.ticketSales.stateMenuOptions) - .then(result => { - expect(result).toBeFalsy(); - done(); - }).catch(done.fail); + .waitToClick(selectors.ticketSales.stateMenuButton) + .exists(selectors.ticketSales.stateMenuOptions) + .then((result) => { + expect(result).toBeFalsy(); + done(); + }).catch(done.fail); }); - it('should go to another ticket sales section', done => { + it('should go to another ticket sales section', (done) => { return nightmare - .waitToClick(selectors.itemsIndex.goBackToModuleIndexButton) - .wait(selectors.ticketsIndex.searchResult) - .type(selectors.ticketsIndex.searchTicketInput, 'id:17') - .click(selectors.ticketsIndex.searchButton) - .waitForNumberOfElements(selectors.ticketsIndex.searchResult, 1) - .waitForTextInElement(selectors.ticketsIndex.searchResult, 'address 26') - .waitToClick(selectors.ticketsIndex.searchResult) - .waitToClick(selectors.ticketSales.saleButton) - .waitForURL('/sale') - .url() - .then(url => { - expect(url).toContain('/sale'); - done(); - }).catch(done.fail); + .waitToClick(selectors.itemsIndex.goBackToModuleIndexButton) + .wait(selectors.ticketsIndex.searchResult) + .type(selectors.ticketsIndex.searchTicketInput, 'id:17') + .click(selectors.ticketsIndex.searchButton) + .waitForNumberOfElements(selectors.ticketsIndex.searchResult, 1) + .waitForTextInElement(selectors.ticketsIndex.searchResult, 'address 26') + .waitToClick(selectors.ticketsIndex.searchResult) + .waitToClick(selectors.ticketSales.saleButton) + .waitForURL('/sale') + .url() + .then((url) => { + expect(url).toContain('/sale'); + done(); + }).catch(done.fail); }); - it(`should be able to delete the ticket`, done => { + it(`should be able to delete the ticket`, (done) => { return nightmare - .waitToClick(selectors.ticketSales.moreMenuButton) - .waitToClick(selectors.ticketSales.moreMenuDeleteOption) - .waitToClick(selectors.ticketSales.acceptDeleteTicketButton) - .waitForURL('/ticket/index') - .url() - .then(url => { - expect(url).toContain('/ticket/index'); - done(); - }).catch(done.fail); + .waitToClick(selectors.ticketSales.moreMenuButton) + .waitToClick(selectors.ticketSales.moreMenuDeleteOption) + .waitToClick(selectors.ticketSales.acceptDeleteTicketButton) + .waitForURL('/ticket/index') + .url() + .then((url) => { + expect(url).toContain('/ticket/index'); + done(); + }).catch(done.fail); }); - it(`should search for the deleted ticket`, done => { + it(`should search for the deleted ticket`, (done) => { return nightmare - .wait(selectors.ticketsIndex.searchResult) - .type(selectors.ticketsIndex.searchTicketInput, 'id:17') - .click(selectors.ticketsIndex.searchButton) - .waitForNumberOfElements(selectors.ticketsIndex.searchResult, 1) - .countElement(selectors.ticketsIndex.searchResult) - .then(result => { - expect(result).toEqual(1); - done(); - }).catch(done.fail); + .wait(selectors.ticketsIndex.searchResult) + .type(selectors.ticketsIndex.searchTicketInput, 'id:17') + .click(selectors.ticketsIndex.searchButton) + .waitForNumberOfElements(selectors.ticketsIndex.searchResult, 1) + .countElement(selectors.ticketsIndex.searchResult) + .then((result) => { + expect(result).toEqual(1); + done(); + }).catch(done.fail); }); - it(`should search for the deleted ticket`, done => { + it(`should search for the deleted ticket`, (done) => { return nightmare - .wait(selectors.ticketsIndex.searchResultDate) - .getInnerText(selectors.ticketsIndex.searchResultDate) - .then(result => { - expect(result).toContain(2000); - done(); - }).catch(done.fail); + .wait(selectors.ticketsIndex.searchResultDate) + .getInnerText(selectors.ticketsIndex.searchResultDate) + .then((result) => { + expect(result).toContain(2000); + done(); + }).catch(done.fail); }); }); }); diff --git a/e2e/paths/ticket-module/08_list_components.spec.js b/e2e/paths/ticket-module/08_list_components.spec.js new file mode 100644 index 000000000..c983e4bc7 --- /dev/null +++ b/e2e/paths/ticket-module/08_list_components.spec.js @@ -0,0 +1,83 @@ +import selectors from '../../helpers/selectors.js'; +import createNightmare from '../../helpers/nightmare'; + +describe('Ticket List components path', () => { + const nightmare = createNightmare(); + + beforeAll(() => { + return nightmare + .waitForLogin('employee'); + }); + + it('should click on the Tickets button of the top bar menu', async () => { + const url = await nightmare + .waitToClick(selectors.globalItems.applicationsMenuButton) + .wait(selectors.globalItems.applicationsMenuVisible) + .waitToClick(selectors.globalItems.ticketsButton) + .wait(selectors.ticketsIndex.searchResult) + .parsedUrl(); + + expect(url.hash).toEqual('#!/ticket/index'); + }); + + it('should search for the ticket 1', async () => { + const result = await nightmare + .wait(selectors.ticketsIndex.searchResult) + .type(selectors.ticketsIndex.searchTicketInput, 'id:1') + .click(selectors.ticketsIndex.searchButton) + .waitForNumberOfElements(selectors.ticketsIndex.searchResult, 1) + .countElement(selectors.ticketsIndex.searchResult); + + expect(result).toEqual(1); + }); + + it(`should click on the search result to access to the ticket components`, async () => { + const url = await nightmare + .waitForTextInElement(selectors.ticketsIndex.searchResult, 'address 21') + .waitToClick(selectors.ticketsIndex.searchResult) + .waitToClick(selectors.ticketComponents.componentsButton) + .waitForURL('components') + .url(); + + expect(url).toContain('components'); + }); + + it('should confirm the total base is correct', async () => { + const name = 'Base €'; + const minLength = name.length; + + const base = await nightmare + .waitPropertyLength(selectors.ticketComponents.base, 'innerText', minLength) + .getProperty(selectors.ticketComponents.base, 'innerText'); + + + expect(base).toContain('Base'); + expect(base.length).toBeGreaterThan(minLength); + }); + + it('should confirm the total margin is correct', async () => { + const name = 'Margin €'; + const minLength = name.length; + + const margin = await nightmare + .waitPropertyLength(selectors.ticketComponents.margin, 'innerText', minLength) + .getProperty(selectors.ticketComponents.margin, 'innerText'); + + + expect(margin).toContain('Margin'); + expect(margin.length).toBeGreaterThan(minLength); + }); + + it('should confirm the total total is correct', async () => { + const name = 'Total €'; + const minLength = name.length; + + const total = await nightmare + .waitPropertyLength(selectors.ticketComponents.total, 'innerText', minLength) + .getProperty(selectors.ticketComponents.total, 'innerText'); + + + expect(total).toContain('Total'); + expect(total.length).toBeGreaterThan(minLength); + }); +});