This commit is contained in:
Carlos Jimenez Ruiz 2019-02-07 14:33:52 +01:00
parent 3610ce88d7
commit b5a1e52bf3
6 changed files with 30 additions and 23 deletions

View File

@ -127,6 +127,16 @@ let actions = {
.then(result => done(null, result), done);
},
waitPropertyValue: function(selector, property, status, done) {
this.wait(selector)
.wait((selector, property, status) => {
const element = document.querySelector(selector);
return element[property] === status;
}, selector, property, status)
.then(done)
.catch(done);
},
waitToGetProperty: function(selector, property, done) {
this.wait((selector, property) => {
const element = document.querySelector(selector);
@ -265,11 +275,11 @@ let actions = {
.catch(done);
},
waitForTextInInput: function(selector, name, done) {
waitForTextInInput: function(selector, text, done) {
this.wait(selector)
.wait((selector, name) => {
return document.querySelector(selector).value.toLowerCase().includes(name.toLowerCase());
}, selector, name)
.wait((selector, text) => {
return document.querySelector(selector).value.toLowerCase().includes(text.toLowerCase());
}, selector, text)
.then(done)
.catch(done);
},

View File

@ -7,7 +7,7 @@ describe('Ticket Edit sale path', () => {
beforeAll(() => {
nightmare
.loginAndModule('salesPerson', 'ticket')
.accessToSearchResult('id:16')
.accessToSearchResult('16')
.accessToSection('ticket.card.sale');
});
@ -34,7 +34,7 @@ describe('Ticket Edit sale path', () => {
it('should again search for a specific ticket', async() => {
const result = await nightmare
.write(selectors.ticketsIndex.searchTicketInput, 'id:16')
.write(selectors.ticketsIndex.searchTicketInput, '16')
.waitToClick(selectors.ticketsIndex.searchButton)
.waitForNumberOfElements(selectors.ticketsIndex.searchResult, 1)
.countElement(selectors.ticketsIndex.searchResult);
@ -123,7 +123,7 @@ describe('Ticket Edit sale path', () => {
.waitToClick(selectors.globalItems.applicationsMenuButton)
.wait(selectors.globalItems.applicationsMenuVisible)
.waitToClick(selectors.globalItems.ticketsButton)
.write(selectors.ticketsIndex.searchTicketInput, 'id:16')
.write(selectors.ticketsIndex.searchTicketInput, '16')
.waitToClick(selectors.ticketsIndex.searchButton)
.waitForNumberOfElements(selectors.ticketsIndex.searchResult, 1)
.waitForTextInElement(selectors.ticketsIndex.searchResult, 'address 21')
@ -249,7 +249,7 @@ describe('Ticket Edit sale path', () => {
it('should search the ticket', async() => {
const result = await nightmare
.write(selectors.ticketsIndex.searchTicketInput, 'id:16')
.write(selectors.ticketsIndex.searchTicketInput, '16')
.waitToClick(selectors.ticketsIndex.searchButton)
.waitForNumberOfElements(selectors.ticketsIndex.searchResult, 1)
.countElement(selectors.ticketsIndex.searchResult);

View File

@ -1,8 +1,7 @@
import selectors from '../../helpers/selectors.js';
import createNightmare from '../../helpers/nightmare';
// #1051 Traducciones que fallan
xdescribe('Ticket descriptor path', () => {
describe('Ticket descriptor path', () => {
const nightmare = createNightmare();
beforeAll(() => {
@ -10,9 +9,9 @@ xdescribe('Ticket descriptor path', () => {
.loginAndModule('employee', 'ticket');
});
it('should search for a specific ticket', async() => {
it('should search for an specific ticket', async() => {
const result = await nightmare
.write(selectors.ticketsIndex.searchTicketInput, 'id:17')
.write(selectors.ticketsIndex.searchTicketInput, '17')
.waitToClick(selectors.ticketsIndex.searchButton)
.waitForNumberOfElements(selectors.ticketsIndex.searchResult, 1)
.countElement(selectors.ticketsIndex.searchResult);
@ -49,7 +48,7 @@ xdescribe('Ticket descriptor path', () => {
it(`should search for the deleted ticket and check it's date`, async() => {
const result = await nightmare
.write(selectors.ticketsIndex.searchTicketInput, 'id:17')
.write(selectors.ticketsIndex.searchTicketInput, '17')
.waitToClick(selectors.ticketsIndex.searchButton)
.waitForNumberOfElements(selectors.ticketsIndex.searchResult, 1)
.wait(selectors.ticketsIndex.searchResultDate)

View File

@ -1,8 +1,7 @@
import selectors from '../../helpers/selectors.js';
import createNightmare from '../../helpers/nightmare';
// #1051 Traducciones que fallan
xdescribe('Ticket services path', () => {
describe('Ticket services path', () => {
const nightmare = createNightmare();
beforeAll(() => {
@ -20,8 +19,7 @@ xdescribe('Ticket services path', () => {
.write(selectors.ticketService.firstQuantityInput, 99)
.clearInput(selectors.ticketService.firstPriceInput)
.write(selectors.ticketService.firstPriceInput, 999)
.autocompleteSearch(selectors.ticketService.firstVatTypeAutocomplete, 'Reduced VAT')
.waitForTextInInput(`${selectors.ticketService.firstVatTypeAutocomplete} Input`, 'Reduced VAT')
.autocompleteSearch(selectors.ticketService.firstVatTypeAutocomplete, 'General VAT')
.waitToClick(selectors.ticketService.saveServiceButton)
.waitForLastSnackbar();
@ -54,12 +52,13 @@ xdescribe('Ticket services path', () => {
const result = await nightmare
.waitToGetProperty(`${selectors.ticketService.firstVatTypeAutocomplete} input`, 'value');
expect(result).toEqual('Reduced VAT');
expect(result).toEqual('General VAT');
});
it('should delete the service', async() => {
const result = await nightmare
.waitToClick(selectors.ticketService.fistDeleteServiceButton)
.waitForNumberOfElements(selectors.ticketService.serviceLine, 0)
.waitToClick(selectors.ticketService.saveServiceButton)
.waitForLastSnackbar();

View File

@ -1,8 +1,7 @@
import selectors from '../../helpers/selectors.js';
import createNightmare from '../../helpers/nightmare';
// #1051 Traducciones que fallan
xdescribe('Ticket create path', () => {
describe('Ticket create path', () => {
const nightmare = createNightmare();
beforeAll(() => {
@ -29,14 +28,13 @@ xdescribe('Ticket create path', () => {
.waitToClick(selectors.createTicketView.createButton)
.waitForLastSnackbar();
expect(result).toEqual(`You can't create a ticket for a inactive client`);
expect(result).toMatch(/You can't create a ticket for a inactive|frozen client/);
});
it('should succeed to create a ticket for a valid client', async() => {
const result = await nightmare
.autocompleteSearch(selectors.createTicketView.clientAutocomplete, 'Tony Stark')
.autocompleteSearch(selectors.createTicketView.addressAutocomplete, 'Tony Stark')
.datePicker(selectors.createTicketView.deliveryDateInput, 1)
.autocompleteSearch(selectors.createTicketView.warehouseAutocomplete, 'Warehouse One')
.autocompleteSearch(selectors.createTicketView.agencyAutocomplete, 'inhouse pickup')
.waitToClick(selectors.createTicketView.createButton)

View File

@ -35,5 +35,6 @@
"A client with that Web User name already exists": "A client with that Web User name already exists",
"The warehouse can't be repeated": "The warehouse can't be repeated",
"Barcode must be unique": "Barcode must be unique",
"You don't have enough privileges to do that": "You don't have enough privileges to do that"
"You don't have enough privileges to do that": "You don't have enough privileges to do that",
"You can't create a ticket for a frozen client": "You can't create a ticket for a frozen client"
}