This commit is contained in:
Juan Ferrer 2019-01-16 15:29:13 +01:00
commit d02dc68c3e
37 changed files with 445 additions and 136 deletions

View File

@ -329,6 +329,36 @@ let actions = {
.catch(() => {
done(new Error(`.autocompleteSearch() for ${autocompleteSelector}, timed out`));
});
},
datePicker: function(datePickerSelector, changeMonth, done) {
this.wait(datePickerSelector)
.mousedown(datePickerSelector)
.wait('div.flatpickr-calendar.open');
if (changeMonth > 0)
this.mousedown('body > div > div.flatpickr-months > span.flatpickr-next-month > svg');
if (changeMonth < 0)
this.mousedown('body > div > div.flatpickr-months > span.flatpickr-prev-month > svg');
const daySelector = 'div.flatpickr-calendar.open span.flatpickr-day:nth-child(16)';
this.wait(selector => {
return document.querySelector(selector);
}, daySelector)
.evaluate(selector => {
let event = new MouseEvent('mousedown', {
bubbles: true,
cancelable: true,
view: window
});
document.querySelector(selector).dispatchEvent(event);
}, daySelector)
.then(done)
.catch(() => {
done(new Error(`.datePicker(), for ${daySelector} timed out`));
});
}
};

View File

@ -34,6 +34,10 @@ export default {
createButton: `${components.vnSubmit}`,
cancelButton: `vn-button[href="#!/client/index"]`
},
clientDescriptor: {
moreMenu: `vn-client-descriptor > vn-card > div vn-icon-menu > div > vn-icon`,
simpleTicketButton: 'vn-client-descriptor vn-popover > div > div.content > div > div.list > ul > li'
},
clientBasicData: {
basicDataButton: `vn-left-menu a[ui-sref="client.card.basicData"]`,
nameInput: `${components.vnTextfield}[name="name"]`,
@ -177,7 +181,7 @@ export default {
closeItemSummaryPreview: 'vn-item-index [vn-id="preview"] button.close'
},
itemCreateView: {
name: `${components.vnTextfield}[name="name"]`,
temporalName: `${components.vnTextfield}[name="provisionalName"]`,
typeAutocomplete: `vn-autocomplete[field="$ctrl.item.typeFk"]`,
intrastatAutocomplete: `vn-autocomplete[field="$ctrl.item.intrastatFk"]`,
originAutocomplete: `vn-autocomplete[field="$ctrl.item.originFk"]`,

View File

@ -1,7 +1,7 @@
import selectors from '../../helpers/selectors.js';
import createNightmare from '../../helpers/nightmare';
xdescribe('Client Edit pay method path', () => {
describe('Client Edit pay method path', () => {
const nightmare = createNightmare();
beforeAll(() => {
@ -74,11 +74,6 @@ xdescribe('Client Edit pay method path', () => {
.waitForSnackbar();
expect(snackbarMessages).toEqual(jasmine.arrayContaining(['Data saved!']));
// #953 update test to capture the relevant message
// .waitForLastSnackbar();
// expect(snackbarMessage).toEqual('Data saved!');
});
it('should confirm the due day have been edited', async() => {

View File

@ -11,7 +11,7 @@ describe('Client Edit web access path', () => {
.accessToSection('client.card.webAccess');
});
it(`should uncheck the Enable web access checkbox and update the name`, async () => {
it(`should uncheck the Enable web access checkbox and update the name`, async() => {
const result = await nightmare
.waitToClick(selectors.clientWebAccess.enableWebAccessCheckbox)
.clearInput(selectors.clientWebAccess.userNameInput)
@ -22,7 +22,7 @@ describe('Client Edit web access path', () => {
expect(result).toEqual('Data saved!');
});
it('should confirm web access is now unchecked', async () => {
it('should confirm web access is now unchecked', async() => {
const result = await nightmare
.waitToClick(selectors.clientBasicData.basicDataButton)
.wait(selectors.clientBasicData.nameInput)
@ -36,7 +36,7 @@ describe('Client Edit web access path', () => {
expect(result).toBeFalsy();
});
it('should confirm web access name have been updated', async () => {
it('should confirm web access name have been updated', async() => {
const result = await nightmare
.waitToGetProperty(selectors.clientWebAccess.userNameInput, 'value');

View File

@ -11,7 +11,7 @@ describe('Client Add notes path', () => {
.accessToSection('client.card.note.index');
});
it(`should click on the add note button`, async () => {
it(`should click on the add note button`, async() => {
const url = await nightmare
.waitToClick(selectors.clientNotes.addNoteFloatButton)
.waitForURL('/note/create')
@ -20,7 +20,7 @@ describe('Client Add notes path', () => {
expect(url.hash).toContain('/note/create');
});
it(`should create a note`, async () => {
it(`should create a note`, async() => {
const result = await nightmare
.type(selectors.clientNotes.noteInput, 'Meeting with Black Widow 21st 9am')
.click(selectors.clientNotes.saveButton)
@ -29,7 +29,7 @@ describe('Client Add notes path', () => {
expect(result).toEqual('Data saved!');
});
it('should confirm the note was created', async () => {
it('should confirm the note was created', async() => {
const result = await nightmare
.waitToGetProperty(selectors.clientNotes.firstNoteText, 'innerText');

View File

@ -11,7 +11,7 @@ describe('Client Add credit path', () => {
.accessToSection('client.card.credit.index');
});
it(`should click on the add credit button`, async () => {
it(`should click on the add credit button`, async() => {
const url = await nightmare
.waitToClick(selectors.clientCredit.addCreditFloatButton)
.waitForURL('/credit/create')
@ -20,7 +20,7 @@ describe('Client Add credit path', () => {
expect(url.hash).toContain('/credit/create');
});
it(`should edit the credit`, async () => {
it(`should edit the credit`, async() => {
const result = await nightmare
.clearInput(selectors.clientCredit.creditInput)
.type(selectors.clientCredit.creditInput, 999)
@ -30,7 +30,7 @@ describe('Client Add credit path', () => {
expect(result).toEqual('Data saved!');
});
it('should confirm the credit was updated', async () => {
it('should confirm the credit was updated', async() => {
const result = await nightmare
.waitToGetProperty(selectors.clientCredit.firstCreditText, 'innerText');

View File

@ -11,7 +11,7 @@ describe('Client mandate path', () => {
.accessToSection('client.card.mandate');
});
it('should confirm the client has a mandate of the CORE type', async () => {
it('should confirm the client has a mandate of the CORE type', async() => {
const result = await nightmare
.waitToGetProperty(selectors.clientMandate.firstMandateText, 'innerText');

View File

@ -12,7 +12,7 @@ describe('Client lock verified data path', () => {
.accessToSection('client.card.fiscalData');
});
it('should confirm verified data button is disabled for salesPerson', async () => {
it('should confirm verified data button is disabled for salesPerson', async() => {
const result = await nightmare
.wait(200)
.wait(selectors.clientFiscalData.verifiedDataCheckboxInput)
@ -23,7 +23,7 @@ describe('Client lock verified data path', () => {
expect(result).toBeTruthy();
});
it('should edit the social name', async () => {
it('should edit the social name', async() => {
const result = await nightmare
.wait(selectors.clientFiscalData.socialNameInput)
.clearInput(selectors.clientFiscalData.socialNameInput)
@ -34,7 +34,7 @@ describe('Client lock verified data path', () => {
expect(result).toEqual('Data saved!');
});
it('should confirm the social name have been edited', async () => {
it('should confirm the social name have been edited', async() => {
const result = await nightmare
.waitToClick(selectors.clientBasicData.basicDataButton)
.wait(selectors.clientBasicData.nameInput)
@ -52,7 +52,7 @@ describe('Client lock verified data path', () => {
.waitForLogin('administrative');
});
it('should navigate to clients index', async () => {
it('should navigate to clients index', async() => {
const url = await nightmare
.waitToClick(selectors.globalItems.applicationsMenuButton)
.wait(selectors.globalItems.applicationsMenuVisible)
@ -63,7 +63,7 @@ describe('Client lock verified data path', () => {
expect(url.hash).toEqual('#!/client/index');
});
it('should search again for the user Petter Parker', async () => {
it('should search again for the user Petter Parker', async() => {
const resultCount = await nightmare
.wait(selectors.clientsIndex.searchClientInput)
.type(selectors.clientsIndex.searchClientInput, 'Petter Parker')
@ -74,7 +74,7 @@ describe('Client lock verified data path', () => {
expect(resultCount).toEqual(1);
});
it(`should click on the search result to access to the Petter Parkers fiscal data`, async () => {
it(`should click on the search result to access to the Petter Parkers fiscal data`, async() => {
const url = await nightmare
.waitForTextInElement(selectors.clientsIndex.searchResult, 'Petter Parker')
.waitToClick(selectors.clientsIndex.searchResult)
@ -85,7 +85,7 @@ describe('Client lock verified data path', () => {
expect(url.hash).toContain('fiscal-data');
});
it(`should click on the fiscal data button`, async () => {
it(`should click on the fiscal data button`, async() => {
const url = await nightmare
.waitToClick(selectors.clientFiscalData.fiscalDataButton)
.waitForURL('fiscal-data')
@ -94,7 +94,7 @@ describe('Client lock verified data path', () => {
expect(url.hash).toContain('fiscal-data');
});
it('should confirm verified data button is enabled for administrative', async () => {
it('should confirm verified data button is enabled for administrative', async() => {
const result = await nightmare
.wait(selectors.clientFiscalData.verifiedDataCheckboxInput)
.evaluate(selector => {
@ -104,7 +104,7 @@ describe('Client lock verified data path', () => {
expect(result).not.toBeTruthy();
});
it('should check the Verified data checkbox', async () => {
it('should check the Verified data checkbox', async() => {
const result = await nightmare
.waitToClick(selectors.clientFiscalData.verifiedDataCheckboxInput)
.waitToClick(selectors.clientFiscalData.saveButton)
@ -113,7 +113,7 @@ describe('Client lock verified data path', () => {
expect(result).toEqual('Data saved!');
});
it('should confirm Verified data checkbox is checked', async () => {
it('should confirm Verified data checkbox is checked', async() => {
const result = await nightmare
.waitToClick(selectors.clientBasicData.basicDataButton)
.wait(selectors.clientBasicData.nameInput)
@ -126,7 +126,7 @@ describe('Client lock verified data path', () => {
expect(result).toBeTruthy();
});
it('should again edit the social name', async () => {
it('should again edit the social name', async() => {
const result = await nightmare
.wait(selectors.clientFiscalData.socialNameInput)
.clearInput(selectors.clientFiscalData.socialNameInput)
@ -137,7 +137,7 @@ describe('Client lock verified data path', () => {
expect(result).toEqual('Data saved!');
});
it('should again confirm the social name have been edited', async () => {
it('should again confirm the social name have been edited', async() => {
const result = await nightmare
.waitToClick(selectors.clientBasicData.basicDataButton)
.wait(selectors.clientBasicData.nameInput)
@ -155,7 +155,7 @@ describe('Client lock verified data path', () => {
.waitForLogin('salesPerson');
});
it('should again click on the Clients button of the top bar menu', async () => {
it('should again click on the Clients button of the top bar menu', async() => {
const url = await nightmare
.waitToClick(selectors.globalItems.applicationsMenuButton)
.wait(selectors.globalItems.applicationsMenuVisible)
@ -166,7 +166,7 @@ describe('Client lock verified data path', () => {
expect(url.hash).toEqual('#!/client/index');
});
it('should again search for the user Petter Parker', async () => {
it('should again search for the user Petter Parker', async() => {
const resultCount = await nightmare
.wait(selectors.clientsIndex.searchClientInput)
.type(selectors.clientsIndex.searchClientInput, 'Petter Parker')
@ -177,7 +177,7 @@ describe('Client lock verified data path', () => {
expect(resultCount).toEqual(1);
});
it(`should click on the search result to access to the client's fiscal data`, async () => {
it(`should click on the search result to access to the client's fiscal data`, async() => {
const url = await nightmare
.waitForTextInElement(selectors.clientsIndex.searchResult, 'Petter Parker')
.waitToClick(selectors.clientsIndex.searchResult)
@ -188,7 +188,7 @@ describe('Client lock verified data path', () => {
expect(url.hash).toContain('fiscal-data');
});
it(`should click on the fiscal data button to start editing`, async () => {
it(`should click on the fiscal data button to start editing`, async() => {
const url = await nightmare
.waitToClick(selectors.clientFiscalData.fiscalDataButton)
.waitForURL('fiscal-data')
@ -197,7 +197,7 @@ describe('Client lock verified data path', () => {
expect(url.hash).toContain('fiscal-data');
});
it('should confirm verified data button is disabled once again for salesPerson', async () => {
it('should confirm verified data button is disabled once again for salesPerson', async() => {
const result = await nightmare
.wait(selectors.clientFiscalData.verifiedDataCheckboxInput)
.evaluate(selector => {
@ -207,7 +207,7 @@ describe('Client lock verified data path', () => {
expect(result).toBe(true);
});
it('should not be able to save change throwing a verified data error', async () => {
it('should not be able to save change throwing a verified data error', async() => {
const result = await nightmare
.wait(selectors.clientFiscalData.socialNameInput)
.clearInput(selectors.clientFiscalData.socialNameInput)
@ -226,7 +226,7 @@ describe('Client lock verified data path', () => {
.waitForLogin('salesAssistant');
});
it('should now navigate to clients index', async () => {
it('should now navigate to clients index', async() => {
const url = await nightmare
.waitToClick(selectors.globalItems.applicationsMenuButton)
.wait(selectors.globalItems.applicationsMenuVisible)
@ -237,7 +237,7 @@ describe('Client lock verified data path', () => {
expect(url.hash).toEqual('#!/client/index');
});
it('should now search again for the user Petter Parker', async () => {
it('should now search again for the user Petter Parker', async() => {
const resultCount = await nightmare
.wait(selectors.clientsIndex.searchClientInput)
.type(selectors.clientsIndex.searchClientInput, 'Petter Parker')
@ -248,7 +248,7 @@ describe('Client lock verified data path', () => {
expect(resultCount).toEqual(1);
});
it(`should click on the search result to access to the Petter Parkers fiscal data`, async () => {
it(`should click on the search result to access to the Petter Parkers fiscal data`, async() => {
const url = await nightmare
.waitForTextInElement(selectors.clientsIndex.searchResult, 'Petter Parker')
.waitToClick(selectors.clientsIndex.searchResult)
@ -259,7 +259,7 @@ describe('Client lock verified data path', () => {
expect(url.hash).toContain('fiscal-data');
});
it(`should click on the fiscal data button`, async () => {
it(`should click on the fiscal data button`, async() => {
const url = await nightmare
.waitToClick(selectors.clientFiscalData.fiscalDataButton)
.waitForURL('fiscal-data')
@ -268,7 +268,7 @@ describe('Client lock verified data path', () => {
expect(url.hash).toContain('fiscal-data');
});
it('should confirm verified data button is enabled for salesAssistant', async () => {
it('should confirm verified data button is enabled for salesAssistant', async() => {
const result = await nightmare
.wait(selectors.clientFiscalData.verifiedDataCheckboxInput)
.evaluate(selector => {
@ -278,7 +278,7 @@ describe('Client lock verified data path', () => {
expect(result).toBeFalsy();
});
it('should now edit the social name', async () => {
it('should now edit the social name', async() => {
const result = await nightmare
.wait(selectors.clientFiscalData.socialNameInput)
.clearInput(selectors.clientFiscalData.socialNameInput)
@ -289,7 +289,7 @@ describe('Client lock verified data path', () => {
expect(result).toEqual('Data saved!');
});
it('should now confirm the social name have been edited once and for all', async () => {
it('should now confirm the social name have been edited once and for all', async() => {
const result = await nightmare
.waitToClick(selectors.clientBasicData.basicDataButton)
.wait(selectors.clientBasicData.nameInput)
@ -307,7 +307,7 @@ describe('Client lock verified data path', () => {
.waitForLogin('salesPerson');
});
it('should now click on the Clients button of the top bar menu', async () => {
it('should now click on the Clients button of the top bar menu', async() => {
const url = await nightmare
.waitToClick(selectors.globalItems.applicationsMenuButton)
.wait(selectors.globalItems.applicationsMenuVisible)
@ -318,7 +318,7 @@ describe('Client lock verified data path', () => {
expect(url.hash).toEqual('#!/client/index');
});
it('should once again search for the user Petter Parker', async () => {
it('should once again search for the user Petter Parker', async() => {
const resultCount = await nightmare
.wait(selectors.clientsIndex.searchClientInput)
.type(selectors.clientsIndex.searchClientInput, 'Petter Parker')
@ -329,7 +329,7 @@ describe('Client lock verified data path', () => {
expect(resultCount).toEqual(1);
});
it(`should click on the search result to access to the client's fiscal data`, async () => {
it(`should click on the search result to access to the client's fiscal data`, async() => {
const url = await nightmare
.waitForTextInElement(selectors.clientsIndex.searchResult, 'Petter Parker')
.waitToClick(selectors.clientsIndex.searchResult)
@ -340,7 +340,7 @@ describe('Client lock verified data path', () => {
expect(url.hash).toContain('fiscal-data');
});
it(`should click on the fiscal data button to start editing`, async () => {
it(`should click on the fiscal data button to start editing`, async() => {
const url = await nightmare
.waitToClick(selectors.clientFiscalData.fiscalDataButton)
.waitForURL('fiscal-data')
@ -349,7 +349,7 @@ describe('Client lock verified data path', () => {
expect(url.hash).toContain('fiscal-data');
});
it('should confirm verified data button is enabled once again', async () => {
it('should confirm verified data button is enabled once again', async() => {
const result = await nightmare
.wait(selectors.clientFiscalData.verifiedDataCheckboxInput)
.evaluate(selector => {
@ -359,7 +359,7 @@ describe('Client lock verified data path', () => {
expect(result).toBe(true);
});
it('should confirm the form is enabled for salesPerson', async () => {
it('should confirm the form is enabled for salesPerson', async() => {
const result = await nightmare
.wait(selectors.clientFiscalData.socialNameInput)
.evaluate(selector => {

View File

@ -11,7 +11,7 @@ describe('Client risk path', () => {
.accessToSection('client.card.risk.index');
});
it('should click the new payment button', async () => {
it('should click the new payment button', async() => {
let url = await nightmare
.waitToClick(selectors.clientRisk.newPaymentButton)
.waitForURL('/risk')
@ -20,7 +20,7 @@ describe('Client risk path', () => {
expect(url.hash).toContain('/risk');
});
it('should create a new payment that clears the debt', async () => {
it('should create a new payment that clears the debt', async() => {
let result = await nightmare
.clearInput(selectors.clientRisk.newPaymentBankInut)
.type(selectors.clientRisk.newPaymentBankInut, '2')
@ -30,14 +30,14 @@ describe('Client risk path', () => {
expect(result).toContain('Data saved!');
});
it('should check balance is now 0', async () => {
it('should check balance is now 0', async() => {
let result = await nightmare
.waitToGetProperty(selectors.clientRisk.firstRiskLineBalance, 'innerText');
expect(result).toEqual('0.00 €');
});
it('should now click the new payment button', async () => {
it('should now click the new payment button', async() => {
let url = await nightmare
.waitToClick(selectors.clientRisk.newPaymentButton)
.waitForURL('/risk')
@ -46,7 +46,7 @@ describe('Client risk path', () => {
expect(url.hash).toContain('/risk');
});
it('should create a new payment that sets the balance to positive value', async () => {
it('should create a new payment that sets the balance to positive value', async() => {
let result = await nightmare
.clearInput(selectors.clientRisk.newPaymentAmountInput)
.type(selectors.clientRisk.newPaymentAmountInput, '100')
@ -56,14 +56,14 @@ describe('Client risk path', () => {
expect(result).toContain('Data saved!');
});
it('should check balance is now 100', async () => {
it('should check balance is now 100', async() => {
let result = await nightmare
.waitToGetProperty(selectors.clientRisk.firstRiskLineBalance, 'innerText');
expect(result).toEqual('100.00 €');
});
it('should again click the new payment button', async () => {
it('should again click the new payment button', async() => {
let url = await nightmare
.waitToClick(selectors.clientRisk.newPaymentButton)
.waitForURL('/risk')
@ -72,7 +72,7 @@ describe('Client risk path', () => {
expect(url.hash).toContain('/risk');
});
it('should create a new payment that sets the balance back to the original negative value', async () => {
it('should create a new payment that sets the balance back to the original negative value', async() => {
let result = await nightmare
.clearInput(selectors.clientRisk.newPaymentAmountInput)
.type(selectors.clientRisk.newPaymentAmountInput, '-150')
@ -82,14 +82,14 @@ describe('Client risk path', () => {
expect(result).toContain('Data saved!');
});
it('should check balance is now -50', async () => {
it('should check balance is now -50', async() => {
let result = await nightmare
.waitToGetProperty(selectors.clientRisk.firstRiskLineBalance, 'innerText');
expect(result).toEqual('-50.00 €');
});
it('should now click on the Clients button of the top bar menu', async () => {
it('should now click on the Clients button of the top bar menu', async() => {
let url = await nightmare
.waitForLogin('employee')
.waitToClick(selectors.globalItems.applicationsMenuButton)
@ -101,7 +101,7 @@ describe('Client risk path', () => {
expect(url.hash).toEqual('#!/client/index');
});
it('should now search for the user Petter Parker', async () => {
it('should now search for the user Petter Parker', async() => {
let resultCount = await nightmare
.wait(selectors.clientsIndex.searchClientInput)
.type(selectors.clientsIndex.searchClientInput, 'Petter Parker')
@ -112,7 +112,7 @@ describe('Client risk path', () => {
expect(resultCount).toEqual(1);
});
it(`should click on the search result to access to the client's risk`, async () => {
it(`should click on the search result to access to the client's risk`, async() => {
let url = await nightmare
.waitForTextInElement(selectors.clientsIndex.searchResult, 'Petter Parker')
.waitToClick(selectors.clientsIndex.searchResult)
@ -123,7 +123,7 @@ describe('Client risk path', () => {
expect(url.hash).toContain('/risk');
});
it('should not be able to click the new payment button as it isnt present', async () => {
it('should not be able to click the new payment button as it isnt present', async() => {
let result = await nightmare
.exists(selectors.clientRisk.newPaymentButton);

View File

@ -49,7 +49,7 @@ describe('Item Create/Clone path', () => {
it('should create the Infinity Gauntlet item', async() => {
const result = await nightmare
.type(selectors.itemCreateView.name, 'Infinity Gauntlet')
.type(selectors.itemCreateView.temporalName, 'Infinity Gauntlet')
.autocompleteSearch(selectors.itemCreateView.typeAutocomplete, 'Crisantemo')
.autocompleteSearch(selectors.itemCreateView.intrastatAutocomplete, 'Coral y materiales similares')
.autocompleteSearch(selectors.itemCreateView.originAutocomplete, 'Holand')

View File

@ -1,7 +1,7 @@
import selectors from '../../helpers/selectors.js';
import createNightmare from '../../helpers/nightmare';
xdescribe('Ticket services path', () => {
describe('Ticket services path', () => {
const nightmare = createNightmare();
beforeAll(() => {
@ -72,9 +72,9 @@ xdescribe('Ticket services path', () => {
.waitToClick(selectors.ticketBasicData.basicDataButton)
.wait(selectors.ticketBasicData.clientAutocomplete)
.click(selectors.ticketService.serviceButton)
.waitForNumberOfElements(selectors.ticketService.serviceLine, 2)
.waitForNumberOfElements(selectors.ticketService.serviceLine, 0)
.countElement(selectors.ticketService.serviceLine);
expect(result).toEqual(2);
expect(result).toEqual(0);
});
});

View File

@ -0,0 +1,54 @@
import selectors from '../../helpers/selectors.js';
import createNightmare from '../../helpers/nightmare';
describe('Ticket create path', () => {
const nightmare = createNightmare();
beforeAll(() => {
nightmare
.loginAndModule('employee', 'ticket');
});
it('should open the new ticket form', async() => {
const url = await nightmare
.waitToClick(selectors.ticketsIndex.newTicketButton)
.wait(selectors.createTicketView.clientAutocomplete)
.parsedUrl();
expect(url.hash).toEqual('#!/ticket/create');
});
it('should atempt to create a ticket for a frozen client but fail', async() => {
const result = await nightmare
.autocompleteSearch(selectors.createTicketView.clientAutocomplete, 'Bruce Banner')
.autocompleteSearch(selectors.createTicketView.addressAutocomplete, 'Bruce Banner')
.datePicker(selectors.createTicketView.deliveryDateInput, 1)
.autocompleteSearch(selectors.createTicketView.warehouseAutocomplete, 'Warehouse One')
.autocompleteSearch(selectors.createTicketView.agencyAutocomplete, 'inhouse pickup')
.waitToClick(selectors.createTicketView.createButton)
.waitForLastSnackbar();
expect(result).toEqual(`You can't create a ticket for a inactive client`);
});
it('should suceed 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)
.waitForLastSnackbar();
expect(result).toEqual('Data saved!');
});
it('should check the url is now the summary of the ticket', async() => {
const url = await nightmare
.waitForURL('/summary')
.parsedUrl();
expect(url.hash).toContain('/summary');
});
});

View File

@ -0,0 +1,34 @@
import selectors from '../../helpers/selectors.js';
import createNightmare from '../../helpers/nightmare';
describe('Ticket create from client path', () => {
const nightmare = createNightmare();
beforeAll(() => {
nightmare
.loginAndModule('employee', 'client')
.accessToSearchResult('Petter Parker');
});
it('should click the create simple ticket on the descriptor menu', async() => {
const url = await nightmare
.waitToClick(selectors.clientDescriptor.moreMenu)
.waitToClick(selectors.clientDescriptor.simpleTicketButton)
.waitForURL('#!/ticket/create?clientFk=102')
.parsedUrl();
expect(url.hash).toContain('clientFk=102');
});
it('should check if the client details are the expected ones', async() => {
const client = await nightmare
.waitToGetProperty(`${selectors.createTicketView.clientAutocomplete} input`, 'value');
const address = await nightmare
.waitToGetProperty(`${selectors.createTicketView.addressAutocomplete} input`, 'value');
expect(client).toContain('Petter Parker');
expect(address).toContain('20 Ingram Street');
});
});

View File

@ -29,24 +29,13 @@ class DatePicker extends Component {
if (this.vp.selectedDates.length) {
let date = this.vp.selectedDates[0];
if (!this.isLocale && !this._iniOptions.enableTime && !this.iniOptions.onlyDate) {
let now = new Date();
date.setTime(date.getTime()
+ now.getHours() * 60 * 60 * 1000
+ now.getUTCMinutes() * 60 * 1000
+ now.getUTCSeconds() * 1000
+ now.getUTCMilliseconds()
);
}
console.log(this.iniOptions);
if (this.iniOptions.onlyDate) {
if (!this.isLocale && !this._iniOptions.enableTime) {
let now = new Date();
let offset = now.getTimezoneOffset() * 60000;
date.setHours(0, 0, 0, 0);
date.setTime(date.getTime() - offset);
}
console.log(date);
this._model = date;
} else
this.model = null;

View File

@ -0,0 +1,39 @@
// #937 front test datePicker awaiting loopback connector refactor to store dates correctly.
xdescribe('Component vnDatePicker', () => {
let controller;
let $attrs;
let $element;
let today = new Date();
today.setHours(0, 0, 0, 0);
beforeEach(ngModule('vnCore'));
beforeEach(angular.mock.inject($componentController => {
$attrs = {};
$translate = {use: () => {
return 'es';
}};
$element = angular.element(`<vn-date-picker><div><input type="text" class="mdl-textfield__input" name="MyName" ng-disabled="$ctrl.disabled" rule=""></input></div></vn-date-picker>`);
controller = $componentController('vnDatePicker', {$element, $attrs, $translate});
}));
describe('onValueUpdate() while date is selected', () => {
it(`should store the selected date in the controller`, () => {
controller.vp = {selectedDates: [today]};
controller.isLocale = true;
controller.onValueUpdate();
expect(controller._model).toEqual(today);
});
it(`should format the date`, () => {
controller.vp = {selectedDates: [today], destroy: () => {}};
controller.isLocale = undefined;
controller._iniOptions.enableTime = undefined;
controller.onValueUpdate();
expect(controller._model).toEqual(today);
});
});
});

View File

@ -1,10 +1,6 @@
@import "colors";
vn-fetched-tags {
&.noTitle vn-one {
display: none !important;
}
@media screen and (max-width: 1600px){
& vn-horizontal {
flex-direction: column;
@ -26,7 +22,7 @@ vn-fetched-tags {
}
}
@media screen and (max-width: 1200px) {
@media screen and (max-width: 1200px){
& vn-horizontal {
.inline-tag {
font-size: 0.6em;
@ -35,15 +31,8 @@ vn-fetched-tags {
}
}
& vn-horizontal {
flex-direction: column;
text-align: center;
}
& vn-one {
white-space: nowrap;
padding-top: 0.2em
}
& vn-two {
@ -51,19 +40,19 @@ vn-fetched-tags {
}
& .inline-tag {
background-color: $secondary-font-color;
background-color: $color-white;
display: inline-block;
float: none;
color: $color-white;
color: $secondary-font-color;
margin-right: 0.4em;
text-align: center;
font-size: 0.8em;
height: 1.25em;
padding: 0.4em;
width: 5em
width: 5em;
border: 1px solid $secondary-font-color;
}
& .inline-tag.empty {
background-color: $main-bg
border: 1px solid $main-bg
}
}

View File

@ -61,7 +61,7 @@ module.exports = Self => {
], transaction);
}
Self.importToNewRefundTicket = async (ctx, id) => {
Self.importToNewRefundTicket = async(ctx, id) => {
let models = Self.app.models;
let token = ctx.req.accessToken;
let userId = token.userId;

View File

@ -43,7 +43,7 @@
</vn-td>
<vn-td>{{::claim.created | date:'dd/MM/yyyy'}}</vn-td>
<vn-td>{{::claim.worker.firstName}} {{::claim.worker.name}}</vn-td>
<vn-td>{{::claim.claimState.description}}</vn-td>
<vn-td class="{{::claim.claimState.description}}">{{::claim.claimState.description}}</vn-td>
<vn-td>
<vn-icon-button
ng-click="$ctrl.preview($event, claim)"

View File

@ -1,4 +1,5 @@
import ngModule from '../module';
import './style.scss';
export default class Controller {
constructor($scope) {

View File

@ -0,0 +1,19 @@
@import 'colors';
vn-claim-index {
.Pendiente {
background-color: $main-01-05;
}
.Gestionado {
background-color: $main-03-05;
}
.Anulado, .Cuestionado {
background-color: white;
}
.Resuelto {
background-color: $main-02-05;
}
}

View File

@ -56,7 +56,7 @@
<vn-autocomplete vn-one
initial-data="$ctrl.address.agencyMode"
field="$ctrl.address.agencyModeFk"
url="/client/api/AgencyMode/isActive"
url="/client/api/AgencyModes/isActive"
show-field="name"
value-field="id"
label="Agency">

View File

@ -30,9 +30,13 @@ class Controller {
}
getInstance(instance) {
let validDate = /^(-?(?:[1-9][0-9]*)?[0-9]{4})-(1[0-2]|0[1-9])-(3[01]|0[1-9]|[12][0-9])T(2[0-3]|[01][0-9]):([0-5][0-9]):([0-5][0-9])(.[0-9]+)?(Z)?$/;
const properties = [];
if (typeof instance == 'object' && instance != null) {
Object.keys(instance).forEach(property => {
if (validDate.test(instance[property]))
instance[property] = new Date(instance[property]).toLocaleString('es-ES');
properties.push({key: property, value: instance[property]});
});
return properties;

View File

@ -0,0 +1,71 @@
let UserError = require('vn-loopback/util/user-error');
module.exports = Self => {
Self.remoteMethod('new', {
description: 'Create a new item and returns the new ID',
accessType: 'WRITE',
accepts: [{
arg: 'params',
type: 'object',
http: {source: 'body'}
}],
returns: {
type: 'number',
root: true
},
http: {
path: `/new`,
verb: 'post'
}
});
Self.new = async params => {
let validUpdateParams = [
'provisionalName',
'typeFk',
'intrastatFk',
'originFk',
'relevancy'
];
for (const key in params) {
if (validUpdateParams.indexOf(key) === -1)
throw new UserError(`You don't have enough privileges to do that`);
}
let transaction = await Self.beginTransaction({});
try {
let provisionalName = params.provisionalName;
delete params.provisionalName;
let item = await Self.app.models.Item.create(params, {transaction: transaction});
let typeTags = await Self.app.models.ItemTypeTag.find({where: {itemTypeFk: item.typeFk}});
let query = `SET @isTriggerDisabled = TRUE`;
await Self.rawSql(query, null, {transaction: transaction});
let nameTag = await Self.app.models.Tag.findOne({where: {name: 'Nombre temporal'}});
let newTags = [];
newTags.push({itemFk: item.id, tagFk: nameTag.id, value: provisionalName, priority: '2'});
typeTags.forEach(typeTag => {
newTags.push({itemFk: item.id, tagFk: typeTag.tagFk, value: '', priority: typeTag.priority});
});
await Self.app.models.ItemTag.create(newTags, {transaction: transaction});
query = `SET @isTriggerDisabled = FALSE`;
await Self.rawSql(query, null, {transaction: transaction});
query = `CALL vn.itemRefreshTags(?)`;
await Self.rawSql(query, [item.id], {transaction: transaction});
await transaction.commit();
return item;
} catch (e) {
await transaction.rollback();
throw e;
}
};
};

View File

@ -0,0 +1,35 @@
const app = require(`${serviceRoot}/server/server`);
describe('item new()', () => {
let item;
afterAll(async() => {
await app.models.Item.destroyById(item.id);
});
it('should create a new item, adding the name as a tag', async() => {
let itemParams = {
intrastatFk: 5080000,
originFk: 1,
provisionalName: 'planta',
typeFk: 2,
relevancy: 0
};
item = await app.models.Item.new(itemParams);
let temporalNameTag = await app.models.Tag.findOne({where: {name: 'Nombre temporal'}});
let temporalName = await app.models.ItemTag.findOne({
where: {
itemFk: item.id,
tagFk: temporalNameTag.id,
}
});
item = await app.models.Item.findById(item.id);
expect(item.intrastatFk).toEqual(5080000);
expect(item.originFk).toEqual(1);
expect(item.typeFk).toEqual(2);
expect(item.name).toEqual('planta');
expect(temporalName.value).toEqual('planta');
});
});

View File

@ -13,8 +13,7 @@
"description": "Identifier"
},
"value": {
"type": "String",
"required": true
"type": "String"
},
"priority": {
"type": "Number",

View File

@ -9,8 +9,8 @@ module.exports = Self => {
require('../methods/item/getSummary')(Self);
require('../methods/item/getCard')(Self);
require('../methods/item/regularize')(Self);
require('../methods/item/new')(Self);
Self.validatesPresenceOf('name', {message: 'Cannot be blank'});
Self.validatesPresenceOf('originFk', {message: 'Cannot be blank'});
Self.observe('before save', async function(ctx) {

View File

@ -13,8 +13,7 @@
"description": "Identifier"
},
"name": {
"type": "String",
"required": true
"type": "String"
},
"size": {
"type": "Number"
@ -22,6 +21,10 @@
"category": {
"type": "String"
},
"typeFk": {
"type": "Number",
"required": true
},
"stems": {
"type": "Number"
},

View File

@ -1,4 +1,4 @@
<mg-ajax path="/item/api/Items" options="vnPost"></mg-ajax>
<mg-ajax path="/item/api/Items/new" options="vnPost"></mg-ajax>
<vn-watcher
vn-id="watcher"
data="$ctrl.item"
@ -10,7 +10,12 @@
<vn-card pad-large>
<vn-title>New item</vn-title>
<vn-horizontal>
<vn-textfield vn-one label="Name" field="$ctrl.item.name" vn-focus></vn-textfield>
<vn-textfield
vn-one
label="Temporal name"
field="$ctrl.item.provisionalName"
vn-focus>
</vn-textfield>
</vn-horizontal>
<vn-horizontal>
<vn-autocomplete vn-one

View File

@ -44,12 +44,12 @@ module.exports = Self => {
let clientFk = address.clientFk;
let agency;
if (params.agency)
if (params.agencyModeFk)
agency = await Self.app.models.AgencyMode.findById(params.agencyModeFk);
else
agency = {code: null};
if (agency.code != 'refund') {
if (agency.name != 'ABONO') {
let query = `SELECT vn.clientGetDebt(?, CURDATE()) AS debt`;
let clientDebt = await Self.rawSql(query, [clientFk]);

View File

@ -120,8 +120,22 @@ module.exports = Self => {
ticketFk: ticketFk
},
include: [
{relation: 'requester'},
{relation: 'atender'}
{
relation: 'requester',
scope: {
include: {
relation: 'user'
}
}
},
{
relation: 'atender',
scope: {
include: {
relation: 'user'
}
}
}
]
};
return await Self.app.models.TicketRequest.find(filter);

View File

@ -12,6 +12,10 @@
"id": true,
"description": "Identifier"
},
"ticketFk": {
"type": "Number",
"required": true
},
"description": {
"type": "String",
"required": true

View File

@ -27,7 +27,6 @@
ini-options="{enableTime: false}">
</vn-date-picker>
<vn-autocomplete
vn-one
disabled="!$ctrl.clientFk || !$ctrl.landed"
field="$ctrl.warehouseFk"
url="/agency/api/Warehouses"

View File

@ -31,8 +31,13 @@ class Controller {
getInstance(instance) {
const properties = [];
let validDate = /^(-?(?:[1-9][0-9]*)?[0-9]{4})-(1[0-2]|0[1-9])-(3[01]|0[1-9]|[12][0-9])T(2[0-3]|[01][0-9]):([0-5][0-9]):([0-5][0-9])(.[0-9]+)?(Z)?$/;
if (typeof instance == 'object' && instance != null) {
Object.keys(instance).forEach(property => {
if (validDate.test(instance[property]))
instance[property] = new Date(instance[property]).toLocaleString('es-ES');
properties.push({key: property, value: instance[property]});
});
return properties;

View File

@ -231,6 +231,7 @@
{"state": "ticket.card.observation", "icon": "insert_drive_file"},
{"state": "ticket.card.volume", "icon": "icon-volume"},
{"state": "ticket.card.expedition", "icon": "icon-package"},
{"state": "ticket.card.service", "icon": "icon-services"},
{"state": "ticket.card.package.index", "icon": "icon-bucket"},
{"state": "ticket.card.tracking.index", "icon": "remove_red_eye"},
{"state": "ticket.card.saleChecked", "icon": "assignment"},

View File

@ -44,7 +44,7 @@
vn-one
label="Agency"
field="filter.agencyModeFk"
url="/api/AgencyMode/isActive">
url="/api/AgencyModes/isActive">
</vn-autocomplete>
<vn-autocomplete
vn-one

View File

@ -161,7 +161,6 @@
<vn-table model="model">
<vn-thead>
<vn-tr>
<vn-th number>Id</vn-th>
<vn-th>Description</vn-th>
<vn-th number>Created</vn-th>
<vn-th>Requester</vn-th>
@ -174,17 +173,16 @@
</vn-thead>
<vn-tbody>
<vn-tr ng-repeat="request in $ctrl.summary.requests">
<vn-td number>{{::request.id}}</vn-td>
<vn-td>{{::request.description}}</vn-td>
<vn-td number>{{::request.created | dateTime: 'dd/MM/yyyy'}}</vn-td>
<vn-td>{{::request.requester.firstName}} {{::request.requester.name}}</vn-td>
<vn-td>{{::request.atender.firstName}} {{::request.atender.name}}</vn-td>
<vn-td>{{::request.requester.user.name}}</vn-td>
<vn-td>{{::request.atender.user.name}}</vn-td>
<vn-td number>{{::request.quantity}}</vn-td>
<vn-td number>{{::request.price}}</vn-td>
<vn-td number>
<span
ng-show="::request.saleFk"
ng-click="$ctrl.showDescriptor($event, request.sale)"
ng-click="$ctrl.showDescriptor($event, request.saleFk)"
pointer class="link">
{{("000000"+request.saleFk).slice(-6)}}
</span>

View File

@ -81,7 +81,7 @@ INSERT INTO `vn`.`agency`(`id`, `name`, `warehouseFk`, `isVolumetric`, `bankFk`,
(6, 'Walking' , 1, 0, 1, 1),
(7, 'Silla247' , 1, 0, 1, 1),
(8, 'Silla247Expensive' , 1, 0, 1, 1),
(9, 'Abono' , 1, 0, 1, 1),
(9, 'ABONO' , 1, 0, 1, 1),
(10, 'OTRA AGENCIA' , 1, 0, 1, 1);
UPDATE `vn`.`agencyMode` SET `id` = 1 WHERE `name` = 'inhouse pickup';
@ -92,7 +92,7 @@ UPDATE `vn`.`agencyMode` SET `id` = 5 WHERE `name` = 'Quantum break device';
UPDATE `vn`.`agencyMode` SET `id` = 6 WHERE `name` = 'Walking';
UPDATE `vn`.`agencyMode` SET `id` = 7 WHERE `name` = 'Silla247';
UPDATE `vn`.`agencyMode` SET `id` = 8 WHERE `name` = 'Silla247Expensive';
UPDATE `vn`.`agencyMode` SET `id` = 23 WHERE `name` = 'Abono';
UPDATE `vn`.`agencyMode` SET `id` = 23 WHERE `name` = 'ABONO';
UPDATE `vn`.`agencyMode` SET `id` = 10 WHERE `name` = 'OTRA AGENCIA';
UPDATE `vn`.`agencyMode` SET `deliveryMethodFk` = 1 WHERE `id` = 1;
@ -320,7 +320,8 @@ INSERT INTO `vn2008`.`empresa_grupo`(`empresa_grupo_id`, `grupo`)
INSERT INTO `vn`.`bankEntity`(`id`, `countryFk`, `name`, `bic`)
VALUES
( 128, 1, 'The Best Bank', 'BBKKESMMMMMM');
( 128, 1, 'The Best Bank', 'BBKKESMMMMMM'),
( 2100, 1, 'Caixa Bank', 'CAIXESBB');
INSERT INTO `vn`.`supplierAccount`(`id`, `supplierFk`, `iban`, `bankEntityFk`)
VALUES
@ -363,7 +364,7 @@ INSERT INTO `vn`.`invoiceOut`(`id`,`ref`, `serial`, `amount`, `issued`,`clientFk
(17, 4, 4, 4, CURDATE() , CURDATE() , 106, 'address 26', 126, NULL, 0, CURDATE() ),
(18, 4, 4, 4, CURDATE() , CURDATE() , 107, 'address 27', 127, NULL, 0, CURDATE() ),
(19, 5, 5, 4, CURDATE() , CURDATE() , 108, 'address 28', 128, NULL, 0, CURDATE() ),
(20, 5, 5, 4, CURDATE() , CURDATE() , 109, 'address 19', 119, NULL, 0, CURDATE() ),
(20, 5, 5, 4, CURDATE() , CURDATE() , 108, 'address 28', 128, NULL, 0, CURDATE() ),
(21, 5, 5, 4, CURDATE() , CURDATE() , 110, 'address 29', 129, NULL, 1, CURDATE() );
INSERT INTO `vn`.`ticketObservation`(`id`, `ticketFk`, `observationTypeFk`, `description`)
@ -396,6 +397,10 @@ INSERT INTO `vn`.`ticketTracking`(`id`, `ticketFk`, `stateFk`, `workerFk`, `crea
(20, 20, 15, 19, CURDATE()),
(21, 21, 3 , 19, CURDATE());
INSERT INTO `vn`.`stowaway`(`id`, `shipFk`, `created`)
VALUES
(19, 20, CURDATE());
INSERT INTO `vn`.`vehicle`(`id`, `numberPlate`, `tradeMark`, `model`, `companyFk`, `warehouseFk`, `description`, `m3`, `isActive`)
VALUES
(1, '3333-BAT', 'WAYNE INDUSTRIES', 'BATMOBILE', 442, 1, 'The ultimate war machine', 50, 1),
@ -535,16 +540,18 @@ INSERT INTO `vn`.`sale`(`id`, `itemFk`, `ticketFk`, `concept`, `quantity`, `pric
(1, 1, 1 , 'Object1 Gem1 5', 5, 9.10, 0, 0, 0, DATE_ADD(CURDATE(), INTERVAL -15 DAY)),
(2, 2, 1 , 'Object2 Gem2 3', 10, 1.07, 0, 0, 0, DATE_ADD(CURDATE(), INTERVAL -15 DAY)),
(3, 1, 1 , 'Object1 Gem1 5', 2, 9.10, 0, 0, 0, DATE_ADD(CURDATE(), INTERVAL -15 DAY)),
(4, 4, 1 , 'Object4 Armor2 2' , 20, 3.06, 0, 0, 0, DATE_ADD(CURDATE(), INTERVAL -15 DAY)),
(4, 4, 1 , 'Object4 Armor2 2', 20, 3.06, 0, 0, 0, DATE_ADD(CURDATE(), INTERVAL -15 DAY)),
(5, 1, 2 , 'Object1 Gem1 5', 10, 9.10, 0, 0, 0, DATE_ADD(CURDATE(), INTERVAL -10 DAY)),
(6, 1, 3 , 'Object1 Gem1 5', 15, 6.50, 0, 0, 0, DATE_ADD(CURDATE(), INTERVAL -5 DAY)),
(7, 2, 11, 'Object2 Gem2 3', 15, 1.30, 0, 0, 0, CURDATE()),
(8, 4, 11, 'Object4 Armor2 2' , 10, 3.26, 0, 0, 0, CURDATE()),
(8, 4, 11, 'Object4 Armor2 2', 10, 3.26, 0, 0, 0, CURDATE()),
(9, 1, 16, 'Object1 Gem1 5', 5, 9.10, 0, 0, 0, CURDATE()),
(10, 2, 16, 'Object2 Gem2 3', 10, 1.07, 0, 0, 0, CURDATE()),
(11, 1, 16, 'Object1 Gem1 5', 2, 9.10, 0, 0, 0, CURDATE()),
(12, 4, 16, 'Object4 Armor2 2' , 20, 3.06, 0, 0, 0, CURDATE()),
(13, 2, 8, 'Object2 Gem2 3', 15, 1.30, 0, 0, 0, CURDATE());
(12, 4, 16, 'Object4 Armor2 2', 20, 3.06, 0, 0, 0, CURDATE()),
(13, 2, 8, 'Object2 Gem2 3', 15, 1.30, 0, 0, 0, CURDATE()),
(14, 1, 19, 'Object1 Gem1 5', 10, 1.50, 0, 0, 0, CURDATE()),
(15, 2, 20, 'Object2 Gem2 3', 15, 1.30, 0, 0, 0, CURDATE());
INSERT INTO `vn`.`saleChecked`(`saleFk`, `isChecked`)
VALUES
@ -614,7 +621,17 @@ INSERT INTO `vn`.`saleComponent`(`saleFk`, `componentFk`, `value`)
(13, 15, 0.29),
(13, 28, 5.6),
(13, 29, -4.6),
(13, 39, 0.01);
(13, 39, 0.01),
(14, 15, 0.58),
(14, 23, 6.5),
(14, 28, 20.72),
(14, 29, -18.72),
(14, 39, 0.02),
(15, 15, 0.058),
(15, 21, 0.002),
(15, 28, 5.6),
(15, 29, -4.6),
(15, 39, 0.01);
INSERT INTO `vn`.`saleTracking`(`saleFk`, `isChecked`, `created`, `originalQuantity`, `workerFk`, `actionFk`, `id`, `stateFk`)
VALUES
@ -949,8 +966,8 @@ INSERT INTO `vn`.`claim`(`id`, `ticketCreated`, `claimStateFk`, `observation`, `
( 1, CURDATE(), 1, 'observation one', 101, 18, 1, 0, CURDATE()),
( 2, CURDATE(), 2, 'observation two', 101, 18, 2, 0, CURDATE()),
( 3, DATE_ADD(CURDATE(), INTERVAL -5 DAY), 3, 'observation three', 101, 18, 3, 0, CURDATE()),
( 4, CURDATE(), 3, 'observation four', 101, 18, 1, 0, CURDATE()),
( 5, DATE_ADD(CURDATE(), INTERVAL -5 DAY), 3, 'observation five', 101, 18, 3, 0, CURDATE());
( 4, CURDATE(), 3, 'observation four', 104, 18, 1, 0, CURDATE()),
( 5, DATE_ADD(CURDATE(), INTERVAL -5 DAY), 3, 'observation five', 104, 18, 3, 0, CURDATE());
INSERT INTO `vn`.`claimBeginning`(`id`, `claimFk`, `saleFk`, `quantity`)
VALUES