Merge branch 'dev' of https://gitea.verdnatura.es/verdnatura/salix into 2500-display_dates
gitea/salix/pipeline/head This commit looks good Details

This commit is contained in:
Carlos Jimenez Ruiz 2020-11-11 14:45:22 +01:00
commit 6cd1332a18
88 changed files with 1061 additions and 842 deletions

View File

@ -2,24 +2,18 @@ const app = require('vn-loopback/server/server');
describe('campaign latest()', () => {
it('should return the campaigns from the last year', async() => {
let result = await app.models.Campaign.latest();
const lastYearDate = new Date();
lastYearDate.setFullYear(lastYearDate.getFullYear() - 1);
const lastYear = lastYearDate.getFullYear();
const now = new Date();
const result = await app.models.Campaign.latest();
const randomIndex = Math.floor(Math.random() * result.length);
const campaignDated = result[randomIndex].dated;
const campaignYear = campaignDated.getFullYear();
expect(result.length).toEqual(3);
expect(campaignYear).toEqual(lastYear);
expect(campaignDated).toBeLessThanOrEqual(now);
});
it('should return the campaigns from the current year', async() => {
const currentDate = new Date();
const currentYear = currentDate.getFullYear();
const now = new Date();
const currentYear = now.getFullYear();
const result = await app.models.Campaign.latest({
where: {dated: {like: `%${currentYear}%`}}
});

View File

@ -247,7 +247,7 @@ let actions = {
write: async function(selector, text) {
let builtSelector = await this.selectorFormater(selector);
await this.waitForSelector(selector, {});
await this.waitForSelector(selector);
await this.type(builtSelector, text);
await this.waitForTextInField(selector, text);
},
@ -340,6 +340,31 @@ let actions = {
});
},
waitForTextInField: async function(selector, text) {
let builtSelector = await this.selectorFormater(selector);
await this.waitForSelector(builtSelector);
const expectedText = text.toLowerCase();
return new Promise((resolve, reject) => {
let attempts = 0;
const interval = setInterval(async() => {
const currentText = await this.evaluate(selector => {
return document.querySelector(selector).value.toLowerCase();
}, builtSelector);
if (currentText === expectedText || attempts === 40) {
clearInterval(interval);
resolve(currentText);
}
attempts += 1;
}, 100);
}).then(result => {
if (result === '')
return expect(result).toEqual(expectedText);
return expect(result).toContain(expectedText);
});
},
selectorFormater: function(selector) {
if (selector.includes('vn-textarea'))
return `${selector} textarea`;
@ -350,14 +375,6 @@ let actions = {
return `${selector} input`;
},
waitForTextInField: async function(selector, text) {
let builtSelector = await this.selectorFormater(selector);
await this.waitForSelector(builtSelector);
return await this.waitForFunction((selector, text) => {
return document.querySelector(selector).value.toLowerCase().includes(text.toLowerCase());
}, {}, builtSelector, text);
},
waitForInnerText: async function(selector) {
await this.waitForSelector(selector, {});
await this.waitForFunction(selector => {

View File

@ -413,7 +413,7 @@ export default {
stateLabelValue: 'vn-ticket-descriptor vn-label-value[label="State"]',
isDeletedIcon: 'vn-ticket-descriptor vn-icon[icon="icon-deletedTicket"]',
goBackToModuleIndexButton: 'vn-ticket-descriptor a[ui-sref="ticket.index"]',
moreMenu: 'vn-ticket-descriptor vn-icon-button[icon=more_vert]',
moreMenu: 'vn-ticket-descriptor vn-ticket-descriptor-menu > vn-icon-button[icon=more_vert]',
moreMenuAddStowaway: '.vn-menu [name="addStowaway"]',
moreMenuDeleteStowawayButton: '.vn-menu [name="deleteStowaway"]',
moreMenuAddToTurn: '.vn-menu [name="addTurn"]',
@ -482,7 +482,7 @@ export default {
firstSaleCheckbox: 'vn-ticket-sale vn-tr:nth-child(1) vn-check[ng-model="sale.checked"]',
secondSaleText: 'vn-table div > vn-tbody > vn-tr:nth-child(2)',
secondSaleId: 'vn-ticket-sale:nth-child(2) vn-td-editable:nth-child(4) text > span',
secondSaleIdAutocomplete: 'vn-ticket-sale vn-table vn-tbody > vn-tr:nth-child(2) > vn-td:nth-child(4) > vn-autocomplete',
secondSaleIdAutocomplete: 'vn-ticket-sale vn-tr:nth-child(2) vn-autocomplete[ng-model="sale.itemFk"]',
secondSaleQuantity: 'vn-ticket-sale vn-table vn-tr:nth-child(2) vn-input-number',
secondSaleQuantityCell: 'vn-ticket-sale > div > vn-card > vn-table > div > vn-tbody > vn-tr:nth-child(2) > vn-td-editable:nth-child(5)',
secondSaleConceptCell: 'vn-ticket-sale vn-tbody > :nth-child(2) > :nth-child(6)',

View File

@ -19,7 +19,7 @@ describe('Login path', async() => {
const message = await page.waitForSnackbar();
const state = await page.getState();
expect(message.text).toBe('Invalid login, remember that distinction is made between uppercase and lowercase');
expect(message.text).toContain('Invalid login, remember that distinction is made between uppercase and lowercase');
expect(state).toBe('login');
});
@ -28,7 +28,7 @@ describe('Login path', async() => {
const message = await page.waitForSnackbar();
const state = await page.getState();
expect(message.text).toBe('Invalid login, remember that distinction is made between uppercase and lowercase');
expect(message.text).toContain('Invalid login, remember that distinction is made between uppercase and lowercase');
expect(state).toBe('login');
});
@ -37,7 +37,7 @@ describe('Login path', async() => {
const message = await page.waitForSnackbar();
const state = await page.getState();
expect(message.text).toBe('Please enter your username');
expect(message.text).toContain('Please enter your username');
expect(state).toBe('login');
});
});

View File

@ -31,7 +31,7 @@ describe('Client create path', () => {
await page.waitToClick(selectors.createClientView.createButton);
const message = await page.waitForSnackbar();
expect(message.text).toBe('Some fields are invalid');
expect(message.text).toContain('Some fields are invalid');
});
it('should receive an error when clicking the create button having name and Business name fields empty', async() => {
@ -42,7 +42,7 @@ describe('Client create path', () => {
await page.waitToClick(selectors.createClientView.createButton);
const message = await page.waitForSnackbar();
expect(message.text).toBe('Some fields are invalid');
expect(message.text).toContain('Some fields are invalid');
});
it(`should create a new province`, async() => {
@ -53,7 +53,7 @@ describe('Client create path', () => {
await page.waitToClick(selectors.createClientView.saveNewProvicenButton);
const message = await page.waitForSnackbar();
expect(message.text).toBe('The province has been created');
expect(message.text).toContain('The province has been created');
});
it(`should create a new city`, async() => {
@ -63,7 +63,7 @@ describe('Client create path', () => {
await page.waitToClick(selectors.createClientView.saveNewCityButton);
const message = await page.waitForSnackbar();
expect(message.text).toBe('The city has been created');
expect(message.text).toContain('The city has been created');
});
it(`should create a new post code`, async() => {
@ -72,7 +72,7 @@ describe('Client create path', () => {
const message = await page.waitForSnackbar();
expect(message.text).toBe('The postcode has been created. You can save the data now');
expect(message.text).toContain('The postcode has been created. You can save the data now');
});
it(`should attempt to create a new user with all it's data but wrong email`, async() => {
@ -84,7 +84,7 @@ describe('Client create path', () => {
await page.waitToClick(selectors.createClientView.createButton);
const message = await page.waitForSnackbar();
expect(message.text).toBe('Some fields are invalid');
expect(message.text).toContain('Some fields are invalid');
});
it(`should attempt to create a new user with all it's data but wrong postal code`, async() => {
@ -95,7 +95,7 @@ describe('Client create path', () => {
await page.waitToClick(selectors.createClientView.createButton);
const message = await page.waitForSnackbar();
expect(message.text).toBe(`The postcode doesn't exist. Please enter a correct one`);
expect(message.text).toContain(`The postcode doesn't exist. Please enter a correct one`);
});
it(`should check for autocompleted city, province and country`, async() => {
@ -119,7 +119,7 @@ describe('Client create path', () => {
await page.waitToClick(selectors.createClientView.createButton);
const message = await page.waitForSnackbar();
expect(message.text).toBe('Data saved!');
expect(message.text).toContain('Data saved!');
});
it('should click on the Clients button of the top bar menu', async() => {

View File

@ -37,7 +37,7 @@ describe('Client Edit basicData path', () => {
await page.waitToClick(selectors.clientBasicData.saveButton);
const message = await page.waitForSnackbar();
expect(message.text).toBe('Data saved!');
expect(message.text).toContain('Data saved!');
});
it('should confirm the name have been edited', async() => {
@ -101,7 +101,7 @@ describe('Client Edit basicData path', () => {
await page.waitToClick(selectors.clientBasicData.saveButton);
const message = await page.waitForSnackbar();
expect(message.text).toBe('Data saved!');
expect(message.text).toContain('Data saved!');
});
it('should now confirm the name have been edited', async() => {

View File

@ -83,7 +83,7 @@ describe('Client Edit fiscalData path', () => {
await page.waitToClick(selectors.globalItems.acceptButton);
const message = await page.waitForSnackbar();
expect(message.text).toBe('Invalid Tax number');
expect(message.text).toContain('Invalid Tax number');
});
it(`should edit the fiscal this time with a valid fiscal id`, async() => {
@ -93,14 +93,14 @@ describe('Client Edit fiscalData path', () => {
await page.waitToClick(selectors.globalItems.acceptButton);
const message = await page.waitForSnackbar();
expect(message.text).toBe('Data saved!');
expect(message.text).toContain('Data saved!');
});
it('should propagate the Equalization tax', async() => {
await page.waitToClick(selectors.globalItems.acceptButton);
const message = await page.waitForSnackbar();
expect(message.text).toBe('Equivalent tax spreaded');
expect(message.text).toContain('Equivalent tax spreaded');
});
it('should receive an error if the fiscal id contains A or B at the beginning', async() => {
@ -110,7 +110,7 @@ describe('Client Edit fiscalData path', () => {
await page.waitToClick(selectors.clientFiscalData.saveButton);
const message = await page.waitForSnackbar();
expect(message.text).toBe('Cannot check Equalization Tax in this NIF/CIF');
expect(message.text).toContain('Cannot check Equalization Tax in this NIF/CIF');
});
it('should finally edit the fixcal data correctly as VIES isnt checked and fiscal id is valid for EQtax', async() => {
@ -119,7 +119,7 @@ describe('Client Edit fiscalData path', () => {
await page.waitToClick(selectors.clientFiscalData.saveButton);
const message = await page.waitForSnackbar();
expect(message.text).toBe('Data saved!');
expect(message.text).toContain('Data saved!');
});
// confirm all addresses have now EQtax checked step 1
@ -155,7 +155,7 @@ describe('Client Edit fiscalData path', () => {
await page.waitToClick(selectors.clientFiscalData.saveButton);
const message = await page.waitForSnackbar();
expect(message.text).toBe('Data saved!');
expect(message.text).toContain('Data saved!');
});
it('should propagate the Equalization tax changes', async() => {
@ -163,7 +163,7 @@ describe('Client Edit fiscalData path', () => {
await page.waitToClick(selectors.globalItems.acceptButton);
const message = await page.waitForSnackbar();
expect(message.text).toBe('Equivalent tax spreaded');
expect(message.text).toContain('Equivalent tax spreaded');
});
it('should confirm its name have been edited', async() => {
@ -289,7 +289,7 @@ describe('Client Edit fiscalData path', () => {
await page.waitToClick(selectors.clientAddresses.saveButton);
const message = await page.waitForSnackbar();
expect(message.text).toBe('Data saved!');
expect(message.text).toContain('Data saved!');
});
// confirm invoice by address checkbox gets checked if the EQtax differs between addresses step 3

View File

@ -28,7 +28,7 @@ describe('Client Edit billing data path', () => {
await page.waitToClick(selectors.clientBillingData.saveButton);
const message = await page.waitForSnackbar();
expect(message.text).toBe('That payment method requires an IBAN');
expect(message.text).toContain('That payment method requires an IBAN');
});
// 2256: Windows (hidden mode): Entity code doesn't get the focus, '9999' is written in entity name.
@ -65,7 +65,7 @@ describe('Client Edit billing data path', () => {
await page.waitToClick(selectors.clientBillingData.saveButton);
const message = await page.waitForSnackbar();
expect(message.text).toBe('Notification sent!');
expect(message.text).toContain('Notification sent!');
});
it('should confirm the due day have been edited', async() => {

View File

@ -31,7 +31,7 @@ describe('Client Add address path', () => {
await page.waitToClick(selectors.clientFiscalData.saveButton);
const message = await page.waitForSnackbar();
expect(message.text).toBe('Some fields are invalid');
expect(message.text).toContain('Some fields are invalid');
});
it('should confirm that the city and province are propertly filled', async() => {
@ -51,7 +51,7 @@ describe('Client Add address path', () => {
await page.waitToClick(selectors.clientAddresses.saveButton);
const message = await page.waitForSnackbar();
expect(message.text).toBe('Incoterms is required for a non UEE member');
expect(message.text).toContain('Incoterms is required for a non UEE member');
});
it(`should receive an error after clicking save button as customsAgent is empty`, async() => {
@ -59,7 +59,7 @@ describe('Client Add address path', () => {
await page.waitToClick(selectors.clientAddresses.saveButton);
const message = await page.waitForSnackbar();
expect(message.text).toBe('Customs agent is required for a non UEE member');
expect(message.text).toContain('Customs agent is required for a non UEE member');
});
it(`should create a new custom agent and then save the address`, async() => {
@ -73,7 +73,7 @@ describe('Client Add address path', () => {
await page.waitToClick(selectors.clientAddresses.saveButton);
const message = await page.waitForSnackbar();
expect(message.text).toBe('Data saved!');
expect(message.text).toContain('Data saved!');
});
it(`should navigate back to the addresses index`, async() => {
@ -91,7 +91,7 @@ describe('Client Add address path', () => {
await page.waitToClick(selectors.clientAddresses.secondMakeDefaultStar);
const message = await page.waitForSnackbar();
expect(message.text).toBe('Data saved!');
expect(message.text).toContain('Data saved!');
});
it(`should confirm the default address is the expected one`, async() => {
@ -113,7 +113,7 @@ describe('Client Add address path', () => {
await page.waitToClick(selectors.clientAddresses.saveButton);
const message = await page.waitForSnackbar();
expect(message.text).toBe('The default consignee can not be unchecked');
expect(message.text).toContain('The default consignee can not be unchecked');
});
it(`should go back to the addreses section by clicking the cancel button`, async() => {

View File

@ -28,7 +28,7 @@ describe('Client add address notes path', () => {
await page.waitToClick(selectors.clientAddresses.saveButton);
const message = await page.waitForSnackbar();
expect(message.text).toBe('Some fields are invalid');
expect(message.text).toContain('Some fields are invalid');
});
it('should not save an observation type without description', async() => {
@ -37,7 +37,7 @@ describe('Client add address notes path', () => {
await page.waitToClick(selectors.clientAddresses.saveButton);
const message = await page.waitForSnackbar();
expect(message.text).toBe('Some fields are invalid');
expect(message.text).toContain('Some fields are invalid');
});
it('should create two new observations', async() => {
@ -48,6 +48,6 @@ describe('Client add address notes path', () => {
await page.waitToClick(selectors.clientAddresses.saveButton);
const message = await page.waitForSnackbar();
expect(message.text).toBe('Data saved!');
expect(message.text).toContain('Data saved!');
});
});

View File

@ -23,7 +23,7 @@ describe('Client Edit web access path', () => {
await page.waitToClick(selectors.clientWebAccess.saveButton);
const message = await page.waitForSnackbar();
expect(message.text).toBe('Data saved!');
expect(message.text).toContain('Data saved!');
});
it('should confirm web access is now unchecked', async() => {

View File

@ -31,7 +31,7 @@ describe('Client Add notes path', () => {
await page.waitToClick(selectors.clientNotes.saveButton);
const message = await page.waitForSnackbar();
expect(message.text).toBe('Data saved!');
expect(message.text).toContain('Data saved!');
});
it('should confirm the note was created', async() => {

View File

@ -27,7 +27,7 @@ describe('Client Add credit path', () => {
await page.waitToClick(selectors.clientCredit.saveButton);
const message = await page.waitForSnackbar();
expect(message.text).toBe('Data saved!');
expect(message.text).toContain('Data saved!');
});
it('should confirm the credit was updated', async() => {

View File

@ -26,7 +26,7 @@ describe('Client Add greuge path', () => {
await page.waitToClick(selectors.clientGreuge.saveButton);
const message = await page.waitForSnackbar();
expect(message.text).toBe('Some fields are invalid');
expect(message.text).toContain('Some fields are invalid');
});
it(`should create a new greuge with all its data`, async() => {
@ -36,7 +36,7 @@ describe('Client Add greuge path', () => {
await page.waitToClick(selectors.clientGreuge.saveButton);
const message = await page.waitForSnackbar();
expect(message.text).toBe('Data saved!');
expect(message.text).toContain('Data saved!');
});
it('should confirm the greuge was added to the list', async() => {

View File

@ -32,7 +32,7 @@ describe('Client lock verified data path', () => {
await page.waitToClick(selectors.clientFiscalData.saveButton);
const message = await page.waitForSnackbar();
expect(message.text).toBe('Data saved!');
expect(message.text).toContain('Data saved!');
});
it('should confirm the social name have been edited', async() => {
@ -64,7 +64,7 @@ describe('Client lock verified data path', () => {
await page.waitToClick(selectors.globalItems.acceptButton);
const message = await page.waitForSnackbar();
expect(message.text).toBe('Data saved!');
expect(message.text).toContain('Data saved!');
});
it('should confirm Verified data checkbox is checked', async() => {
@ -81,7 +81,7 @@ describe('Client lock verified data path', () => {
await page.waitToClick(selectors.clientFiscalData.saveButton);
const message = await page.waitForSnackbar();
expect(message.text).toBe('Data saved!');
expect(message.text).toContain('Data saved!');
});
it('should again confirm the social name have been edited', async() => {
@ -111,7 +111,7 @@ describe('Client lock verified data path', () => {
await page.waitToClick(selectors.clientFiscalData.saveButton);
const message = await page.waitForSnackbar();
expect(message.text).toBe(`You can't make changes on a client with verified data`);
expect(message.text).toContain(`You can't make changes on a client with verified data`);
});
});
@ -135,7 +135,7 @@ describe('Client lock verified data path', () => {
await page.waitToClick(selectors.clientFiscalData.saveButton);
const message = await page.waitForSnackbar();
expect(message.text).toBe('Data saved!');
expect(message.text).toContain('Data saved!');
});
it('should now confirm the social name have been edited once and for all', async() => {

View File

@ -22,7 +22,7 @@ describe('Client log path', () => {
await page.waitToClick(selectors.clientBasicData.saveButton);
const message = await page.waitForSnackbar();
expect(message.text).toBe('Data saved!');
expect(message.text).toContain('Data saved!');
});
it('should navigate to the log section', async() => {

View File

@ -20,7 +20,7 @@ describe('Client balance path', () => {
await page.autocompleteSearch(selectors.globalItems.userLocalCompany, 'CCs');
const message = await page.waitForSnackbar();
expect(message.text).toBe('Data saved!');
expect(message.text).toContain('Data saved!');
});
it('should access to the balance section to check the data shown matches the local settings', async() => {
@ -35,7 +35,7 @@ describe('Client balance path', () => {
await page.clearInput(selectors.globalItems.userConfigThirdAutocomplete);
const message = await page.waitForSnackbar();
expect(message.text).toBe('Data saved!');
expect(message.text).toContain('Data saved!');
});
it('should click the new payment button', async() => {
@ -51,7 +51,7 @@ describe('Client balance path', () => {
await page.waitToClick(selectors.clientBalance.saveButton);
const message = await page.waitForSnackbar();
expect(message.text).toBe('Data saved!');
expect(message.text).toContain('Data saved!');
});
it('should edit the 1st line reference', async() => {
@ -60,7 +60,7 @@ describe('Client balance path', () => {
await page.keyboard.press('Enter');
const message = await page.waitForSnackbar();
expect(message.text).toBe('Data saved!');
expect(message.text).toContain('Data saved!');
});
it('should check balance is now 0, the reference was saved and the company is now VNL becouse the user local settings were removed', async() => {
@ -85,7 +85,7 @@ describe('Client balance path', () => {
await page.waitToClick(selectors.clientBalance.saveButton);
const message = await page.waitForSnackbar();
expect(message.text).toBe('Data saved!');
expect(message.text).toContain('Data saved!');
});
it('should check balance is now -100', async() => {
@ -101,7 +101,7 @@ describe('Client balance path', () => {
await page.waitToClick(selectors.clientBalance.saveButton);
const message = await page.waitForSnackbar();
expect(message.text).toBe('Data saved!');
expect(message.text).toContain('Data saved!');
});
it('should check balance is now 50', async() => {

View File

@ -22,7 +22,7 @@ describe('Client DMS', () => {
await page.respondToDialog('accept');
const message = await page.waitForSnackbar();
expect(message.text).toBe('Data saved!');
expect(message.text).toContain('Data saved!');
});
it(`should click on the first document line worker name making the descriptor visible`, async() => {

View File

@ -24,7 +24,7 @@ describe('Client contacts', () => {
await page.waitToClick(selectors.clientContacts.saveButton);
const message = await page.waitForSnackbar();
expect(message.text).toBe('Data saved!');
expect(message.text).toContain('Data saved!');
});
it('should delete de contact', async() => {
@ -33,6 +33,6 @@ describe('Client contacts', () => {
await page.waitToClick(selectors.clientContacts.saveButton);
const message = await page.waitForSnackbar();
expect(message.text).toBe('Data saved!');
expect(message.text).toContain('Data saved!');
});
});

View File

@ -26,7 +26,7 @@ describe('Worker basic data path', () => {
await page.waitToClick(selectors.workerBasicData.saveButton);
const message = await page.waitForSnackbar();
expect(message.text).toBe('Data saved!');
expect(message.text).toContain('Data saved!');
});
it('should reload the section then check the name was edited', async() => {

View File

@ -21,7 +21,7 @@ describe('Worker pbx path', () => {
await page.waitToClick(selectors.workerPbx.saveButton);
const message = await page.waitForSnackbar();
expect(message.text).toBe('Extension format is invalid');
expect(message.text).toContain('Extension format is invalid');
});
it('should sucessfully save the changes', async() => {
@ -30,6 +30,6 @@ describe('Worker pbx path', () => {
await page.waitToClick(selectors.workerPbx.saveButton);
const message = await page.waitForSnackbar();
expect(message.text).toBe('Data saved! User must access web');
expect(message.text).toContain('Data saved! User must access web');
});
});

View File

@ -59,7 +59,7 @@ describe('Worker time control path', () => {
await page.respondToDialog('accept');
const message = await page.waitForSnackbar();
expect(message.text).toBe('Entry removed');
expect(message.text).toContain('Entry removed');
});
it(`should scan out Hank Pym to leave early`, async() => {

View File

@ -38,7 +38,7 @@ describe('Item Edit basic data path', () => {
await page.waitToClick(selectors.itemBasicData.submitBasicDataButton);
const message = await page.waitForSnackbar();
expect(message.text).toBe('Data saved!');
expect(message.text).toContain('Data saved!');
});
it(`should create a new intrastat`, async() => {
@ -57,7 +57,7 @@ describe('Item Edit basic data path', () => {
await page.waitToClick(selectors.itemBasicData.submitBasicDataButton);
const message = await page.waitForSnackbar();
expect(message.text).toBe('Data saved!');
expect(message.text).toContain('Data saved!');
});
it(`should confirm the item name was edited`, async() => {

View File

@ -23,7 +23,7 @@ describe('Item edit tax path', () => {
await page.waitToClick(selectors.itemTax.submitTaxButton);
const message = await page.waitForSnackbar();
expect(message.text).toBe('Data saved!');
expect(message.text).toContain('Data saved!');
});
it(`should confirm the first item tax class was edited`, async() => {

View File

@ -26,7 +26,7 @@ describe('Item create tags path', () => {
await page.waitToClick(selectors.itemTags.submitItemTagsButton);
const message = await page.waitForSnackbar();
expect(message.text).toBe('Data saved!');
expect(message.text).toContain('Data saved!');
});
it(`should confirm the fourth row data is the expected one`, async() => {

View File

@ -25,7 +25,7 @@ describe('Item create niche path', () => {
await page.waitToClick(selectors.itemNiches.submitNichesButton);
const message = await page.waitForSnackbar();
expect(message.text).toBe('Data saved!');
expect(message.text).toContain('Data saved!');
});
it(`should confirm the first niche is the expected one`, async() => {

View File

@ -23,7 +23,7 @@ describe('Item Create botanical path', () => {
await page.waitToClick(selectors.itemBotanical.submitBotanicalButton);
const message = await page.waitForSnackbar();
expect(message.text).toBe('Data saved!');
expect(message.text).toContain('Data saved!');
});
it(`should confirm the botanical for the item was created`, async() => {
@ -58,7 +58,7 @@ describe('Item Create botanical path', () => {
await page.waitToClick(selectors.itemBotanical.submitBotanicalButton);
const message = await page.waitForSnackbar();
expect(message.text).toBe('Data saved!');
expect(message.text).toContain('Data saved!');
});
it(`should confirm the botanical for the item was edited`, async() => {

View File

@ -23,7 +23,7 @@ describe('Item Create barcodes path', () => {
await page.waitToClick(selectors.itemBarcodes.submitBarcodesButton);
const message = await page.waitForSnackbar();
expect(message.text).toBe('Data saved!');
expect(message.text).toContain('Data saved!');
});
it(`should confirm the barcode 5 is created and it is now the third barcode as the first was deleted`, async() => {

View File

@ -45,7 +45,7 @@ describe('Item Create/Clone path', () => {
await page.waitToClick(selectors.itemCreateView.createButton);
const message = await page.waitForSnackbar();
expect(message.text).toBe('Data saved!');
expect(message.text).toContain('Data saved!');
});
it('should confirm Infinity Gauntlet item was created', async() => {

View File

@ -20,7 +20,7 @@ describe('Item regularize path', () => {
await page.autocompleteSearch(selectors.globalItems.userLocalWarehouse, 'Warehouse Four');
const message = await page.waitForSnackbar();
expect(message.text).toBe('Data saved!');
expect(message.text).toContain('Data saved!');
});
it('should check the local settings were saved', async() => {
@ -51,7 +51,7 @@ describe('Item regularize path', () => {
await page.waitToClick(selectors.itemDescriptor.regularizeSaveButton);
const message = await page.waitForSnackbar();
expect(message.text).toBe('Data saved!');
expect(message.text).toContain('Data saved!');
});
it('should click on the Tickets button of the top bar menu', async() => {
@ -70,7 +70,7 @@ describe('Item regularize path', () => {
await page.clearInput(selectors.globalItems.userConfigFirstAutocomplete);
const message = await page.waitForSnackbar();
expect(message.text).toBe('Data saved!');
expect(message.text).toContain('Data saved!');
});
it('should search for the ticket with alias missing', async() => {
@ -114,7 +114,7 @@ describe('Item regularize path', () => {
await page.waitToClick(selectors.itemDescriptor.regularizeSaveButton);
const message = await page.waitForSnackbar();
expect(message.text).toBe('Data saved!');
expect(message.text).toContain('Data saved!');
});
it('should again click on the Tickets button of the top bar menu', async() => {

View File

@ -36,7 +36,7 @@ describe('Item index path', () => {
await page.waitToClick(selectors.itemsIndex.saveFieldsButton);
const message = await page.waitForSnackbar();
expect(message.text).toBe('Data saved!');
expect(message.text).toContain('Data saved!');
});
it('should navigate forth and back to see the images column is still visible', async() => {
@ -70,7 +70,7 @@ describe('Item index path', () => {
await page.waitToClick(selectors.itemsIndex.saveFieldsButton);
const message = await page.waitForSnackbar();
expect(message.text).toBe('Data saved!');
expect(message.text).toContain('Data saved!');
});
it('should now navigate forth and back to see the ids column is now visible', async() => {

View File

@ -34,7 +34,7 @@ describe('Item log path', () => {
await page.waitToClick(selectors.itemCreateView.createButton);
const message = await page.waitForSnackbar();
expect(message.text).toBe('Data saved!');
expect(message.text).toContain('Data saved!');
});
it('should return to the items index by clicking the return to items button', async() => {

View File

@ -29,7 +29,7 @@ describe('Item descriptor path', () => {
await page.waitToClick(selectors.itemBasicData.submitBasicDataButton);
const message = await page.waitForSnackbar();
expect(message.text).toBe('Data saved!');
expect(message.text).toContain('Data saved!');
});
it('should reload the section and check the inactive icon is bright', async() => {
@ -45,6 +45,6 @@ describe('Item descriptor path', () => {
await page.waitToClick(selectors.itemBasicData.submitBasicDataButton);
const message = await page.waitForSnackbar();
expect(message.text).toBe('Data saved!');
expect(message.text).toContain('Data saved!');
});
});

View File

@ -55,29 +55,13 @@ describe('Ticket List sale path', () => {
it('should select a valid item to be added as the second item in the sales list', async() => {
let searchValue = 'Melee weapon heavy shield 1x0.5m';
await page.waitToClick(`${selectors.ticketSales.secondSaleIdAutocomplete} input`);
await page.waitForSelector(selector => {
document
.querySelector(`${selector} vn-drop-down`).$ctrl.content
.querySelectorAll('li');
}, selectors.ticketSales.secondSaleIdAutocomplete);
await page.write(`.vn-drop-down.shown`, searchValue);
await page.waitForFunction((selector, searchValue) => {
let element = document
.querySelector(`${selector} vn-drop-down`).$ctrl.content
.querySelector('li.active');
if (element)
return element.innerText.includes(searchValue);
}, {}, selectors.ticketSales.secondSaleIdAutocomplete, searchValue);
await page.keyboard.press('Enter');
await page.autocompleteSearch(selectors.ticketSales.secondSaleIdAutocomplete, searchValue);
await page.waitToClick(selectors.ticketSales.secondSaleQuantityCell);
await page.type(selectors.ticketSales.secondSaleQuantity, '1');
await page.keyboard.press('Enter');
const message = await page.waitForSnackbar();
expect(message.text).toBe('Data saved!');
expect(message.text).toContain('Data saved!');
});
it('should update the description of the new sale', async() => {
@ -86,25 +70,25 @@ describe('Ticket List sale path', () => {
await page.keyboard.press('Enter');
const message = await page.waitForSnackbar();
expect(message.text).toBe('Data saved!');
expect(message.text).toContain('Data saved!');
});
it('should add a third empty item to the sale list', async() => {
await page.waitToClick(selectors.ticketSales.newItemButton);
await page.waitForNumberOfElements(selectors.ticketSales.saleLine, 3);
const sales = await page.countElement(selectors.ticketSales.saleLine);
expect(sales).toEqual(3);
});
it('should select the 2nd and 3th item and delete both', async() => {
await page.waitFor(2000);
await page.waitToClick(selectors.ticketSales.secondSaleCheckbox);
await page.waitToClick(selectors.ticketSales.thirdSaleCheckbox);
await page.waitToClick(selectors.ticketSales.deleteSaleButton);
await page.waitToClick(selectors.globalItems.acceptButton);
const message = await page.waitForSnackbar();
expect(message.text).toBe('Data saved!');
expect(message.text).toContain('Data saved!');
});
it(`should verify there's only 1 single line remaining`, async() => {

View File

@ -41,7 +41,7 @@ describe('Ticket Edit sale path', () => {
await page.keyboard.press('Enter');
const message = await page.waitForSnackbar();
expect(message.text).toBe('Data saved!');
expect(message.text).toContain('Data saved!');
});
it(`should check it's state is libre now`, async() => {
@ -55,7 +55,7 @@ describe('Ticket Edit sale path', () => {
await page.waitToClick(selectors.ticketSales.setOk);
const message = await page.waitForSnackbar();
expect(message.text).toBe('Data saved!');
expect(message.text).toContain('Data saved!');
});
it(`should check it's state is OK now`, async() => {
@ -125,7 +125,7 @@ describe('Ticket Edit sale path', () => {
await page.type(selectors.ticketSales.firstSaleQuantity, '11\u000d');
const message = await page.waitForSnackbar();
expect(message.text).toBe('The new quantity should be smaller than the old one');
expect(message.text).toContain('The new quantity should be smaller than the old one');
});
it('should remove 1 from the first sale quantity', async() => {
@ -135,7 +135,7 @@ describe('Ticket Edit sale path', () => {
await page.type(selectors.ticketSales.firstSaleQuantity, '9\u000d');
const message = await page.waitForSnackbar();
expect(message.text).toBe('Data saved!');
expect(message.text).toContain('Data saved!');
});
it('should update the price', async() => {
@ -144,7 +144,7 @@ describe('Ticket Edit sale path', () => {
await page.type(selectors.ticketSales.firstSalePriceInput, '5\u000d');
const message = await page.waitForSnackbar();
expect(message.text).toBe('Data saved!');
expect(message.text).toContain('Data saved!');
});
it('should confirm the price have been updated', async() => {
@ -165,7 +165,7 @@ describe('Ticket Edit sale path', () => {
await page.type(selectors.ticketSales.firstSaleDiscountInput, '50\u000d');
const message = await page.waitForSnackbar();
expect(message.text).toBe('Data saved!');
expect(message.text).toContain('Data saved!');
});
it('should confirm the discount have been updated', async() => {
@ -224,7 +224,7 @@ describe('Ticket Edit sale path', () => {
await page.waitForSpinnerLoad();
const message = await page.waitForSnackbar();
expect(message.text).toBe('Data saved!');
expect(message.text).toContain('Data saved!');
});
it(`should confirm the third sale was deleted`, async() => {
@ -307,7 +307,7 @@ describe('Ticket Edit sale path', () => {
await page.waitToClick(selectors.ticketSales.moveToNewTicketButton);
const message = await page.waitForSnackbar();
expect(message.text).toBe(`You can't create a ticket for a inactive client`);
expect(message.text).toContain(`You can't create a ticket for a inactive client`);
await page.closePopup();
});

View File

@ -24,7 +24,7 @@ describe('Ticket Create notes path', () => {
await page.waitToClick(selectors.ticketNotes.submitNotesButton);
const message = await page.waitForSnackbar();
expect(message.text).toBe('Data saved!');
expect(message.text).toContain('Data saved!');
});
it('should confirm the note is the expected one', async() => {
@ -45,6 +45,6 @@ describe('Ticket Create notes path', () => {
await page.waitToClick(selectors.ticketNotes.submitNotesButton);
const message = await page.waitForSnackbar();
expect(message.text).toBe('Data saved!');
expect(message.text).toContain('Data saved!');
});
});

View File

@ -24,7 +24,7 @@ describe('Ticket Create packages path', () => {
await page.waitToClick(selectors.ticketPackages.savePackagesButton);
const message = await page.waitForSnackbar();
expect(message.text).toBe('Package cannot be blank');
expect(message.text).toContain('Package cannot be blank');
});
it(`should delete the first package and receive and error to save a new one with blank quantity`, async() => {
@ -33,7 +33,7 @@ describe('Ticket Create packages path', () => {
await page.waitToClick(selectors.ticketPackages.savePackagesButton);
const message = await page.waitForSnackbar();
expect(message.text).toBe('Some fields are invalid');
expect(message.text).toContain('Some fields are invalid');
});
it(`should confirm the quantity input isn't invalid yet`, async() => {
@ -51,7 +51,7 @@ describe('Ticket Create packages path', () => {
await page.waitToClick(selectors.ticketPackages.savePackagesButton);
const message = await page.waitForSnackbar();
expect(message.text).toBe('Data saved!');
expect(message.text).toContain('Data saved!');
});
it(`should confirm the first select is the expected one`, async() => {

View File

@ -28,7 +28,7 @@ describe('Ticket Create new tracking state path', () => {
await page.waitToClick(selectors.createStateView.saveStateButton);
const message = await page.waitForSnackbar();
expect(message.text).toBe('State cannot be blank');
expect(message.text).toContain('State cannot be blank');
});
it(`should create a new state`, async() => {
@ -36,7 +36,7 @@ describe('Ticket Create new tracking state path', () => {
await page.waitToClick(selectors.createStateView.saveStateButton);
const message = await page.waitForSnackbar();
expect(message.text).toBe('Data saved!');
expect(message.text).toContain('Data saved!');
});
});
@ -59,7 +59,7 @@ describe('Ticket Create new tracking state path', () => {
await page.waitToClick(selectors.createStateView.saveStateButton);
const message = await page.waitForSnackbar();
expect(message.text).toBe(`You don't have enough privileges`);
expect(message.text).toContain(`You don't have enough privileges`);
});
it(`should make sure the worker gets autocomplete uppon selecting the assigned state`, async() => {
@ -74,7 +74,7 @@ describe('Ticket Create new tracking state path', () => {
await page.waitToClick(selectors.createStateView.saveStateButton);
const message = await page.waitForSnackbar();
expect(message.text).toBe('Data saved!');
expect(message.text).toContain('Data saved!');
});
});
});

View File

@ -33,7 +33,7 @@ describe('Ticket descriptor path', () => {
await page.waitToClick(selectors.ticketDescriptor.thursdayButton);
const message = await page.waitForSnackbar();
expect(message.text).toBe('Data saved!');
expect(message.text).toContain('Data saved!');
});
it('should again click on the Tickets button of the top bar menu', async() => {
@ -68,7 +68,7 @@ describe('Ticket descriptor path', () => {
await page.waitToClick(selectors.ticketDescriptor.saturdayButton);
const message = await page.waitForSnackbar();
expect(message.text).toBe('Data saved!');
expect(message.text).toContain('Data saved!');
});
it('should click on the Tickets button of the top bar menu once again', async() => {
@ -97,7 +97,7 @@ describe('Ticket descriptor path', () => {
await page.waitToClick(selectors.ticketsIndex.acceptDeleteTurn);
const message = await page.waitForSnackbar();
expect(message.text).toBe('Data saved!');
expect(message.text).toContain('Data saved!');
});
it('should confirm the sixth weekly ticket was deleted', async() => {
@ -111,11 +111,11 @@ describe('Ticket descriptor path', () => {
await page.autocompleteSearch(selectors.ticketsIndex.firstWeeklyTicketAgency, 'Silla247');
let message = await page.waitForSnackbar();
expect(message.text).toBe('Data saved!');
expect(message.text).toContain('Data saved!');
await page.clearInput(selectors.ticketsIndex.firstWeeklyTicketAgency);
message = await page.waitForSnackbar();
expect(message.text).toBe('Data saved!');
expect(message.text).toContain('Data saved!');
});
});

View File

@ -27,7 +27,7 @@ describe('Ticket purchase request path', () => {
await page.waitToClick(selectors.ticketRequests.saveButton);
const message = await page.waitForSnackbar();
expect(message.text).toBe('Data saved!');
expect(message.text).toContain('Data saved!');
});
it('should have been redirected to the request index', async() => {
@ -39,7 +39,7 @@ describe('Ticket purchase request path', () => {
await page.keyboard.press('Enter');
const message = await page.waitForSnackbar();
expect(message.text).toBe('Data saved!');
expect(message.text).toContain('Data saved!');
});
it('should check the new request was added', async() => {
@ -67,7 +67,7 @@ describe('Ticket purchase request path', () => {
await page.waitToClick(selectors.ticketRequests.thirdRemoveRequestButton);
const message = await page.waitForSnackbar();
expect(message.text).toBe('Data saved!');
expect(message.text).toContain('Data saved!');
});
it('should check the request was deleted', async() => {

View File

@ -28,10 +28,11 @@ describe('Ticket descriptor path', () => {
await page.waitToClick(selectors.ticketDescriptor.acceptChangeHourButton);
const message = await page.waitForSnackbar();
expect(message.text).toBe('Shipped hour updated');
expect(message.text).toContain('Shipped hour updated');
});
it(`should confirm the ticket descriptor shows the correct shipping hour`, async() => {
await page.waitForState('ticket.card.summary');
const result = await page
.waitToGetProperty(selectors.ticketDescriptor.descriptorDeliveryDate, 'innerText');
@ -44,7 +45,7 @@ describe('Ticket descriptor path', () => {
await page.waitToClick(selectors.ticketDescriptor.acceptDialog);
const message = await page.waitForSnackbar();
expect(message.text).toBe('Ticket deleted. You can undo this action within the first hour');
expect(message.text).toContain('Ticket deleted. You can undo this action within the first hour');
});
it('should have been relocated to the ticket index', async() => {
@ -67,9 +68,10 @@ describe('Ticket descriptor path', () => {
await page.waitToClick(selectors.ticketDescriptor.moreMenu);
await page.waitToClick(selectors.ticketDescriptor.moreMenuRestoreTicket);
await page.waitToClick(selectors.ticketDescriptor.acceptDialog);
await page.waitForState('ticket.card.summary');
const message = await page.waitForSnackbar();
expect(message.text).toBe('Data saved!');
expect(message.text).toContain('Data saved!');
});
it('should make sure the ticketDeleted icon is no longer bright', async() => {
@ -77,7 +79,7 @@ describe('Ticket descriptor path', () => {
});
});
describe('add stowaway', () => {
describe('Add stowaway', () => {
it('should search for a ticket', async() => {
await page.accessToSearchResult('16');
await page.waitForState('ticket.card.summary');
@ -85,7 +87,7 @@ describe('Ticket descriptor path', () => {
it('should open the add stowaway dialog', async() => {
await page.waitForFunction(() => {
let element = document.querySelector('vn-ticket-descriptor');
let element = document.querySelector('vn-ticket-descriptor-menu');
return element.$ctrl.canShowStowaway === true;
});
await page.waitToClick(selectors.ticketDescriptor.moreMenu);
@ -100,10 +102,11 @@ describe('Ticket descriptor path', () => {
await page.waitToClick(selectors.ticketDescriptor.addStowawayDialogFirstTicket);
const message = await page.waitForSnackbar();
expect(message.text).toBe('Data saved!');
expect(message.text).toContain('Data saved!');
});
it(`should check the state of the stowaway ticket is embarked`, async() => {
await page.waitForState('ticket.card.summary');
const state = await page.waitToGetProperty(selectors.ticketDescriptor.stateLabelValue, 'innerText');
expect(state).toEqual('State Embarcando');
@ -121,7 +124,7 @@ describe('Ticket descriptor path', () => {
await page.waitToClick(selectors.ticketDescriptor.acceptDeleteStowawayButton);
const message = await page.waitForSnackbar();
expect(message.text).toBe('Data saved!');
expect(message.text).toContain('Data saved!');
});
it(`should confirm the ship buton doesn't exisist any more`, async() => {
@ -152,7 +155,7 @@ describe('Ticket descriptor path', () => {
await page.waitToClick(selectors.ticketDescriptor.acceptInvoiceOutButton);
const message = await page.waitForSnackbar();
expect(message.text).toBe('Ticket invoiced');
expect(message.text).toContain('Ticket invoiced');
});
it(`should make sure the ticket summary have an invoiceOutFk`, async() => {

View File

@ -34,7 +34,7 @@ describe('Ticket services path', () => {
await page.waitToClick(selectors.ticketService.saveServiceButton);
const message = await page.waitForSnackbar();
expect(message.text).toBe(`The current ticket can't be modified`);
expect(message.text).toContain(`The current ticket can't be modified`);
});
});
@ -58,7 +58,7 @@ describe('Ticket services path', () => {
await page.waitToClick(selectors.ticketService.saveServiceButton);
const message = await page.waitForSnackbar();
expect(message.text).toBe(`can't be blank`);
expect(message.text).toContain(`can't be blank`);
});
it('should click on the add new service type to open the dialog', async() => {
@ -73,7 +73,7 @@ describe('Ticket services path', () => {
await page.waitToClick(selectors.ticketService.saveServiceTypeButton);
const message = await page.waitForSnackbar();
expect(message.text).toBe(`Name can't be empty`);
expect(message.text).toContain(`Name can't be empty`);
});
it('should create a new service type then add price then create the service', async() => {
@ -83,7 +83,7 @@ describe('Ticket services path', () => {
await page.waitToClick(selectors.ticketService.saveServiceButton);
const message = await page.waitForSnackbar();
expect(message.text).toBe('Data saved!');
expect(message.text).toContain('Data saved!');
});
it('should confirm the service description was created correctly', async() => {
@ -114,7 +114,7 @@ describe('Ticket services path', () => {
await page.waitToClick(selectors.ticketService.saveServiceButton);
const message = await page.waitForSnackbar();
expect(message.text).toBe('Data saved!');
expect(message.text).toContain('Data saved!');
});
it(`should confirm the service was removed`, async() => {

View File

@ -31,7 +31,7 @@ describe('Ticket create path', () => {
await page.waitToClick(selectors.createTicketView.createButton);
const message = await page.waitForSnackbar();
expect(message.text).toBe('Data saved!');
expect(message.text).toContain('Data saved!');
});
it('should check the url is now the summary of the ticket', async() => {
@ -55,7 +55,7 @@ describe('Ticket create path', () => {
await page.waitToClick(selectors.createTicketView.createButton);
const message = await page.waitForSnackbar();
expect(message.text).toBe('Data saved!');
expect(message.text).toContain('Data saved!');
});
it('should check the url is now the summary of the created ticket', async() => {
@ -68,7 +68,7 @@ describe('Ticket create path', () => {
await page.waitToClick(selectors.ticketDescriptor.addStowawayDialogFirstTicket);
const message = await page.waitForSnackbar();
expect(message.text).toBe('Data saved!');
expect(message.text).toContain('Data saved!');
});
it('should delete the current ticket', async() => {
@ -77,7 +77,7 @@ describe('Ticket create path', () => {
await page.waitToClick(selectors.ticketDescriptor.acceptDialog);
const message = await page.waitForSnackbar();
expect(message.text).toBe('Ticket deleted. You can undo this action within the first hour');
expect(message.text).toContain('Ticket deleted. You can undo this action within the first hour');
});
it('should search for the stowaway ticket of the previously deleted ticket', async() => {

View File

@ -80,7 +80,7 @@ describe('Ticket Summary path', () => {
await page.waitToClick(selectors.ticketSummary.setOk);
const message = await page.waitForSnackbar();
expect(message.text).toBe('Data saved!');
expect(message.text).toContain('Data saved!');
});
it('should confirm the ticket state was updated', async() => {

View File

@ -29,7 +29,7 @@ describe('Ticket log path', () => {
await page.waitToClick(selectors.ticketNotes.submitNotesButton);
const message = await page.waitForSnackbar();
expect(message.text).toBe('Data saved!');
expect(message.text).toContain('Data saved!');
});
it('should navigate to the log section', async() => {

View File

@ -26,7 +26,7 @@ describe('Ticket index payout path', () => {
await page.waitToClick(selectors.ticketsIndex.payoutButton);
const message = await page.waitForSnackbar();
expect(message.text).toBe('You cannot make a payment on account from multiple clients');
expect(message.text).toContain('You cannot make a payment on account from multiple clients');
});
it('should uncheck the sixth ticket result and check the third which is from the same client then open the payout form', async() => {
@ -42,7 +42,7 @@ describe('Ticket index payout path', () => {
await page.waitToClick(selectors.ticketsIndex.submitPayout);
const message = await page.waitForSnackbar();
expect(message.text).toBe('Data saved!');
expect(message.text).toContain('Data saved!');
});
it('should navigate to the client balance section and check a new balance line was entered', async() => {

View File

@ -27,7 +27,7 @@ describe('Claim edit basic data path', () => {
await page.waitToClick(selectors.claimBasicData.saveButton);
const message = await page.waitForSnackbar();
expect(message.text).toBe('Data saved!');
expect(message.text).toContain('Data saved!');
});
it(`should have been redirected to the next section of claims as the role is claimManager`, async() => {
@ -40,7 +40,7 @@ describe('Claim edit basic data path', () => {
await page.waitToClick(selectors.claimBasicData.saveButton);
const message = await page.waitForSnackbar();
expect(message.text).toBe('Data saved!');
expect(message.text).toContain('Data saved!');
});
it('should confirm the claim state was edited', async() => {
@ -71,6 +71,6 @@ describe('Claim edit basic data path', () => {
await page.waitToClick(selectors.claimBasicData.saveButton);
const message = await page.waitForSnackbar();
expect(message.text).toBe('Data saved!');
expect(message.text).toContain('Data saved!');
});
});

View File

@ -28,7 +28,7 @@ describe('Claim development', () => {
await page.waitToClick(selectors.claimDevelopment.saveDevelopmentButton);
const message = await page.waitForSnackbar();
expect(message.text).toBe('Data saved!');
expect(message.text).toContain('Data saved!');
});
it(`should redirect to the next section of claims as the role is claimManager`, async() => {
@ -45,7 +45,7 @@ describe('Claim development', () => {
await page.waitToClick(selectors.claimDevelopment.saveDevelopmentButton);
const message = await page.waitForSnackbar();
expect(message.text).toBe('Data saved!');
expect(message.text).toContain('Data saved!');
});
it('should confirm the first development is the expected one', async() => {

View File

@ -23,7 +23,7 @@ xdescribe('Claim detail', () => {
await page.waitToClick(selectors.claimDetail.firstClaimableSaleFromTicket);
const message = await page.waitForSnackbar();
expect(message.text).toBe('Data saved!');
expect(message.text).toContain('Data saved!');
});
it('should confirm the claim contains now two items', async() => {
@ -38,7 +38,7 @@ xdescribe('Claim detail', () => {
await page.keyboard.press('Enter');
const message = await page.waitForSnackbar();
expect(message.text).toBe('Data saved!');
expect(message.text).toContain('Data saved!');
});
it('should confirm the first item quantity, and the claimed total were correctly edited', async() => {
@ -67,7 +67,7 @@ xdescribe('Claim detail', () => {
await page.keyboard.press('Enter');
const message = await page.waitForSnackbar();
expect(message.text).toBe('Data saved!');
expect(message.text).toContain('Data saved!');
});
it('should check the mana is the expected one', async() => {
@ -81,7 +81,7 @@ xdescribe('Claim detail', () => {
await page.waitToClick(selectors.claimDetail.secondItemDeleteButton);
const message = await page.waitForSnackbar();
expect(message.text).toBe('Data saved!');
expect(message.text).toContain('Data saved!');
});
it('should confirm the claim contains now one item', async() => {
@ -95,7 +95,7 @@ xdescribe('Claim detail', () => {
await page.waitToClick(selectors.claimDetail.firstClaimableSaleFromTicket);
const message = await page.waitForSnackbar();
expect(message.text).toBe('Data saved!');
expect(message.text).toContain('Data saved!');
});
it(`should have been redirected to the next section in claims`, async() => {

View File

@ -21,7 +21,7 @@ describe('Claim action path', () => {
await page.waitToClick(selectors.claimAction.importClaimButton);
const message = await page.waitForSnackbar();
expect(message.text).toBe('Data saved!');
expect(message.text).toContain('Data saved!');
});
it('should import the second importable ticket', async() => {
@ -33,7 +33,7 @@ describe('Claim action path', () => {
await page.waitToClick(selectors.claimAction.secondImportableTicket);
const message = await page.waitForSnackbar();
expect(message.text).toBe('Data saved!');
expect(message.text).toContain('Data saved!');
});
it('should edit the second line destination field', async() => {
@ -41,14 +41,14 @@ describe('Claim action path', () => {
await page.autocompleteSearch(selectors.claimAction.secondLineDestination, 'Bueno');
const message = await page.waitForSnackbar();
expect(message.text).toBe('Data saved!');
expect(message.text).toContain('Data saved!');
});
it('should delete the first line', async() => {
await page.waitToClick(selectors.claimAction.firstDeleteLine);
const message = await page.waitForSnackbar();
expect(message.text).toBe('Data saved!');
expect(message.text).toContain('Data saved!');
});
it('should refresh the view to check the remaining line is the expected one', async() => {
@ -62,14 +62,14 @@ describe('Claim action path', () => {
await page.waitToClick(selectors.claimAction.firstDeleteLine);
const message = await page.waitForSnackbar();
expect(message.text).toBe('Data saved!');
expect(message.text).toContain('Data saved!');
});
it('should check the "is paid with mana" checkbox', async() => {
await page.waitToClick(selectors.claimAction.isPaidWithManaCheckbox);
const message = await page.waitForSnackbar();
expect(message.text).toBe('Data saved!');
expect(message.text).toContain('Data saved!');
});
it('should confirm the "is paid with mana" is checked', async() => {

View File

@ -42,7 +42,7 @@ describe('claim Descriptor path', () => {
await page.waitToClick(selectors.claimDescriptor.acceptDeleteClaim);
const message = await page.waitForSnackbar();
expect(message.text).toBe('Claim deleted!');
expect(message.text).toContain('Claim deleted!');
});
it(`should have been relocated to the claim index`, async() => {

View File

@ -25,7 +25,7 @@ describe('Order edit basic data path', () => {
await page.waitToClick(selectors.orderBasicData.saveButton);
const message = await page.waitForSnackbar();
expect(message.text).toBe(`You can't make changes on the basic data of an confirmed order or with rows`);
expect(message.text).toContain(`You can't make changes on the basic data of an confirmed order or with rows`);
});
});
@ -47,7 +47,7 @@ describe('Order edit basic data path', () => {
await page.waitToClick(selectors.orderBasicData.saveButton);
const message = await page.waitForSnackbar();
expect(message.text).toBe(`You can't make changes on the basic data of an confirmed order or with rows`);
expect(message.text).toContain(`You can't make changes on the basic data of an confirmed order or with rows`);
});
});
@ -81,7 +81,7 @@ describe('Order edit basic data path', () => {
await page.waitToClick(selectors.orderBasicData.saveButton);
const message = await page.waitForSnackbar();
expect(message.text).toBe('Data saved!');
expect(message.text).toContain('Data saved!');
});
it('should now confirm the client have been edited', async() => {

View File

@ -28,7 +28,7 @@ describe('Order lines', () => {
await page.waitToClick(selectors.orderLine.confirmButton);
const message = await page.waitForSnackbar();
expect(message.text).toBe('Data saved!');
expect(message.text).toContain('Data saved!');
});
it('should confirm the order subtotal has changed', async() => {

View File

@ -33,7 +33,7 @@ describe('Route basic Data path', () => {
await page.waitToClick(selectors.routeBasicData.saveButton);
const message = await page.waitForSnackbar();
expect(message.text).toBe('Data saved!');
expect(message.text).toContain('Data saved!');
});
it('should confirm the worker was edited', async() => {

View File

@ -27,7 +27,7 @@ describe('Route create path', () => {
await page.waitToClick(selectors.createRouteView.submitButton);
const message = await page.waitForSnackbar();
expect(message.text).toBe('Access denied');
expect(message.text).toContain('Access denied');
});
});
@ -51,7 +51,7 @@ describe('Route create path', () => {
await page.waitToClick(selectors.createRouteView.submitButton);
const message = await page.waitForSnackbar();
expect(message.text).toBe('Data saved!');
expect(message.text).toContain('Data saved!');
});
it(`should confirm the redirection to the created route summary`, async() => {

View File

@ -23,7 +23,7 @@ xdescribe('Route basic Data path', () => {
await page.keyboard.press('Enter');
const message = await page.waitForSnackbar();
expect(message.text).toBe('Data saved!');
expect(message.text).toContain('Data saved!');
});
it('should confirm the buscamanButton is disabled', async() => {
@ -60,7 +60,7 @@ xdescribe('Route basic Data path', () => {
await page.waitToClick(selectors.routeTickets.confirmButton);
const message = await page.waitForSnackbar();
expect(message.text).toBe('Ticket removed from route');
expect(message.text).toContain('Ticket removed from route');
});
it('should again delete the first ticket in route', async() => {
@ -68,7 +68,7 @@ xdescribe('Route basic Data path', () => {
await page.waitToClick(selectors.routeTickets.confirmButton);
const message = await page.waitForSnackbar();
expect(message.text).toBe('Ticket removed from route');
expect(message.text).toContain('Ticket removed from route');
});
it('should now count how many tickets are in route to find one less', async() => {

View File

@ -43,7 +43,7 @@ describe('InvoiceOut descriptor path', () => {
await page.waitToClick(selectors.invoiceOutDescriptor.acceptDeleteButton);
const message = await page.waitForSnackbar();
expect(message.text).toBe('InvoiceOut deleted');
expect(message.text).toContain('InvoiceOut deleted');
});
it('should have been relocated to the invoiceOut index', async() => {
@ -96,7 +96,7 @@ describe('InvoiceOut descriptor path', () => {
await page.waitToClick(selectors.invoiceOutDescriptor.acceptBookingButton);
const message = await page.waitForSnackbar();
expect(message.text).toBe('InvoiceOut booked');
expect(message.text).toContain('InvoiceOut booked');
});
it(`should check the invoiceOut booked in the summary data`, async() => {

View File

@ -51,7 +51,7 @@ describe('Travel thermograph path', () => {
const message = await page.waitForSnackbar();
const state = await page.getState();
expect(message.text).toBe('Data saved!');
expect(message.text).toContain('Data saved!');
expect(state).toBe('travel.card.thermograph.index');
});

View File

@ -29,7 +29,7 @@ describe('Travel basic data path', () => {
await page.waitToClick(selectors.travelBasicDada.save);
const message = await page.waitForSnackbar();
expect(message.text).toBe('Landing cannot be lesser than shipment');
expect(message.text).toContain('Landing cannot be lesser than shipment');
});
it('should undo the changes', async() => {
@ -37,7 +37,7 @@ describe('Travel basic data path', () => {
await page.waitToClick(selectors.travelBasicDada.save);
const message = await page.waitForSnackbar();
expect(message.text).toBe('No changes to save');
expect(message.text).toContain('No changes to save');
});
it('should now edit the whole form then save', async() => {
@ -52,7 +52,7 @@ describe('Travel basic data path', () => {
await page.waitToClick(selectors.travelBasicDada.save);
const message = await page.waitForSnackbar();
expect(message.text).toBe('Data saved!');
expect(message.text).toContain('Data saved!');
});
it('should reload the section and check the reference was saved', async() => {

View File

@ -40,7 +40,7 @@ describe('Zone basic data path', () => {
await page.waitToClick(selectors.zoneBasicData.saveButton);
const message = await page.waitForSnackbar();
expect(message.text).toBe('Data saved!');
expect(message.text).toContain('Data saved!');
});
it('should now reload the section', async() => {

View File

@ -35,7 +35,7 @@ describe('Entry basic data path', () => {
const message = await page.waitForSnackbar();
expect(message.text).toBe('Data saved!');
expect(message.text).toContain('Data saved!');
});
it('should confirm the reference was edited', async() => {

View File

@ -27,7 +27,7 @@ describe('Supplier basic data path', () => {
await page.waitToClick(selectors.supplierBasicData.saveButton);
const message = await page.waitForSnackbar();
expect(message.text).toBe('Data saved!');
expect(message.text).toContain('Data saved!');
});
it('should reload the section', async() => {

View File

@ -35,7 +35,7 @@ describe('Supplier fiscal data path', () => {
await page.waitToClick(selectors.supplierFiscalData.saveButton);
const message = await page.waitForSnackbar();
expect(message.text).toBe('Invalid Tax number');
expect(message.text).toContain('Invalid Tax number');
});
it('should save the changes as the tax number is valid this time', async() => {
@ -45,7 +45,7 @@ describe('Supplier fiscal data path', () => {
await page.waitToClick(selectors.supplierFiscalData.saveButton);
const message = await page.waitForSnackbar();
expect(message.text).toBe('Data saved!');
expect(message.text).toContain('Data saved!');
});
it('should reload the section', async() => {

View File

@ -27,7 +27,7 @@ describe('Supplier contact path', () => {
await page.waitToClick(selectors.supplierContact.saveButton);
const message = await page.waitForSnackbar();
expect(message.text).toBe('Data saved!');
expect(message.text).toContain('Data saved!');
});
it(`should reload the section and count the contacts`, async() => {
@ -62,6 +62,7 @@ describe('Supplier contact path', () => {
});
it(`should check the new contact note was saved correctly`, async() => {
await page.waitForTextInField(selectors.supplierContact.thirdContactNotes, 'the end to end integration tester');
const result = await page.waitToGetProperty(selectors.supplierContact.thirdContactNotes, 'value');
expect(result).toContain('the end to end integration tester');
@ -76,7 +77,7 @@ describe('Supplier contact path', () => {
await page.waitToClick(selectors.supplierContact.saveButton);
const message = await page.waitForSnackbar();
expect(message.text).toBe('Data saved!');
expect(message.text).toContain('Data saved!');
});
it(`should reload the section and count the amount of contacts went back to 2`, async() => {

View File

@ -17,11 +17,14 @@
ui-sref="{{::$ctrl.summaryState}}({id: $ctrl.descriptor.id})">
<vn-icon icon="desktop_windows"></vn-icon>
</a>
<vn-icon-button
<vn-icon-button ng-if="$ctrl.$transclude.isSlotFilled('menu')"
ng-class="::{invisible: !$ctrl.$transclude.isSlotFilled('menu')}"
icon="more_vert"
vn-popover="menu">
</vn-icon-button>
<div ng-if="$ctrl.$transclude.isSlotFilled('dotMenu')"
ng-transclude="dotMenu">
</div>
</div>
<vn-menu vn-id="menu">
<vn-list ng-transclude="menu"></vn-list>

View File

@ -130,6 +130,7 @@ ngModule.vnComponent('vnDescriptorContent', {
body: 'slotBody',
before: '?slotBefore',
after: '?slotAfter',
menu: '?slotMenu'
menu: '?slotMenu',
dotMenu: '?slotDotMenu'
}
});

View File

@ -21,7 +21,8 @@ vn-descriptor-content {
align-items: stretch;
color: $color-font-dark;
& > * {
& > a,
& > vn-icon-button {
display: flex;
min-width: 45px;
height: 45px;

View File

@ -187,9 +187,25 @@ function e2eSingleRun() {
displaySpecDuration: true,
},
summary: {
displayStacktrace: 'pretty',
displayStacktrace: 'raw',
displayPending: false
}
},
colors: {
enabled: true,
successful: 'brightGreen',
failed: 'brightRed'
},
// stacktrace: {
// filter: stacktrace => {
// const lines = stacktrace.split('\n');
// const filtered = [];
// for (let i = 1; i < lines.length; i++) {
// if (/e2e\/paths/.test(lines[i]))
// filtered.push(lines[i]);
// }
// return filtered.join('\n');
// }
// }
})
]
}));

View File

@ -159,5 +159,6 @@
"companyFk": "Empresa",
"The social name cannot be empty": "La razón social no puede quedar en blanco",
"The nif cannot be empty": "El NIF no puede quedar en blanco",
"You need to fill sage information before you check verified data": "Debes rellenar la información de sage antes de marcar datos comprobados"
"You need to fill sage information before you check verified data": "Debes rellenar la información de sage antes de marcar datos comprobados",
"ASSIGN_ZONE_FIRST": "Asigna una zona primero"
}

View File

@ -31,7 +31,9 @@ module.exports = Self => {
});
const warehouse = await models.Warehouse.findById(ticket.warehouseFk);
const hasStowaway = ticket.ship() ? true : false;
if (warehouse && warehouse.hasStowaway && !hasStowaway)
const validStowaway = warehouse && warehouse.hasStowaway && !hasStowaway;
if (!ticket.isDeleted && validStowaway)
return true;
return false;

View File

@ -0,0 +1,221 @@
<vn-icon-button
icon="more_vert"
vn-popover="menu">
</vn-icon-button>
<vn-menu vn-id="menu">
<vn-list>
<vn-item
ng-click="addTurn.show()"
vn-acl="buyer"
ng-show="$ctrl.isEditable"
vn-acl-action="remove"
name="addTurn"
translate>
Add turn
</vn-item>
<vn-item
ng-click="$ctrl.showDeliveryNote()"
translate>
Show Delivery Note
</vn-item>
<vn-item
ng-click="confirmDeliveryNote.show()"
translate>
Send Delivery Note
</vn-item>
<vn-item
ng-click="deleteConfirmation.show()"
ng-show="$ctrl.isEditable"
name="deleteTicket"
translate>
Delete ticket
</vn-item>
<vn-item
ng-click="restoreConfirmation.show()"
ng-show="$ctrl.canRestoreTicket"
name="restoreTicket"
translate>
Restore ticket
</vn-item>
<vn-item
ng-click="$ctrl.showChangeShipped()"
ng-show="$ctrl.isEditable"
name="changeShipped"
translate>
Change shipped hour
</vn-item>
<vn-item
ng-click="$ctrl.sendPaymentSms()"
translate>
SMS Pending payment
</vn-item>
<vn-item
ng-click="$ctrl.sendImportSms()"
translate>
SMS Minimum import
</vn-item>
<vn-item
ng-click="addStowaway.show()"
ng-show="$ctrl.canShowStowaway"
name="addStowaway"
translate>
Add stowaway
</vn-item>
<vn-item
ng-click="deleteStowaway.show()"
ng-show="$ctrl.canDeleteStowaway"
name="deleteStowaway"
translate>
Delete stowaway
</vn-item>
<vn-item
ng-click="makeInvoiceConfirmation.show()"
ng-show="$ctrl.isEditable"
vn-acl="invoicing"
vn-acl-action="remove"
name="makeInvoice"
translate>
Make invoice
</vn-item>
<vn-item
ng-click="regenerateInvoiceConfirmation.show()"
ng-show="$ctrl.isInvoiced"
vn-acl="invoicing"
vn-acl-action="remove"
translate>
Regenerate invoice
</vn-item>
<vn-item
ng-click="recalculateComponentsConfirmation.show()"
ng-show="$ctrl.isEditable"
translate>
Recalculate components
</vn-item>
</vn-list>
</vn-menu>
<!-- Add turn popup -->
<vn-popup vn-id="addTurn">
<div class="vn-pa-md">
<h5 style="text-align: center" translate>
In which day you want to add the ticket?
</h5>
<vn-tool-bar class="vn-mt-md">
<vn-button
label="Monday"
ng-click="$ctrl.addTurn(0)">
</vn-button>
<vn-button
label="Tuesday"
ng-click="$ctrl.addTurn(1)">
</vn-button>
<vn-button
label="Wednesday"
ng-click="$ctrl.addTurn(2)">
</vn-button>
<vn-button
label="Thursday"
ng-click="$ctrl.addTurn(3)">
</vn-button>
<vn-button
label="Friday"
ng-click="$ctrl.addTurn(4)">
</vn-button>
<vn-button
label="Saturday"
ng-click="$ctrl.addTurn(5)">
</vn-button>
<vn-button
label="Sunday"
ng-click="$ctrl.addTurn(6)">
</vn-button>
</vn-tool-bar>
</div>
</vn-popup>
<!-- Send delivery note confirmation popup -->
<vn-confirm
vn-id="confirmDeliveryNote"
on-accept="$ctrl.sendDeliveryNote()"
question="Are you sure you want to send it?"
message="Send Delivery Note">
</vn-confirm>
<!-- Delete ticket confirmation popup -->
<vn-confirm
vn-id="deleteConfirmation"
on-accept="$ctrl.deleteTicket()"
question="You are going to delete this ticket"
message="This ticket will be removed from current route! Continue anyway?">
</vn-confirm>
<!-- Restore ticket confirmation popup -->
<vn-confirm
vn-id="restoreConfirmation"
on-accept="$ctrl.restoreTicket()"
question="You are going to restore this ticket"
message="Are you sure you want to restore this ticket?">
</vn-confirm>
<!-- Change shipped dialog -->
<vn-dialog
vn-id="changeShippedDialog"
on-accept="$ctrl.changeShipped()"
message="Change shipped hour">
<tpl-body>
<vn-input-time
ng-model="$ctrl.newShipped"
label="Shipped hour"
vn-focus>
</vn-input-time>
</tpl-body>
<tpl-buttons>
<input type="button" response="cancel" translate-attr="{value: 'Cancel'}"/>
<button response="accept" translate>Save</button>
</tpl-buttons>
</vn-dialog>
<!-- Send SMS popup -->
<vn-ticket-sms
vn-id="sms"
sms="$ctrl.newSMS">
</vn-ticket-sms>
<!-- Add stowaway dialog -->
<vn-add-stowaway
vn-id="addStowaway"
card-reload="$ctrl.reload()"
ticket="$ctrl.ticket">
</vn-add-stowaway>
<!-- Delete stowaway confirmation dialog -->
<vn-confirm
vn-id="deleteStowaway"
on-accept="$ctrl.deleteStowaway()"
question="Delete stowaway"
message="Are you sure you want to delete this stowaway?">
</vn-confirm>
<!-- Make invoice confirmation dialog -->
<vn-confirm
vn-id="makeInvoiceConfirmation"
on-accept="$ctrl.makeInvoice()"
question="You are going to invoice this ticket"
message="Are you sure you want to invoice this ticket?">
</vn-confirm>
<!-- Regenerate invoice confirmation dialog -->
<vn-confirm
vn-id="regenerateInvoiceConfirmation"
on-accept="$ctrl.regenerateInvoice()"
question="You are going to regenerate the invoice"
message="Are you sure you want to regenerate the invoice?">
</vn-confirm>
<!-- Recalculate components confirmation dialog -->
<vn-confirm
vn-id="recalculateComponentsConfirmation"
on-accept="$ctrl.recalculateComponents()"
question="Are you sure you want to recalculate the components?"
message="Recalculate components">
</vn-confirm>

View File

@ -0,0 +1,247 @@
import ngModule from '../module';
import Section from 'salix/components/section';
import './style.scss';
class Controller extends Section {
constructor($element, $, vnReport, vnEmail) {
super($element, $);
this.vnReport = vnReport;
this.vnEmail = vnEmail;
}
get ticketId() {
return this._ticketId;
}
set ticketId(value) {
this._ticketId = value;
this.id = value;
}
get id() {
return this._id;
}
set id(value) {
this._id = value;
if (!value) return;
this.loadData().then(() => {
if (this.$params.sendSMS)
this.showSMSDialog();
});
}
loadData() {
const filter = {
include: [{
relation: 'address',
}, {
relation: 'client',
scope: {
fields: [
'salesPersonFk',
'name',
'isActive',
'isFreezed',
'isTaxDataChecked',
'credit',
'email',
'phone',
'mobile'
],
include: {
relation: 'salesPersonUser',
scope: {
fields: ['id', 'name']
}
}
}
},
{relation: 'ship'},
{relation: 'stowaway'}]
};
return this.$http.get(`Tickets/${this.ticketId}`, {filter})
.then(res => this.ticket = res.data)
.then(() => {
this.canStowaway();
this.isTicketEditable();
});
}
reload() {
return this.loadData().then(() => {
if (this.parentReload)
this.parentReload();
});
}
get isInvoiced() {
return this.ticket.refFk !== null;
}
get isTicketModule() {
return this.$state.getCurrentPath()[1].state.name === 'ticket';
}
isTicketEditable() {
if (!this.ticket) return;
this.$http.get(`Tickets/${this.id}/isEditable`).then(res => {
this.isEditable = res.data;
});
}
addTurn(day) {
const params = {
ticketFk: this.id,
weekDay: day,
agencyModeFk: this.ticket.agencyModeFk
};
return this.$http.patch(`TicketWeeklies`, params)
.then(() => {
this.$.addTurn.hide();
this.vnApp.showSuccess(this.$t('Data saved!'));
});
}
showDeliveryNote() {
this.vnReport.show('delivery-note', {
recipientId: this.ticket.client.id,
ticketId: this.id,
});
}
sendDeliveryNote() {
return this.vnEmail.send('delivery-note', {
recipientId: this.ticket.client.id,
recipient: this.ticket.client.email,
ticketId: this.id
});
}
deleteTicket() {
return this.$http.post(`Tickets/${this.id}/setDeleted`)
.then(() => this.reload())
.then(() => {
this.$state.go('ticket.index');
this.vnApp.showSuccess(this.$t('Ticket deleted. You can undo this action within the first hour'));
});
}
get canRestoreTicket() {
const isDeleted = this.ticket.isDeleted;
const now = new Date();
const maxDate = new Date(this.ticket.updated);
maxDate.setHours(maxDate.getHours() + 1);
return isDeleted && (now <= maxDate);
}
restoreTicket() {
return this.$http.post(`Tickets/${this.id}/restore`)
.then(() => this.reload())
.then(() => this.vnApp.showSuccess(this.$t('Data saved!')));
}
showChangeShipped() {
this.newShipped = this.ticket.shipped;
this.$.changeShippedDialog.show();
}
changeShipped() {
const data = {shipped: this.newShipped};
return this.$http.post(`Tickets/${this.id}/updateEditableTicket`, data)
.then(() => this.reload())
.then(() => this.vnApp.showSuccess(this.$t('Shipped hour updated')));
}
sendImportSms() {
const params = {
ticketId: this.id,
created: this.ticket.updated
};
this.showSMSDialog({
message: this.$params.message || this.$t('Minimum is needed', params)
});
}
sendPaymentSms() {
this.showSMSDialog({
message: this.$params.message || this.$t('Make a payment')
});
}
showSMSDialog(params) {
const address = this.ticket.address;
const client = this.ticket.client;
const phone = this.$params.phone
|| address.mobile
|| address.phone
|| client.mobile
|| client.phone;
this.newSMS = Object.assign({
ticketId: this.id,
destinationFk: this.ticket.clientFk,
destination: phone
}, params);
this.$.sms.open();
}
canStowaway() {
this.canShowStowaway = false;
if (!this.isTicketModule || !this.ticket) return;
this.$http.get(`Tickets/${this.id}/canHaveStowaway`)
.then(res => this.canShowStowaway = !!res.data);
}
get canDeleteStowaway() {
if (!this.ticket || !this.isTicketModule)
return false;
return this.ticket.stowaway || this.ticket.ship;
}
deleteStowaway() {
return this.$http.post(`Tickets/${this.id}/deleteStowaway`)
.then(() => this.reload())
.then(() => this.vnApp.showSuccess(this.$t('Data saved!')));
}
makeInvoice() {
return this.$http.post(`Tickets/${this.id}/makeInvoice`)
.then(() => this.reload())
.then(() => this.vnApp.showSuccess(this.$t('Ticket invoiced')));
}
regenerateInvoice() {
const invoiceId = this.ticket.invoiceOut.id;
return this.$http.post(`InvoiceOuts/${invoiceId}/regenerate`)
.then(() => {
const snackbarMessage = this.$t(
`Invoice sent for a regeneration, will be available in a few minutes`);
this.vnApp.showSuccess(snackbarMessage);
});
}
recalculateComponents() {
return this.$http.post(`Tickets/${this.id}/recalculateComponents`)
.then(() => this.reload())
.then(() => this.vnApp.showSuccess(this.$t('Data saved!')));
}
}
Controller.$inject = ['$element', '$scope', 'vnReport', 'vnEmail'];
ngModule.vnComponent('vnTicketDescriptorMenu', {
template: require('./index.html'),
controller: Controller,
bindings: {
ticketId: '<',
parentReload: '&'
}
});

View File

@ -0,0 +1,223 @@
import './index.js';
describe('Ticket Component vnTicketDescriptorMenu', () => {
let $httpBackend;
let controller;
let $state;
const ticket = {
id: 16,
clientFk: 101,
invoiceOut: {id: 1},
client: {
id: 101,
email: 'client@email'
},
address: {
id: 101,
mobile: 111111111,
phone: 2222222222
},
tracking: {
state: {alertLevel: 3}
}
};
beforeEach(ngModule('ticket'));
beforeEach(inject(($componentController, _$httpBackend_, _$state_) => {
$httpBackend = _$httpBackend_;
$state = _$state_;
$state.params.id = 16;
$state.getCurrentPath = () => [null, {state: {name: 'ticket'}}];
const $element = angular.element('<vn-ticket-descriptor-menu></vn-ticket-descriptor-menu>');
controller = $componentController('vnTicketDescriptorMenu', {$element});
controller._ticketId = ticket.id;
controller._id = ticket.id;
controller.ticket = ticket;
}));
describe('canRestoreTicket() getter', () => {
it('should return true for a ticket deleted within the last hour', () => {
controller.ticket.isDeleted = true;
controller.ticket.updated = new Date();
const result = controller.canRestoreTicket;
expect(result).toBeTruthy();
});
it('should return false for a ticket deleted more than one hour ago', () => {
const pastHour = new Date();
pastHour.setHours(pastHour.getHours() - 2);
controller.ticket.isDeleted = true;
controller.ticket.updated = pastHour;
const result = controller.canRestoreTicket;
expect(result).toBeFalsy();
});
});
describe('addTurn()', () => {
it('should make a query and call $.addTurn.hide() and vnApp.showSuccess()', () => {
controller.$.addTurn = {hide: () => {}};
jest.spyOn(controller.$.addTurn, 'hide');
$httpBackend.expectPATCH(`TicketWeeklies`).respond();
controller.addTurn(1);
$httpBackend.flush();
expect(controller.$.addTurn.hide).toHaveBeenCalledWith();
});
});
describe('deleteTicket()', () => {
it('should make a query and call vnApp.showSuccess()', () => {
jest.spyOn(controller, 'reload').mockReturnThis();
jest.spyOn(controller.$state, 'go').mockReturnValue('ok');
jest.spyOn(controller.vnApp, 'showSuccess');
$httpBackend.expectPOST(`Tickets/${ticket.id}/setDeleted`).respond();
controller.deleteTicket();
$httpBackend.flush();
expect(controller.reload).toHaveBeenCalled();
expect(controller.$state.go).toHaveBeenCalledWith('ticket.index');
expect(controller.vnApp.showSuccess).toHaveBeenCalled();
});
});
describe('restoreTicket()', () => {
it('should make a query to restore the ticket and call vnApp.showSuccess()', () => {
jest.spyOn(controller, 'reload').mockReturnThis();
jest.spyOn(controller.vnApp, 'showSuccess');
$httpBackend.expectPOST(`Tickets/${ticket.id}/restore`).respond();
controller.restoreTicket();
$httpBackend.flush();
expect(controller.reload).toHaveBeenCalled();
expect(controller.vnApp.showSuccess).toHaveBeenCalled();
});
});
describe('showDeliveryNote()', () => {
it('should open a new window showing a delivery note PDF document', () => {
jest.spyOn(controller.vnReport, 'show');
window.open = jasmine.createSpy('open');
const params = {
recipientId: ticket.client.id,
ticketId: ticket.id
};
controller.showDeliveryNote();
expect(controller.vnReport.show).toHaveBeenCalledWith('delivery-note', params);
});
});
describe('sendDeliveryNote()', () => {
it('should make a query and call vnApp.showMessage()', () => {
jest.spyOn(controller.vnEmail, 'send');
const params = {
recipient: ticket.client.email,
recipientId: ticket.client.id,
ticketId: ticket.id
};
controller.sendDeliveryNote();
expect(controller.vnEmail.send).toHaveBeenCalledWith('delivery-note', params);
});
});
describe('makeInvoice()', () => {
it('should make a query and call $state.reload() method', () => {
jest.spyOn(controller, 'reload').mockReturnThis();
jest.spyOn(controller.vnApp, 'showSuccess');
$httpBackend.expectPOST(`Tickets/${ticket.id}/makeInvoice`).respond();
controller.makeInvoice();
$httpBackend.flush();
expect(controller.reload).toHaveBeenCalledWith();
expect(controller.vnApp.showSuccess).toHaveBeenCalled();
});
});
describe('regenerateInvoice()', () => {
it('should make a query and show a success snackbar', () => {
jest.spyOn(controller.vnApp, 'showSuccess');
$httpBackend.expectPOST(`InvoiceOuts/${ticket.invoiceOut.id}/regenerate`).respond();
controller.regenerateInvoice();
$httpBackend.flush();
expect(controller.vnApp.showSuccess).toHaveBeenCalled();
});
});
describe('changeShipped()', () => {
it('should make a query and change the shipped hour if the response is accept', () => {
jest.spyOn(controller, 'reload').mockReturnThis();
jest.spyOn(controller.vnApp, 'showSuccess');
$httpBackend.expectPOST(`Tickets/${ticket.id}/updateEditableTicket`).respond();
controller.changeShipped();
$httpBackend.flush();
expect(controller.reload).toHaveBeenCalled();
expect(controller.vnApp.showSuccess).toHaveBeenCalled();
});
});
describe('canStowaway()', () => {
it('should make a query and return if the ticket can be stowawayed', () => {
$httpBackend.expect('GET', `Tickets/${ticket.id}/canHaveStowaway`).respond(true);
controller.canStowaway();
$httpBackend.flush();
expect(controller.canShowStowaway).toBeTruthy();
});
it('should not make a query if is not on the ticket module', () => {
$state.getCurrentPath = () => [null, {state: {name: 'client'}}];
controller.canStowaway();
expect(controller.canShowStowaway).toBeFalsy();
});
});
describe('recalculateComponents()', () => {
it('should make a query and show a success message', () => {
jest.spyOn(controller, 'reload').mockReturnThis();
jest.spyOn(controller.vnApp, 'showSuccess');
$httpBackend.expect('POST', `Tickets/${ticket.id}/recalculateComponents`).respond();
controller.recalculateComponents();
$httpBackend.flush();
expect(controller.reload).toHaveBeenCalled();
expect(controller.vnApp.showSuccess).toHaveBeenCalled();
});
});
describe('showSMSDialog()', () => {
it('should set the destionationFk and destination properties and then call the sms open() method', () => {
controller.$.sms = {open: () => {}};
jest.spyOn(controller.$.sms, 'open');
controller.showSMSDialog();
expect(controller.$.sms.open).toHaveBeenCalledWith();
expect(controller.newSMS).toEqual({
destinationFk: ticket.clientFk,
destination: ticket.address.mobile,
ticketId: 16
});
});
});
});

View File

@ -0,0 +1,24 @@
@import "./effects";
@import "variables";
vn-ticket-descriptor-menu {
& > vn-icon-button[icon="more_vert"] {
display: flex;
min-width: 45px;
height: 45px;
box-sizing: border-box;
align-items: center;
justify-content: center;
}
& > vn-icon-button[icon="more_vert"] {
@extend %clickable;
color: inherit;
& > vn-icon {
padding: 10px;
}
vn-icon {
font-size: 1.75rem;
}
}
}

View File

@ -1,5 +1,5 @@
<vn-crud-model vn-id="model"
url="Tickets/{{$ctrl.$params.id}}/getPossibleStowaways"
url="Tickets/{{$ctrl.ticket.id}}/getPossibleStowaways"
data="possibleStowaways">
</vn-crud-model>
<vn-dialog
@ -8,7 +8,7 @@
on-open="model.refresh()"
message="Stowaways to add">
<tpl-body>
<vn-horizontal class="add-stowaway vn-pa-md">
<vn-horizontal class="add-stowaway">
<vn-data-viewer model="model">
<vn-table model="model" auto-load="false">
<vn-thead>

View File

@ -1,95 +1,9 @@
<vn-descriptor-content
module="ticket"
description="$ctrl.ticket.client.name">
<slot-menu>
<vn-item
ng-click="addTurn.show()"
vn-acl="buyer"
ng-show="$ctrl.isEditable"
vn-acl-action="remove"
name="addTurn"
translate>
Add turn
</vn-item>
<vn-item
ng-click="$ctrl.showDeliveryNote()"
translate>
Show Delivery Note
</vn-item>
<vn-item
ng-click="confirmDeliveryNote.show()"
translate>
Send Delivery Note
</vn-item>
<vn-item
ng-click="deleteConfirmation.show()"
ng-show="$ctrl.isEditable"
name="deleteTicket"
translate>
Delete ticket
</vn-item>
<vn-item
ng-click="restoreConfirmation.show()"
ng-show="$ctrl.canRestoreTicket"
name="restoreTicket"
translate>
Restore ticket
</vn-item>
<vn-item
ng-click="$ctrl.showChangeShipped()"
ng-show="$ctrl.isEditable"
name="changeShipped"
translate>
Change shipped hour
</vn-item>
<vn-item
ng-click="$ctrl.sendPaymentSms()"
translate>
SMS Pending payment
</vn-item>
<vn-item
ng-click="$ctrl.sendImportSms()"
translate>
SMS Minimum import
</vn-item>
<vn-item
ng-click="addStowaway.show()"
ng-show="$ctrl.canShowStowaway"
name="addStowaway"
translate>
Add stowaway
</vn-item>
<vn-item
ng-click="deleteStowaway.show()"
ng-show="$ctrl.shouldShowDeleteStowaway"
name="deleteStowaway"
translate>
Delete stowaway
</vn-item>
<vn-item
ng-click="makeInvoiceConfirmation.show()"
ng-show="$ctrl.isEditable"
vn-acl="invoicing"
vn-acl-action="remove"
name="makeInvoice"
translate>
Make invoice
</vn-item>
<vn-item
ng-click="regenerateInvoiceConfirmation.show()"
ng-show="$ctrl.isInvoiced"
vn-acl="invoicing"
vn-acl-action="remove"
translate>
Regenerate invoice
</vn-item>
<vn-item
ng-click="recalculateComponentsConfirmation.show()"
ng-show="$ctrl.isEditable"
translate>
Recalculate components
</vn-item>
</slot-menu>
<slot-dot-menu>
<vn-ticket-descriptor-menu ticket-id="$ctrl.ticket.id" parent-reload="$ctrl.cardReload()"/>
</slot-dot-menu>
<slot-body>
<div class="attributes">
<vn-label-value
@ -198,121 +112,8 @@
vn-tooltip="Ship stowaways"
tooltip-position="up"
data="$ctrl.ticket.ship"
on-change="$ctrl.goToTicket(value)">
ui-sref="ticket.card.sale({id: value})">
</vn-button-menu>
</div>
</slot-body>
</vn-descriptor-content>
<vn-popup vn-id="addTurn">
<div class="vn-pa-md">
<h5 style="text-align: center" translate>
In which day you want to add the ticket?
</h5>
<vn-tool-bar class="vn-mt-md">
<vn-button
label="Monday"
ng-click="$ctrl.addTurn(0)">
</vn-button>
<vn-button
label="Tuesday"
ng-click="$ctrl.addTurn(1)">
</vn-button>
<vn-button
label="Wednesday"
ng-click="$ctrl.addTurn(2)">
</vn-button>
<vn-button
label="Thursday"
ng-click="$ctrl.addTurn(3)">
</vn-button>
<vn-button
label="Friday"
ng-click="$ctrl.addTurn(4)">
</vn-button>
<vn-button
label="Saturday"
ng-click="$ctrl.addTurn(5)">
</vn-button>
<vn-button
label="Sunday"
ng-click="$ctrl.addTurn(6)">
</vn-button>
</vn-tool-bar>
</div>
</vn-popup>
<vn-confirm
vn-id="deleteConfirmation"
on-accept="$ctrl.deleteTicket()"
question="You are going to delete this ticket"
message="This ticket will be removed from current route! Continue anyway?">
</vn-confirm>
<vn-confirm
vn-id="restoreConfirmation"
on-accept="$ctrl.restoreTicket()"
question="You are going to restore this ticket"
message="Are you sure you want to restore this ticket?">
</vn-confirm>
<vn-confirm
vn-id="deleteStowaway"
on-accept="$ctrl.deleteStowaway()"
question="Delete stowaway"
message="Are you sure you want to delete this stowaway?">
</vn-confirm>
<vn-confirm
vn-id="confirmDialog"
on-accept="$ctrl.returnDialog()"
question="Pickup order"
message="Do you want to send it directly?">
</vn-confirm>
<vn-confirm
vn-id="makeInvoiceConfirmation"
on-accept="$ctrl.makeInvoice()"
question="You are going to invoice this ticket"
message="Are you sure you want to invoice this ticket?">
</vn-confirm>
<vn-confirm
vn-id="regenerateInvoiceConfirmation"
on-accept="$ctrl.regenerateInvoice()"
question="You are going to regenerate the invoice"
message="Are you sure you want to regenerate the invoice?">
</vn-confirm>
<vn-confirm
vn-id="confirmDeliveryNote"
on-accept="$ctrl.sendDeliveryNote()"
question="Are you sure you want to send it?"
message="Send Delivery Note">
</vn-confirm>
<vn-confirm
vn-id="recalculateComponentsConfirmation"
on-accept="$ctrl.recalculateComponents()"
question="Are you sure you want to recalculate the components?"
message="Recalculate components">
</vn-confirm>
<vn-ticket-sms
vn-id="sms"
sms="$ctrl.newSMS">
</vn-ticket-sms>
<vn-add-stowaway
vn-id="addStowaway"
card-reload="$ctrl.cardReload()"
ticket="$ctrl.ticket">
</vn-add-stowaway>
<vn-dialog
vn-id="changeShippedDialog"
on-accept="$ctrl.changeShipped()"
message="Change shipped hour">
<tpl-body>
<vn-input-time
ng-model="$ctrl.newShipped"
label="Shipped hour"
vn-focus>
</vn-input-time>
</tpl-body>
<tpl-buttons>
<input type="button" response="cancel" translate-attr="{value: 'Cancel'}"/>
<button response="accept" translate>Save</button>
</tpl-buttons>
</vn-dialog>
<vn-worker-descriptor-popover
vn-id="workerDescriptor">
</vn-worker-descriptor-popover>
</vn-descriptor-content>

View File

@ -16,185 +16,6 @@ class Controller extends Descriptor {
set entity(value) {
super.entity = value;
this.canStowaway();
this.isTicketEditable();
if (value && this.$params.sendSMS)
this.showSMSDialog();
}
get isInvoiced() {
return this.ticket.refFk !== null;
}
get isTicketModule() {
return this.$state.getCurrentPath()[1].state.name === 'ticket';
}
get shouldShowDeleteStowaway() {
if (!this.ticket || !this.isTicketModule)
return false;
return this.ticket.stowaway || this.ticket.ship;
}
get filter() {
if (this.ticket)
return JSON.stringify({clientFk: this.ticket.clientFk});
return null;
}
get canRestoreTicket() {
const isDeleted = this.ticket.isDeleted;
const now = new Date();
const maxDate = new Date(this.ticket.updated);
maxDate.setHours(maxDate.getHours() + 1);
return isDeleted && (now <= maxDate);
}
isTicketEditable() {
if (!this.ticket) return;
this.$http.get(`Tickets/${this.id}/isEditable`).then(res => {
this.isEditable = res.data;
});
}
showChangeShipped() {
this.newShipped = this.ticket.shipped;
this.$.changeShippedDialog.show();
}
changeShipped() {
let data = {
shipped: this.newShipped
};
return this.$http.post(`Tickets/${this.id}/updateEditableTicket`, data)
.then(() => this.cardReload())
.then(() => this.vnApp.showSuccess(this.$t('Shipped hour updated')));
}
goToTicket(ticketId) {
this.$state.go('ticket.card.sale', {id: ticketId}, {absolute: true});
}
addTurn(day) {
let params = {
ticketFk: this.id,
weekDay: day,
agencyModeFk: this.ticket.agencyModeFk
};
return this.$http.patch(`TicketWeeklies`, params)
.then(() => {
this.$.addTurn.hide();
this.vnApp.showSuccess(this.$t('Data saved!'));
});
}
deleteTicket() {
return this.$http.post(`Tickets/${this.id}/setDeleted`)
.then(() => {
this.$state.go('ticket.index');
this.vnApp.showSuccess(this.$t('Ticket deleted. You can undo this action within the first hour'));
});
}
restoreTicket() {
return this.$http.post(`Tickets/${this.id}/restore`)
.then(() => {
this.vnApp.showSuccess(this.$t('Data saved!'));
this.cardReload();
});
}
canStowaway() {
this.canShowStowaway = false;
if (!this.isTicketModule || !this.ticket) return;
this.$http.get(`Tickets/${this.id}/canHaveStowaway`)
.then(res => this.canShowStowaway = !!res.data);
}
deleteStowaway() {
return this.$http.post(`Tickets/${this.id}/deleteStowaway`)
.then(() => {
this.vnApp.showSuccess(this.$t('Data saved!'));
this.cardReload();
});
}
showDeliveryNote() {
this.vnReport.show('delivery-note', {
recipientId: this.ticket.client.id,
ticketId: this.id,
});
}
sendDeliveryNote() {
return this.vnEmail.send('delivery-note', {
recipientId: this.ticket.client.id,
recipient: this.ticket.client.email,
ticketId: this.id
});
}
sendImportSms() {
const params = {
ticketId: this.id,
created: this.ticket.updated
};
this.showSMSDialog({
message: this.$params.message || this.$t('Minimum is needed', params)
});
}
sendPaymentSms() {
this.showSMSDialog({
message: this.$params.message || this.$t('Make a payment')
});
}
showSMSDialog(params) {
const address = this.ticket.address;
const client = this.ticket.client;
const phone = this.$params.phone
|| address.mobile
|| address.phone
|| client.mobile
|| client.phone;
this.newSMS = Object.assign({
destinationFk: this.ticket.clientFk,
destination: phone
}, params);
this.$.sms.open();
}
makeInvoice() {
return this.$http.post(`Tickets/${this.id}/makeInvoice`)
.then(() => {
this.vnApp.showSuccess(this.$t('Ticket invoiced'));
this.$state.reload();
});
}
regenerateInvoice() {
const invoiceId = this.ticket.invoiceOut.id;
return this.$http.post(`InvoiceOuts/${invoiceId}/regenerate`)
.then(() => {
const snackbarMessage = this.$t(
`Invoice sent for a regeneration, will be available in a few minutes`);
this.vnApp.showSuccess(snackbarMessage);
});
}
recalculateComponents() {
return this.$http.post(`Tickets/${this.id}/recalculateComponents`)
.then(() => this.vnApp.showSuccess(this.$t('Data saved!')));
}
cardReload() {
// Prevents error when not defined
}
loadData() {
@ -243,6 +64,15 @@ class Controller extends Descriptor {
return this.getData(`Tickets/${this.id}`, {filter})
.then(res => this.entity = res.data);
}
cardReload() {
// Prevents error when not defined
}
get filter() {
return this.ticket ?
JSON.stringify({clientFk: this.ticket.clientFk}) : null;
}
}
ngModule.vnComponent('vnTicketDescriptor', {

View File

@ -27,197 +27,17 @@ describe('Ticket Component vnTicketDescriptor', () => {
beforeEach(inject(($componentController, _$httpBackend_, _$state_) => {
$httpBackend = _$httpBackend_;
$httpBackend.whenGET(`Tickets/${ticket.id}/canHaveStowaway`).respond(true);
$httpBackend.expect('GET', `Tickets/${ticket.id}/isEditable`).respond(true);
$state = _$state_;
$state.params.id = 1;
$state.getCurrentPath = () => [null, {state: {name: 'ticket'}}];
controller = $componentController('vnTicketDescriptor', {$element: null}, {ticket});
const $element = angular.element('<vn-ticket-descriptor></vn-ticket-descriptor>');
controller = $componentController('vnTicketDescriptor', {$element});
controller.ticket = ticket;
}));
describe('canRestoreTicket() getter', () => {
it('should return true for a ticket deleted within the last hour', () => {
controller.ticket.isDeleted = true;
controller.ticket.updated = new Date();
const result = controller.canRestoreTicket;
expect(result).toBeTruthy();
});
it('should return false for a ticket deleted more than one hour ago', () => {
const pastHour = new Date();
pastHour.setHours(pastHour.getHours() - 2);
controller.ticket.isDeleted = true;
controller.ticket.updated = pastHour;
const result = controller.canRestoreTicket;
expect(result).toBeFalsy();
});
});
describe('addTurn()', () => {
it('should make a query and call $.addTurn.hide() and vnApp.showSuccess()', () => {
controller.$.addTurn = {hide: () => {}};
jest.spyOn(controller.$.addTurn, 'hide');
$httpBackend.expectPATCH(`TicketWeeklies`).respond();
controller.addTurn(1);
$httpBackend.flush();
expect(controller.$.addTurn.hide).toHaveBeenCalledWith();
});
});
describe('deleteTicket()', () => {
it('should make a query and call vnApp.showSuccess()', () => {
jest.spyOn(controller.$state, 'go').mockReturnValue('ok');
jest.spyOn(controller.vnApp, 'showSuccess');
$httpBackend.expectPOST(`Tickets/${ticket.id}/setDeleted`).respond();
controller.deleteTicket();
$httpBackend.flush();
expect(controller.$state.go).toHaveBeenCalledWith('ticket.index');
expect(controller.vnApp.showSuccess).toHaveBeenCalled();
});
});
describe('restoreTicket()', () => {
it('should make a query to restore the ticket and call vnApp.showSuccess()', () => {
jest.spyOn(controller, 'cardReload');
jest.spyOn(controller.vnApp, 'showSuccess');
$httpBackend.expectPOST(`Tickets/${ticket.id}/restore`).respond();
controller.restoreTicket();
$httpBackend.flush();
expect(controller.cardReload).toHaveBeenCalled();
expect(controller.vnApp.showSuccess).toHaveBeenCalled();
});
});
describe('showDeliveryNote()', () => {
it('should open a new window showing a delivery note PDF document', () => {
jest.spyOn(controller.vnReport, 'show');
window.open = jasmine.createSpy('open');
const params = {
recipientId: ticket.client.id,
ticketId: ticket.id
};
controller.showDeliveryNote();
expect(controller.vnReport.show).toHaveBeenCalledWith('delivery-note', params);
});
});
describe('sendDeliveryNote()', () => {
it('should make a query and call vnApp.showMessage()', () => {
jest.spyOn(controller.vnEmail, 'send');
const params = {
recipient: ticket.client.email,
recipientId: ticket.client.id,
ticketId: ticket.id
};
controller.sendDeliveryNote();
expect(controller.vnEmail.send).toHaveBeenCalledWith('delivery-note', params);
});
});
describe('makeInvoice()', () => {
it('should make a query and call $state.reload() method', () => {
jest.spyOn(controller.$state, 'reload').mockReturnThis();
jest.spyOn(controller.vnApp, 'showSuccess');
$httpBackend.expectPOST(`Tickets/${ticket.id}/makeInvoice`).respond();
controller.makeInvoice();
$httpBackend.flush();
expect(controller.vnApp.showSuccess).toHaveBeenCalled();
expect(controller.$state.reload).toHaveBeenCalledWith();
});
});
describe('regenerateInvoice()', () => {
it('should make a query and show a success snackbar', () => {
jest.spyOn(controller.vnApp, 'showSuccess');
$httpBackend.expectPOST(`InvoiceOuts/${ticket.invoiceOut.id}/regenerate`).respond();
controller.regenerateInvoice();
$httpBackend.flush();
expect(controller.vnApp.showSuccess).toHaveBeenCalled();
});
});
describe('changeShipped()', () => {
it('should make a query and change the shipped hour if the response is accept', () => {
jest.spyOn(controller.vnApp, 'showSuccess');
jest.spyOn(controller, 'cardReload');
$httpBackend.expectPOST(`Tickets/${ticket.id}/updateEditableTicket`).respond();
controller.changeShipped();
$httpBackend.flush();
expect(controller.vnApp.showSuccess).toHaveBeenCalled();
expect(controller.cardReload).toHaveBeenCalled();
});
});
describe('canStowaway()', () => {
it('should make a query and return if the ticket can be stowawayed', () => {
controller.canStowaway();
$httpBackend.flush();
expect(controller.canShowStowaway).toBeTruthy();
});
it('should not make a query if is not on the ticket module', () => {
$state.getCurrentPath = () => [null, {state: {name: 'client'}}];
controller.canStowaway();
expect(controller.canShowStowaway).toBeFalsy();
});
});
describe('recalculateComponents()', () => {
it('should make a query and show a success message', () => {
jest.spyOn(controller.vnApp, 'showSuccess');
$httpBackend.expectPOST(`Tickets/${ticket.id}/recalculateComponents`).respond();
controller.recalculateComponents();
$httpBackend.flush();
expect(controller.vnApp.showSuccess).toHaveBeenCalled();
});
});
describe('showSMSDialog()', () => {
it('should set the destionationFk and destination properties and then call the sms open() method', () => {
controller.$.sms = {open: () => {}};
jest.spyOn(controller.$.sms, 'open');
controller.showSMSDialog();
expect(controller.$.sms.open).toHaveBeenCalledWith();
expect(controller.newSMS).toEqual({
destinationFk: ticket.clientFk,
destination: ticket.address.mobile
});
});
});
describe('loadData()', () => {
it(`should perform a get query to store the ticket data into the controller`, () => {
$httpBackend.when('GET', `Tickets/${ticket.id}/isEditable`).respond();
$httpBackend.expectRoute('GET', `Tickets/${ticket.id}`).respond();
$httpBackend.expect('GET', `Tickets/${ticket.id}`).respond();
controller.loadData();
$httpBackend.flush();
});

View File

@ -7,6 +7,7 @@ import './card';
import './descriptor';
import './descriptor/addStowaway';
import './descriptor-popover';
import './descriptor-menu';
import './create/card';
import './create/index';
import './summary';

View File

@ -25,7 +25,7 @@ class Controller extends Component {
if (this.charactersRemaining() < 0)
throw new Error(`The message it's too long`);
this.$http.post(`Tickets/${this.$params.id}/sendSms`, this.sms).then(res => {
this.$http.post(`Tickets/${this.sms.ticketId}/sendSms`, this.sms).then(res => {
this.vnApp.showMessage(this.$t('SMS sent!'));
if (res.data) this.emit('send', {response: res.data});

View File

@ -12,7 +12,6 @@ describe('Ticket', () => {
let $scope = $rootScope.$new();
const $element = angular.element('<vn-dialog></vn-dialog>');
controller = $componentController('vnTicketSms', {$element, $scope});
controller.$params = {id: 11};
controller.$.message = {
input: {
value: 'My SMS'
@ -22,8 +21,8 @@ describe('Ticket', () => {
describe('onResponse()', () => {
it('should perform a POST query and show a success snackbar', () => {
let params = {destinationFk: 101, destination: 111111111, message: 'My SMS'};
controller.sms = {destinationFk: 101, destination: 111111111, message: 'My SMS'};
let params = {ticketId: 11, destinationFk: 101, destination: 111111111, message: 'My SMS'};
controller.sms = {ticketId: 11, destinationFk: 101, destination: 111111111, message: 'My SMS'};
jest.spyOn(controller.vnApp, 'showMessage');
$httpBackend.expect('POST', `Tickets/11/sendSms`, params).respond(200, params);

View File

@ -1,5 +1,11 @@
<vn-card class="summary">
<h5>
<a ng-if="::$ctrl.summary.id"
translate-attr="{title: 'Go to ticket summary'}"
ui-sref="ticket.card.summary({id: {{::$ctrl.summary.id}}})"
name="goToTicketSummary">
<vn-icon-button icon="open_in_full"></vn-icon-button>
</a>
<span>
Ticket #{{$ctrl.summary.id}} - {{$ctrl.summary.client.name}}
({{$ctrl.summary.client.id}}) - {{$ctrl.summary.nickname}}
@ -12,6 +18,7 @@
ng-click="$ctrl.setOkState()"
vn-tooltip="Change ticket state to 'Ok'">
</vn-button>
<vn-ticket-descriptor-menu ticket-id="$ctrl.summary.id" parent-reload="$ctrl.reload()"/>
</h5>
<vn-horizontal>
<vn-one>

View File

@ -10,7 +10,7 @@ class Controller extends Section {
set ticket(value) {
this._ticket = value;
if (value) this.getSummary();
if (value) this.loadData();
}
get formattedAddress() {
@ -22,13 +22,24 @@ class Controller extends Section {
return `${address.street} - ${address.city} ${province}`;
}
getSummary() {
this.$http.get(`Tickets/${this.ticket.id}/summary`).then(res => {
loadData() {
return this.$http.get(`Tickets/${this.ticket.id}/summary`).then(res => {
if (res && res.data)
this.summary = res.data;
});
}
reload() {
this.loadData()
.then(() => {
if (this.card)
this.card.reload();
// Refresh index model
if (this.model)
this.model.refresh();
});
}
get isEditable() {
try {
return !this.ticket.ticketState.state.alertLevel;
@ -53,17 +64,11 @@ class Controller extends Section {
params.code = 'OK';
this.$http.post(`TicketTrackings/changeState`, params).then(() => {
this.vnApp.showSuccess(this.$t('Data saved!'));
if (this.card)
this.card.reload();
else {
this.getSummary();
// Refresh index model
if (this.model)
this.model.refresh();
}
});
this.$http.post(`TicketTrackings/changeState`, params)
.then(() => this.reload())
.then(() => {
this.vnApp.showSuccess(this.$t('Data saved!'));
});
}
getRequestState(state) {

View File

@ -1,4 +1,5 @@
Address phone: Tel. consignatario
Address mobile: Móv. consignatario
Client phone: Tel. cliente
Client mobile: Móv. cliente
Client mobile: Móv. cliente
Go to ticket summary: Ir a la vista previa del ticket

View File

@ -1,5 +1,12 @@
@import "./effects";
@import "./variables";
vn-ticket-card vn-ticket-summary {
a[name="goToTicketSummary"],
vn-ticket-descriptor-menu {
display: none
}
}
vn-ticket-summary .summary {
max-width: $width-lg;
@ -9,6 +16,26 @@ vn-ticket-summary .summary {
align-items: center;
align-content: center;
& > a > vn-icon-button[icon="open_in_full"] {
display: flex;
min-width: 45px;
height: 45px;
box-sizing: border-box;
align-items: center;
justify-content: center;
}
& > a > vn-icon-button[icon="open_in_full"] {
@extend %clickable;
color: $color-font-dark;
& > vn-icon {
padding: 10px;
}
vn-icon {
font-size: 1.75rem;
}
}
span {
flex: 1;

70
package-lock.json generated
View File

@ -5883,7 +5883,7 @@
},
"util": {
"version": "0.10.3",
"resolved": "https://registry.npmjs.org/util/-/util-0.10.3.tgz",
"resolved": "http://registry.npmjs.org/util/-/util-0.10.3.tgz",
"integrity": "sha1-evsa/lCAUkZInj23/g7TeTNqwPk=",
"dev": true,
"requires": {
@ -6854,7 +6854,7 @@
"base": {
"version": "0.11.2",
"resolved": "https://registry.npmjs.org/base/-/base-0.11.2.tgz",
"integrity": "sha1-e95c7RRbbVUakNuH+DxVi060io8=",
"integrity": "sha512-5T6P4xPgpp0YDFvSWwEZ4NoE3aM4QBQXDzmVbraCkFj8zHM+mba8SyqB5DbZWyR7mYHo6Y7BdQo3MoA4m0TeQg==",
"dev": true,
"requires": {
"cache-base": "^1.0.1",
@ -7366,7 +7366,7 @@
"cache-base": {
"version": "1.0.1",
"resolved": "https://registry.npmjs.org/cache-base/-/cache-base-1.0.1.tgz",
"integrity": "sha1-Cn9GQWgxyLZi7jb+TnxZ129marI=",
"integrity": "sha512-AKcdTnFSWATd5/GCPRxr2ChwIJ85CeyrEyjRHlKxQ56d4XJMGym0uAiKn0xbLOGOl3+yRpOTi484dVCEc5AUzQ==",
"dev": true,
"requires": {
"collection-visit": "^1.0.0",
@ -7574,7 +7574,7 @@
"class-utils": {
"version": "0.3.6",
"resolved": "https://registry.npmjs.org/class-utils/-/class-utils-0.3.6.tgz",
"integrity": "sha1-+TNprouafOAv1B+q0MqDAzGQxGM=",
"integrity": "sha512-qOhPa/Fj7s6TY8H8esGu5QNpMMQxz79h+urzrNYN6mn+9BnxlDGf5QZ+XeCDsxSjPqsSR56XOZOJmpeurnLMeg==",
"dev": true,
"requires": {
"arr-union": "^3.1.0",
@ -10003,7 +10003,7 @@
},
"file-loader": {
"version": "1.1.11",
"resolved": "https://registry.npmjs.org/file-loader/-/file-loader-1.1.11.tgz",
"resolved": "http://registry.npmjs.org/file-loader/-/file-loader-1.1.11.tgz",
"integrity": "sha512-TGR4HU7HUsGg6GCOPJnFk06RhWgEWFLAGWiT6rcD+GRC2keU3s9RGJ+b3Z6/U73jwwNb2gKLJ7YCrp+jvU4ALg==",
"dev": true,
"requires": {
@ -11189,7 +11189,7 @@
"global-modules": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/global-modules/-/global-modules-1.0.0.tgz",
"integrity": "sha1-bXcPDrUjrHgWTXK15xqIdyZcw+o=",
"integrity": "sha512-sKzpEkf11GpOFuw0Zzjzmt4B4UZwjOcG757PPvrfhxcLFbq0wpsgpOqxpxtxFiCG4DtG93M6XRVbF2oGdev7bg==",
"dev": true,
"requires": {
"global-prefix": "^1.0.1",
@ -13376,7 +13376,7 @@
"is-plain-object": {
"version": "2.0.4",
"resolved": "https://registry.npmjs.org/is-plain-object/-/is-plain-object-2.0.4.tgz",
"integrity": "sha1-LBY7P6+xtgbZ0Xko8FwqHDjgdnc=",
"integrity": "sha512-h5PpgXkWitc38BBMYawTYMWJHFZJVnBquFE57xFpjB8pJFiF6gZ+bU+WyI/yqXiFR5mdLsgYNaPe8uao6Uv9Og==",
"dev": true,
"requires": {
"isobject": "^3.0.1"
@ -13666,23 +13666,21 @@
}
},
"jasmine": {
"version": "3.5.0",
"resolved": "https://registry.npmjs.org/jasmine/-/jasmine-3.5.0.tgz",
"integrity": "sha512-DYypSryORqzsGoMazemIHUfMkXM7I7easFaxAvNM3Mr6Xz3Fy36TupTrAOxZWN8MVKEU5xECv22J4tUQf3uBzQ==",
"version": "3.6.3",
"resolved": "https://registry.npmjs.org/jasmine/-/jasmine-3.6.3.tgz",
"integrity": "sha512-Th91zHsbsALWjDUIiU5d/W5zaYQsZFMPTdeNmi8GivZPmAaUAK8MblSG3yQI4VMGC/abF2us7ex60NH1AAIMTA==",
"dev": true,
"requires": {
"glob": "^7.1.4",
"jasmine-core": "~3.5.0"
},
"dependencies": {
"jasmine-core": {
"version": "3.5.0",
"resolved": "https://registry.npmjs.org/jasmine-core/-/jasmine-core-3.5.0.tgz",
"integrity": "sha512-nCeAiw37MIMA9w9IXso7bRaLl+c/ef3wnxsoSAlYrzS+Ot0zTG6nU8G/cIfGkqpkjX2wNaIW9RFG0TwIFnG6bA==",
"dev": true
}
"glob": "^7.1.6",
"jasmine-core": "~3.6.0"
}
},
"jasmine-core": {
"version": "3.6.0",
"resolved": "https://registry.npmjs.org/jasmine-core/-/jasmine-core-3.6.0.tgz",
"integrity": "sha512-8uQYa7zJN8hq9z+g8z1bqCfdC8eoDAeVnM5sfqs7KHv9/ifoJ500m018fpFc7RDaO6SWCLCXwo/wPSNcdYTgcw==",
"dev": true
},
"jasmine-reporters": {
"version": "2.3.2",
"resolved": "https://registry.npmjs.org/jasmine-reporters/-/jasmine-reporters-2.3.2.tgz",
@ -13702,20 +13700,12 @@
}
},
"jasmine-spec-reporter": {
"version": "4.2.1",
"resolved": "https://registry.npmjs.org/jasmine-spec-reporter/-/jasmine-spec-reporter-4.2.1.tgz",
"integrity": "sha512-FZBoZu7VE5nR7Nilzy+Np8KuVIOxF4oXDPDknehCYBDE080EnlPu0afdZNmpGDBRCUBv3mj5qgqCRmk6W/K8vg==",
"version": "6.0.0",
"resolved": "https://registry.npmjs.org/jasmine-spec-reporter/-/jasmine-spec-reporter-6.0.0.tgz",
"integrity": "sha512-MvTOVoMxDZAftQYBApIlSfKnGMzi9cj351nXeqtnZTuXffPlbONN31+Es7F+Ke4okUeQ2xISukt4U1npfzLVrQ==",
"dev": true,
"requires": {
"colors": "1.1.2"
},
"dependencies": {
"colors": {
"version": "1.1.2",
"resolved": "https://registry.npmjs.org/colors/-/colors-1.1.2.tgz",
"integrity": "sha1-FopHAXVran9RoSzgyXv6KMCE7WM=",
"dev": true
}
"colors": "1.4.0"
}
},
"jasmine-terminal-reporter": {
@ -22316,7 +22306,7 @@
"dependencies": {
"jsesc": {
"version": "0.5.0",
"resolved": "https://registry.npmjs.org/jsesc/-/jsesc-0.5.0.tgz",
"resolved": "http://registry.npmjs.org/jsesc/-/jsesc-0.5.0.tgz",
"integrity": "sha1-597mbjXW/Bb3EP6R1c9p9w8IkR0=",
"dev": true
}
@ -22658,7 +22648,7 @@
},
"safe-regex": {
"version": "1.1.0",
"resolved": "https://registry.npmjs.org/safe-regex/-/safe-regex-1.1.0.tgz",
"resolved": "http://registry.npmjs.org/safe-regex/-/safe-regex-1.1.0.tgz",
"integrity": "sha1-QKNmnzsHfR6UPURinhV91IAjvy4=",
"dev": true,
"requires": {
@ -22872,7 +22862,7 @@
"dependencies": {
"source-map": {
"version": "0.4.4",
"resolved": "https://registry.npmjs.org/source-map/-/source-map-0.4.4.tgz",
"resolved": "http://registry.npmjs.org/source-map/-/source-map-0.4.4.tgz",
"integrity": "sha1-66T12pwNyZneaAMti092FzZSA2s=",
"dev": true,
"requires": {
@ -23333,7 +23323,7 @@
"snapdragon-node": {
"version": "2.1.1",
"resolved": "https://registry.npmjs.org/snapdragon-node/-/snapdragon-node-2.1.1.tgz",
"integrity": "sha1-bBdfhv8UvbByRWPo88GwIaKGhTs=",
"integrity": "sha512-O27l4xaMYt/RSQ5TR3vpWCAB5Kb/czIcqUFOM/C4fYcLnbZUc1PkjTAMjof2pBWaSTwOUd6qUHcFGVGj7aIwnw==",
"dev": true,
"requires": {
"define-property": "^1.0.0",
@ -23384,7 +23374,7 @@
"snapdragon-util": {
"version": "3.0.1",
"resolved": "https://registry.npmjs.org/snapdragon-util/-/snapdragon-util-3.0.1.tgz",
"integrity": "sha1-+VZHlIbyrNeXAGk/b3uAXkWrVuI=",
"integrity": "sha512-mbKkMdQKsjX4BAL4bRYTj21edOf8cN7XHdYUJEe+Zn99hVEYcMvKPct1IqNe7+AZPirn8BCDOQBHQZknqmKlZQ==",
"dev": true,
"requires": {
"kind-of": "^3.2.0"
@ -23668,7 +23658,7 @@
"split-string": {
"version": "3.1.0",
"resolved": "https://registry.npmjs.org/split-string/-/split-string-3.1.0.tgz",
"integrity": "sha1-fLCd2jqGWFcFxks5pkZgOGguj+I=",
"integrity": "sha512-NzNVhJDYpwceVVii8/Hu6DKfD2G+NrQHlS/V/qgv763EYudVwEcMQNxd2lh+0VrUByXN/oJkl5grOhYWvQUYiw==",
"dev": true,
"requires": {
"extend-shallow": "^3.0.0"
@ -24970,7 +24960,7 @@
"touch": {
"version": "3.1.0",
"resolved": "https://registry.npmjs.org/touch/-/touch-3.1.0.tgz",
"integrity": "sha1-/jZfX3XsntTlaCXgu3bSSrdK+Ds=",
"integrity": "sha512-WBx8Uy5TLtOSRtIq+M03/sKDrXCLHxwDcquSP2c43Le03/9serjQBIztjRz6FkJez9D/hleyAXTBGLwwZUw9lA==",
"dev": true,
"requires": {
"nopt": "~1.0.10"
@ -26741,7 +26731,7 @@
},
"xmlbuilder": {
"version": "9.0.7",
"resolved": "http://registry.npmjs.org/xmlbuilder/-/xmlbuilder-9.0.7.tgz",
"resolved": "https://registry.npmjs.org/xmlbuilder/-/xmlbuilder-9.0.7.tgz",
"integrity": "sha1-Ey7mPS7FVlxVfiD0wi35rKaGsQ0="
},
"xmlchars": {

View File

@ -73,9 +73,9 @@
"html-loader-jest": "^0.2.1",
"html-webpack-plugin": "^4.0.0-beta.11",
"identity-obj-proxy": "^3.0.0",
"jasmine": "^3.5.0",
"jasmine": "^3.6.3",
"jasmine-reporters": "^2.3.2",
"jasmine-spec-reporter": "^4.2.1",
"jasmine-spec-reporter": "^6.0.0",
"jest": "^26.0.1",
"jest-junit": "^8.0.0",
"json-loader": "^0.5.7",

View File

@ -5,8 +5,8 @@ let env = process.env.NODE_ENV ? process.env.NODE_ENV : 'development';
let configPath = `/etc/salix`;
let config = require('../config/print.json');
let configFiles = [
`${__dirname}/../config/print.local.json`,
`${__dirname}/../config/print.${env}.json`,
`../config/print.local.json`,
`../config/print.${env}.json`,
`${configPath}/print.json`,
`${configPath}/print.local.json`,
`${configPath}/print.${env}.json`