#1537 refactor fixtures
This commit is contained in:
parent
63febf8bd0
commit
560cce7c8c
|
@ -187,7 +187,7 @@ INSERT INTO `vn`.`contactChannel`(`id`, `name`)
|
||||||
INSERT INTO `vn`.`client`(`id`,`name`,`fi`,`socialName`,`contact`,`street`,`city`,`postcode`,`phone`,`mobile`,`fax`,`isRelevant`,`email`,`iban`,`dueDay`,`accountingAccount`,`isEqualizated`,`provinceFk`,`hasToInvoice`,`credit`,`countryFk`,`isActive`,`gestdocFk`,`quality`,`payMethodFk`,`created`,`isToBeMailed`,`contactChannelFk`,`hasSepaVnl`,`hasCoreVnl`,`hasCoreVnh`,`riskCalculated`,`clientTypeFk`,`mailAddress`,`cplusTerIdNifFk`,`hasToInvoiceByAddress`,`isTaxDataChecked`,`isFreezed`,`creditInsurance`,`isCreatedAsServed`,`hasInvoiceSimplified`,`salesPersonFk`,`isVies`,`eypbc`)
|
INSERT INTO `vn`.`client`(`id`,`name`,`fi`,`socialName`,`contact`,`street`,`city`,`postcode`,`phone`,`mobile`,`fax`,`isRelevant`,`email`,`iban`,`dueDay`,`accountingAccount`,`isEqualizated`,`provinceFk`,`hasToInvoice`,`credit`,`countryFk`,`isActive`,`gestdocFk`,`quality`,`payMethodFk`,`created`,`isToBeMailed`,`contactChannelFk`,`hasSepaVnl`,`hasCoreVnl`,`hasCoreVnh`,`riskCalculated`,`clientTypeFk`,`mailAddress`,`cplusTerIdNifFk`,`hasToInvoiceByAddress`,`isTaxDataChecked`,`isFreezed`,`creditInsurance`,`isCreatedAsServed`,`hasInvoiceSimplified`,`salesPersonFk`,`isVies`,`eypbc`)
|
||||||
VALUES
|
VALUES
|
||||||
(101, 'Bruce Wayne', '84612325V', 'Batman', 'Alfred', '1007 Mountain Drive, Gotham', 'Silla', 46460, 1111111111, 222222222, 333333333, 1, 'BruceWayne@mydomain.com', NULL, 0, 1234567890, 0, 1, 1, 300, 1, 1, NULL, 10, 5,CURDATE(), 1, 5, 1, 1, 1, '0000-00-00', 1, NULL, 1, 1, 1, 0, NULL, 0, 0, 18, 0, 1),
|
(101, 'Bruce Wayne', '84612325V', 'Batman', 'Alfred', '1007 Mountain Drive, Gotham', 'Silla', 46460, 1111111111, 222222222, 333333333, 1, 'BruceWayne@mydomain.com', NULL, 0, 1234567890, 0, 1, 1, 300, 1, 1, NULL, 10, 5,CURDATE(), 1, 5, 1, 1, 1, '0000-00-00', 1, NULL, 1, 1, 1, 0, NULL, 0, 0, 18, 0, 1),
|
||||||
(102, 'Petter Parker', '87945234L', 'Spider-Man', 'Aunt May', '20 Ingram Street', 'Silla', 46460, 1111111111, 222222222, 333333333, 1, 'PetterParker@mydomain.com', NULL, 0, 1234567890, 0, 1, 1, 300, 1, 1, NULL, 10, 5,CURDATE(), 1, 5, 1, 1, 1, '0000-00-00', 1, NULL, 1, 1, 0, 0, NULL, 0, 0, 18, 0, 1),
|
(102, 'Petter Parker', '87945234L', 'Spider-Man', 'Aunt May', '20 Ingram Street', 'Silla', 46460, 1111111111, 222222222, 333333333, 1, 'PetterParker@mydomain.com', NULL, 0, 1234567890, 0, 1, 1, 300, 1, 1, NULL, 10, 5,CURDATE(), 1, 5, 1, 1, 1, '0000-00-00', 1, NULL, 1, 1, 1, 0, NULL, 0, 0, 18, 0, 1),
|
||||||
(103, 'Clark Kent', '06815934E', 'Super-Man', 'lois lane', '344 Clinton Street', 'Silla', 46460, 1111111111, 222222222, 333333333, 1, 'ClarkKent@mydomain.com', NULL, 0, 1234567890, 0, 1, 1, 0, 1, 1, NULL, 10, 5,CURDATE(), 1, 5, 1, 1, 1, '0000-00-00', 1, NULL, 1, 1, 1, 0, NULL, 0, 0, 18, 0, 1),
|
(103, 'Clark Kent', '06815934E', 'Super-Man', 'lois lane', '344 Clinton Street', 'Silla', 46460, 1111111111, 222222222, 333333333, 1, 'ClarkKent@mydomain.com', NULL, 0, 1234567890, 0, 1, 1, 0, 1, 1, NULL, 10, 5,CURDATE(), 1, 5, 1, 1, 1, '0000-00-00', 1, NULL, 1, 1, 1, 0, NULL, 0, 0, 18, 0, 1),
|
||||||
(104, 'Tony Stark', '06089160W', 'Iron-Man', 'Pepper Potts', '10880 Malibu Point', 'Silla', 46460, 1111111111, 222222222, 333333333, 1, 'TonyStark@mydomain.com', NULL, 0, 1234567890, 0, 1, 1, 300, 1, 1, NULL, 10, 5,CURDATE(), 1, 5, 1, 1, 1, '0000-00-00', 1, NULL, 1, 1, 1, 0, NULL, 0, 0, 18, 0, 1),
|
(104, 'Tony Stark', '06089160W', 'Iron-Man', 'Pepper Potts', '10880 Malibu Point', 'Silla', 46460, 1111111111, 222222222, 333333333, 1, 'TonyStark@mydomain.com', NULL, 0, 1234567890, 0, 1, 1, 300, 1, 1, NULL, 10, 5,CURDATE(), 1, 5, 1, 1, 1, '0000-00-00', 1, NULL, 1, 1, 1, 0, NULL, 0, 0, 18, 0, 1),
|
||||||
(105, 'Max Eisenhardt', '251628698', 'Magneto', 'Rogue', 'Unknown Whereabouts', 'Silla', 46460, 1111111111, 222222222, 333333333, 1, 'MaxEisenhardt@mydomain.com', NULL, 0, 1234567890, 0, 1, 1, 300, 1, 1, NULL, 10, 5,CURDATE(), 1, 5, 1, 1, 1, '0000-00-00', 1, NULL, 1, 1, 1, 1, NULL, 0, 0, NULL, 0, 1),
|
(105, 'Max Eisenhardt', '251628698', 'Magneto', 'Rogue', 'Unknown Whereabouts', 'Silla', 46460, 1111111111, 222222222, 333333333, 1, 'MaxEisenhardt@mydomain.com', NULL, 0, 1234567890, 0, 1, 1, 300, 1, 1, NULL, 10, 5,CURDATE(), 1, 5, 1, 1, 1, '0000-00-00', 1, NULL, 1, 1, 1, 1, NULL, 0, 0, NULL, 0, 1),
|
||||||
|
@ -439,12 +439,12 @@ INSERT INTO `vn`.`ticket`(`id`, `priority`, `agencyModeFk`,`warehouseFk`,`routeF
|
||||||
(14, 1, 2, 2, 3, CURDATE(), DATE_ADD(CURDATE(), INTERVAL + 1 DAY), 104, 'Malibu Point', 4, NULL, 0, CURDATE()),
|
(14, 1, 2, 2, 3, CURDATE(), DATE_ADD(CURDATE(), INTERVAL + 1 DAY), 104, 'Malibu Point', 4, NULL, 0, CURDATE()),
|
||||||
(15, 1, 3, 3, 3, CURDATE(), DATE_ADD(CURDATE(), INTERVAL + 1 DAY), 105, 'Plastic Cell', 125, NULL, 0, CURDATE()),
|
(15, 1, 3, 3, 3, CURDATE(), DATE_ADD(CURDATE(), INTERVAL + 1 DAY), 105, 'Plastic Cell', 125, NULL, 0, CURDATE()),
|
||||||
(16, 1, 7, 1, 3, CURDATE(), DATE_ADD(CURDATE(), INTERVAL + 1 DAY), 106, 'Many Places', 126, NULL, 0, CURDATE()),
|
(16, 1, 7, 1, 3, CURDATE(), DATE_ADD(CURDATE(), INTERVAL + 1 DAY), 106, 'Many Places', 126, NULL, 0, CURDATE()),
|
||||||
(17, 1, 4, 4, 3, CURDATE(), DATE_ADD(CURDATE(), INTERVAL + 1 DAY), 107, 'Your pocket', 127, NULL, 0, CURDATE()),
|
(17, 1, 7, 1, 3, CURDATE(), DATE_ADD(CURDATE(), INTERVAL + 1 DAY), 106, 'Many Places', 126, NULL, 0, CURDATE()),
|
||||||
(18, 1, 4, 4, 3, CURDATE(), DATE_ADD(CURDATE(), INTERVAL + 1 DAY), 108, 'Cerebro', 128, NULL, 0, CURDATE()),
|
(18, 1, 4, 4, 3, CURDATE(), DATE_ADD(CURDATE(), INTERVAL + 1 DAY), 108, 'Cerebro', 128, NULL, 0, CURDATE()),
|
||||||
(19, 1, 5, 5, 3, CURDATE(), DATE_ADD(CURDATE(), INTERVAL + 1 DAY), 109, 'Somewhere in Thailand', 129, NULL, 0, CURDATE()),
|
(19, 1, 5, 5, 3, CURDATE(), DATE_ADD(CURDATE(), INTERVAL + 1 DAY), 109, 'Somewhere in Thailand', 129, NULL, 1, CURDATE()),
|
||||||
(20, 1, 5, 5, 3, CURDATE(), DATE_ADD(CURDATE(), INTERVAL + 1 DAY), 109, 'Somewhere in Thailand', 129, NULL, 0, CURDATE()),
|
(20, 1, 5, 5, 3, DATE_ADD(CURDATE(), INTERVAL +1 MONTH), DATE_ADD(DATE_ADD(CURDATE(),INTERVAL +1 MONTH), INTERVAL +1 DAY), 109, 'Somewhere in Thailand', 129, NULL, 0, DATE_ADD(CURDATE(), INTERVAL +1 MONTH)),
|
||||||
(21, NULL, 5, 5, NULL, DATE_ADD(CURDATE(), INTERVAL +1 MONTH), DATE_ADD(DATE_ADD(CURDATE(),INTERVAL +1 MONTH), INTERVAL +1 DAY), 109, 'Somewhere in Holland', 102, NULL, 1, DATE_ADD(CURDATE(), INTERVAL +1 MONTH)),
|
(21, NULL, 5, 5, NULL, DATE_ADD(CURDATE(), INTERVAL +1 MONTH), DATE_ADD(DATE_ADD(CURDATE(),INTERVAL +1 MONTH), INTERVAL +1 DAY), 109, 'Somewhere in Holland', 102, NULL, 0, DATE_ADD(CURDATE(), INTERVAL +1 MONTH)),
|
||||||
(22, NULL, 5, 5, NULL, DATE_ADD(CURDATE(), INTERVAL +1 MONTH), DATE_ADD(DATE_ADD(CURDATE(),INTERVAL +1 MONTH), INTERVAL +1 DAY), 109, 'Somewhere in Japan', 103, NULL, 1, DATE_ADD(CURDATE(), INTERVAL +1 MONTH));
|
(22, NULL, 5, 5, NULL, DATE_ADD(CURDATE(), INTERVAL +1 MONTH), DATE_ADD(DATE_ADD(CURDATE(),INTERVAL +1 MONTH), INTERVAL +1 DAY), 109, 'Somewhere in Japan', 103, NULL, 0, DATE_ADD(CURDATE(), INTERVAL +1 MONTH));
|
||||||
ccc
|
ccc
|
||||||
INSERT INTO `vn`.`ticketObservation`(`id`, `ticketFk`, `observationTypeFk`, `description`)
|
INSERT INTO `vn`.`ticketObservation`(`id`, `ticketFk`, `observationTypeFk`, `description`)
|
||||||
VALUES
|
VALUES
|
||||||
|
@ -475,10 +475,10 @@ INSERT INTO `vn`.`ticketTracking`(`id`, `ticketFk`, `stateFk`, `workerFk`, `crea
|
||||||
(16, 16, 3, 19, CURDATE()),
|
(16, 16, 3, 19, CURDATE()),
|
||||||
(17, 17, 3, 19, CURDATE()),
|
(17, 17, 3, 19, CURDATE()),
|
||||||
(18, 18, 3, 19, CURDATE()),
|
(18, 18, 3, 19, CURDATE()),
|
||||||
(19, 19, 3, 19, CURDATE()),
|
(19, 19, 17, 19, CURDATE()),
|
||||||
(20, 20, 3, 19, CURDATE()),
|
(20, 20, 1, 19, DATE_ADD(CURDATE(), INTERVAL +1 MONTH)),
|
||||||
(21, 21, 1, 19, DATE_ADD(CURDATE(), INTERVAL +1 MONTH)),
|
(21, 21, 1, 19, DATE_ADD(CURDATE(), INTERVAL +1 MONTH)),
|
||||||
(22, 22, 17, 19, DATE_ADD(CURDATE(), INTERVAL +1 MONTH));
|
(22, 22, 1, 19, DATE_ADD(CURDATE(), INTERVAL +1 MONTH));
|
||||||
|
|
||||||
INSERT INTO `vn`.`stowaway`(`id`, `shipFk`, `created`)
|
INSERT INTO `vn`.`stowaway`(`id`, `shipFk`, `created`)
|
||||||
VALUES
|
VALUES
|
||||||
|
@ -1095,7 +1095,7 @@ INSERT INTO `hedera`.`order`(`id`, `date_send`, `customer_id`, `delivery_method_
|
||||||
(17, DATE_ADD(CURDATE(), INTERVAL + 1 DAY), 107, 1, 4, 127, 442, NULL, 'SALIX', 0, CURDATE(), CURDATE(), CURDATE()),
|
(17, DATE_ADD(CURDATE(), INTERVAL + 1 DAY), 107, 1, 4, 127, 442, NULL, 'SALIX', 0, CURDATE(), CURDATE(), CURDATE()),
|
||||||
(18, DATE_ADD(CURDATE(), INTERVAL + 1 DAY), 108, 1, 4, 128, 442, NULL, 'SALIX', 0, CURDATE(), CURDATE(), CURDATE()),
|
(18, DATE_ADD(CURDATE(), INTERVAL + 1 DAY), 108, 1, 4, 128, 442, NULL, 'SALIX', 0, CURDATE(), CURDATE(), CURDATE()),
|
||||||
(19, DATE_ADD(CURDATE(), INTERVAL + 1 DAY), 109, 1, 5, 129, 442, NULL, 'SALIX', 0, CURDATE(), CURDATE(), CURDATE()),
|
(19, DATE_ADD(CURDATE(), INTERVAL + 1 DAY), 109, 1, 5, 129, 442, NULL, 'SALIX', 0, CURDATE(), CURDATE(), CURDATE()),
|
||||||
(20, DATE_ADD(CURDATE(), INTERVAL + 1 DAY), 109, 1, 5, 101, 442, NULL, 'SALIX', 0, CURDATE(), CURDATE(), CURDATE()),
|
(20, DATE_ADD(DATE_ADD(CURDATE(),INTERVAL +1 MONTH), INTERVAL +1 DAY), 109, 1, 5, 101, 442, NULL, 'SALIX', 0, DATE_ADD(CURDATE(), INTERVAL +1 MONTH), DATE_ADD(CURDATE(), INTERVAL +1 MONTH), DATE_ADD(CURDATE(), INTERVAL +1 MONTH)),
|
||||||
(21, DATE_ADD(DATE_ADD(CURDATE(),INTERVAL +1 MONTH), INTERVAL +1 DAY), 109, 1, 5, 102, 442, NULL, 'SALIX', 0, DATE_ADD(CURDATE(), INTERVAL +1 MONTH), DATE_ADD(CURDATE(), INTERVAL +1 MONTH), DATE_ADD(CURDATE(), INTERVAL +1 MONTH)),
|
(21, DATE_ADD(DATE_ADD(CURDATE(),INTERVAL +1 MONTH), INTERVAL +1 DAY), 109, 1, 5, 102, 442, NULL, 'SALIX', 0, DATE_ADD(CURDATE(), INTERVAL +1 MONTH), DATE_ADD(CURDATE(), INTERVAL +1 MONTH), DATE_ADD(CURDATE(), INTERVAL +1 MONTH)),
|
||||||
(22, DATE_ADD(DATE_ADD(CURDATE(),INTERVAL +1 MONTH), INTERVAL +1 DAY), 109, 1, 5, 103, 442, NULL, 'SALIX', 0, DATE_ADD(CURDATE(), INTERVAL +1 MONTH), DATE_ADD(CURDATE(), INTERVAL +1 MONTH), DATE_ADD(CURDATE(), INTERVAL +1 MONTH));
|
(22, DATE_ADD(DATE_ADD(CURDATE(),INTERVAL +1 MONTH), INTERVAL +1 DAY), 109, 1, 5, 103, 442, NULL, 'SALIX', 0, DATE_ADD(CURDATE(), INTERVAL +1 MONTH), DATE_ADD(CURDATE(), INTERVAL +1 MONTH), DATE_ADD(CURDATE(), INTERVAL +1 MONTH));
|
||||||
|
|
||||||
|
|
|
@ -270,8 +270,8 @@ let actions = {
|
||||||
|
|
||||||
waitForClassPresent: function(selector, className, done) {
|
waitForClassPresent: function(selector, className, done) {
|
||||||
this.wait(selector)
|
this.wait(selector)
|
||||||
.wait((selector, className) => {
|
.wait((elementSelector, targetClass) => {
|
||||||
if (document.querySelector(selector).classList.contains(className))
|
if (document.querySelector(elementSelector).classList.contains(targetClass))
|
||||||
return true;
|
return true;
|
||||||
}, selector, className)
|
}, selector, className)
|
||||||
.then(done)
|
.then(done)
|
||||||
|
|
|
@ -8,7 +8,7 @@ describe('Client lock verified data path', () => {
|
||||||
beforeAll(() => {
|
beforeAll(() => {
|
||||||
nightmare
|
nightmare
|
||||||
.loginAndModule('salesPerson', 'client')
|
.loginAndModule('salesPerson', 'client')
|
||||||
.accessToSearchResult('Petter Parker')
|
.accessToSearchResult('Hank Pym')
|
||||||
.accessToSection('client.card.fiscalData');
|
.accessToSection('client.card.fiscalData');
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -27,7 +27,7 @@ describe('Client lock verified data path', () => {
|
||||||
const result = await nightmare
|
const result = await nightmare
|
||||||
.wait(selectors.clientFiscalData.socialNameInput)
|
.wait(selectors.clientFiscalData.socialNameInput)
|
||||||
.clearInput(selectors.clientFiscalData.socialNameInput)
|
.clearInput(selectors.clientFiscalData.socialNameInput)
|
||||||
.write(selectors.clientFiscalData.socialNameInput, 'salesPerson was here')
|
.write(selectors.clientFiscalData.socialNameInput, 'Captain America Civil War')
|
||||||
.waitToClick(selectors.clientFiscalData.saveButton)
|
.waitToClick(selectors.clientFiscalData.saveButton)
|
||||||
.waitForLastSnackbar();
|
.waitForLastSnackbar();
|
||||||
|
|
||||||
|
@ -39,55 +39,16 @@ describe('Client lock verified data path', () => {
|
||||||
.reloadSection('client.card.fiscalData')
|
.reloadSection('client.card.fiscalData')
|
||||||
.waitToGetProperty(selectors.clientFiscalData.socialNameInput, 'value');
|
.waitToGetProperty(selectors.clientFiscalData.socialNameInput, 'value');
|
||||||
|
|
||||||
expect(result).toEqual('salesPerson was here');
|
expect(result).toEqual('Captain America Civil War');
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('as administrative', () => {
|
describe('as administrative', () => {
|
||||||
beforeAll(() => {
|
beforeAll(() => {
|
||||||
nightmare
|
nightmare
|
||||||
.waitForLogin('administrative');
|
.loginAndModule('administrative', 'client')
|
||||||
});
|
.accessToSearchResult('Hank Pym')
|
||||||
|
.accessToSection('client.card.fiscalData');
|
||||||
it('should navigate to clients index', async() => {
|
|
||||||
const url = await nightmare
|
|
||||||
.waitToClick(selectors.globalItems.applicationsMenuButton)
|
|
||||||
.wait(selectors.globalItems.applicationsMenuVisible)
|
|
||||||
.waitToClick(selectors.globalItems.clientsButton)
|
|
||||||
.wait(selectors.clientsIndex.createClientButton)
|
|
||||||
.parsedUrl();
|
|
||||||
|
|
||||||
expect(url.hash).toEqual('#!/client/index');
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should search again for the user Petter Parker', async() => {
|
|
||||||
const resultCount = await nightmare
|
|
||||||
.write(selectors.clientsIndex.searchClientInput, 'Petter Parker')
|
|
||||||
.waitToClick(selectors.clientsIndex.searchButton)
|
|
||||||
.waitForNumberOfElements(selectors.clientsIndex.searchResult, 1)
|
|
||||||
.countElement(selectors.clientsIndex.searchResult);
|
|
||||||
|
|
||||||
expect(resultCount).toEqual(1);
|
|
||||||
});
|
|
||||||
|
|
||||||
it(`should click on the search result to access to the Petter Parkers fiscal data`, async() => {
|
|
||||||
const url = await nightmare
|
|
||||||
.waitForTextInElement(selectors.clientsIndex.searchResult, 'Petter Parker')
|
|
||||||
.waitToClick(selectors.clientsIndex.searchResult)
|
|
||||||
.waitToClick(selectors.clientFiscalData.fiscalDataButton)
|
|
||||||
.waitForURL('fiscal-data')
|
|
||||||
.parsedUrl();
|
|
||||||
|
|
||||||
expect(url.hash).toContain('fiscal-data');
|
|
||||||
});
|
|
||||||
|
|
||||||
it(`should click on the fiscal data button`, async() => {
|
|
||||||
const url = await nightmare
|
|
||||||
.waitToClick(selectors.clientFiscalData.fiscalDataButton)
|
|
||||||
.waitForURL('fiscal-data')
|
|
||||||
.parsedUrl();
|
|
||||||
|
|
||||||
expect(url.hash).toContain('fiscal-data');
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should confirm verified data button is enabled for administrative', async() => {
|
it('should confirm verified data button is enabled for administrative', async() => {
|
||||||
|
@ -110,18 +71,18 @@ describe('Client lock verified data path', () => {
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should confirm Verified data checkbox is checked', async() => {
|
it('should confirm Verified data checkbox is checked', async() => {
|
||||||
const result = await nightmare
|
const isChecked = await nightmare
|
||||||
.reloadSection('client.card.fiscalData')
|
.reloadSection('client.card.fiscalData')
|
||||||
.checkboxState(selectors.clientFiscalData.verifiedDataCheckbox);
|
.checkboxState(selectors.clientFiscalData.verifiedDataCheckbox);
|
||||||
|
|
||||||
expect(result).toBe('checked');
|
expect(isChecked).toEqual('checked');
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should again edit the social name', async() => {
|
it('should again edit the social name', async() => {
|
||||||
const result = await nightmare
|
const result = await nightmare
|
||||||
.wait(selectors.clientFiscalData.socialNameInput)
|
.wait(selectors.clientFiscalData.socialNameInput)
|
||||||
.clearInput(selectors.clientFiscalData.socialNameInput)
|
.clearInput(selectors.clientFiscalData.socialNameInput)
|
||||||
.write(selectors.clientFiscalData.socialNameInput, 'administrative was here')
|
.write(selectors.clientFiscalData.socialNameInput, 'Ant-Man and the Wasp')
|
||||||
.waitToClick(selectors.clientFiscalData.saveButton)
|
.waitToClick(selectors.clientFiscalData.saveButton)
|
||||||
.waitForLastSnackbar();
|
.waitForLastSnackbar();
|
||||||
|
|
||||||
|
@ -133,71 +94,32 @@ describe('Client lock verified data path', () => {
|
||||||
.reloadSection('client.card.fiscalData')
|
.reloadSection('client.card.fiscalData')
|
||||||
.waitToGetProperty(selectors.clientFiscalData.socialNameInput, 'value');
|
.waitToGetProperty(selectors.clientFiscalData.socialNameInput, 'value');
|
||||||
|
|
||||||
expect(result).toEqual('administrative was here');
|
expect(result).toEqual('Ant-Man and the Wasp');
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('as salesPerson second run', () => {
|
describe('as salesPerson second run', () => {
|
||||||
beforeAll(() => {
|
beforeAll(() => {
|
||||||
nightmare
|
nightmare
|
||||||
.waitForLogin('salesPerson');
|
.loginAndModule('salesPerson', 'client')
|
||||||
});
|
.accessToSearchResult('Hank Pym')
|
||||||
|
.accessToSection('client.card.fiscalData');
|
||||||
it('should again click on the Clients button of the top bar menu', async() => {
|
|
||||||
const url = await nightmare
|
|
||||||
.waitToClick(selectors.globalItems.applicationsMenuButton)
|
|
||||||
.wait(selectors.globalItems.applicationsMenuVisible)
|
|
||||||
.waitToClick(selectors.globalItems.clientsButton)
|
|
||||||
.wait(selectors.clientsIndex.createClientButton)
|
|
||||||
.parsedUrl();
|
|
||||||
|
|
||||||
expect(url.hash).toEqual('#!/client/index');
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should again search for the user Petter Parker', async() => {
|
|
||||||
const resultCount = await nightmare
|
|
||||||
.write(selectors.clientsIndex.searchClientInput, 'Petter Parker')
|
|
||||||
.waitToClick(selectors.clientsIndex.searchButton)
|
|
||||||
.waitForNumberOfElements(selectors.clientsIndex.searchResult, 1)
|
|
||||||
.countElement(selectors.clientsIndex.searchResult);
|
|
||||||
|
|
||||||
expect(resultCount).toEqual(1);
|
|
||||||
});
|
|
||||||
|
|
||||||
it(`should click on the search result to access to the client's fiscal data`, async() => {
|
|
||||||
const url = await nightmare
|
|
||||||
.waitForTextInElement(selectors.clientsIndex.searchResult, 'Petter Parker')
|
|
||||||
.waitToClick(selectors.clientsIndex.searchResult)
|
|
||||||
.waitToClick(selectors.clientFiscalData.fiscalDataButton)
|
|
||||||
.waitForURL('fiscal-data')
|
|
||||||
.parsedUrl();
|
|
||||||
|
|
||||||
expect(url.hash).toContain('fiscal-data');
|
|
||||||
});
|
|
||||||
|
|
||||||
it(`should click on the fiscal data button to start editing`, async() => {
|
|
||||||
const url = await nightmare
|
|
||||||
.waitToClick(selectors.clientFiscalData.fiscalDataButton)
|
|
||||||
.waitForURL('fiscal-data')
|
|
||||||
.parsedUrl();
|
|
||||||
|
|
||||||
expect(url.hash).toContain('fiscal-data');
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should confirm verified data button is disabled once again for salesPerson', async() => {
|
it('should confirm verified data button is disabled once again for salesPerson', async() => {
|
||||||
const result = await nightmare
|
const isChecked = await nightmare
|
||||||
.wait(selectors.clientFiscalData.verifiedDataCheckbox)
|
.waitForClassPresent(selectors.clientFiscalData.verifiedDataCheckbox, 'md-checked')
|
||||||
.evaluate(selector => {
|
.evaluate(selector => {
|
||||||
return document.querySelector(selector).getAttribute('disabled');
|
return document.querySelector(selector).getAttribute('disabled');
|
||||||
}, selectors.clientFiscalData.verifiedDataCheckbox);
|
}, selectors.clientFiscalData.verifiedDataCheckbox);
|
||||||
|
|
||||||
expect(result).toBeTruthy();
|
expect(isChecked).toBeTruthy();
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should not be able to save change throwing a verified data error', async() => {
|
it('should not be able to save change throwing a verified data error', async() => {
|
||||||
const result = await nightmare
|
const result = await nightmare
|
||||||
.clearInput(selectors.clientFiscalData.socialNameInput)
|
.clearInput(selectors.clientFiscalData.socialNameInput)
|
||||||
.write(selectors.clientFiscalData.socialNameInput, 'salesPerson was here')
|
.write(selectors.clientFiscalData.socialNameInput, 'This wont happen')
|
||||||
.waitToClick(selectors.clientFiscalData.saveButton)
|
.waitToClick(selectors.clientFiscalData.saveButton)
|
||||||
.waitForSnackbar();
|
.waitForSnackbar();
|
||||||
|
|
||||||
|
@ -209,64 +131,25 @@ describe('Client lock verified data path', () => {
|
||||||
beforeAll(() => {
|
beforeAll(() => {
|
||||||
nightmare
|
nightmare
|
||||||
.forceReloadSection('client.card.fiscalData')
|
.forceReloadSection('client.card.fiscalData')
|
||||||
.waitForLogin('salesAssistant');
|
.loginAndModule('salesAssistant', 'client')
|
||||||
});
|
.accessToSearchResult('Hank Pym')
|
||||||
|
.accessToSection('client.card.fiscalData');
|
||||||
it('should now navigate to clients index', async() => {
|
|
||||||
const url = await nightmare
|
|
||||||
.waitToClick(selectors.globalItems.applicationsMenuButton)
|
|
||||||
.wait(selectors.globalItems.applicationsMenuVisible)
|
|
||||||
.waitToClick(selectors.globalItems.clientsButton)
|
|
||||||
.wait(selectors.clientsIndex.createClientButton)
|
|
||||||
.parsedUrl();
|
|
||||||
|
|
||||||
expect(url.hash).toEqual('#!/client/index');
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should now search again for the user Petter Parker', async() => {
|
|
||||||
const resultCount = await nightmare
|
|
||||||
.write(selectors.clientsIndex.searchClientInput, 'Petter Parker')
|
|
||||||
.waitToClick(selectors.clientsIndex.searchButton)
|
|
||||||
.waitForNumberOfElements(selectors.clientsIndex.searchResult, 1)
|
|
||||||
.countElement(selectors.clientsIndex.searchResult);
|
|
||||||
|
|
||||||
expect(resultCount).toEqual(1);
|
|
||||||
});
|
|
||||||
|
|
||||||
it(`should click on the search result to access to the Petter Parkers fiscal data`, async() => {
|
|
||||||
const url = await nightmare
|
|
||||||
.waitForTextInElement(selectors.clientsIndex.searchResult, 'Petter Parker')
|
|
||||||
.waitToClick(selectors.clientsIndex.searchResult)
|
|
||||||
.waitToClick(selectors.clientFiscalData.fiscalDataButton)
|
|
||||||
.waitForURL('fiscal-data')
|
|
||||||
.parsedUrl();
|
|
||||||
|
|
||||||
expect(url.hash).toContain('fiscal-data');
|
|
||||||
});
|
|
||||||
|
|
||||||
it(`should click on the fiscal data button`, async() => {
|
|
||||||
const url = await nightmare
|
|
||||||
.waitToClick(selectors.clientFiscalData.fiscalDataButton)
|
|
||||||
.waitForURL('fiscal-data')
|
|
||||||
.parsedUrl();
|
|
||||||
|
|
||||||
expect(url.hash).toContain('fiscal-data');
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should confirm verified data button is enabled for salesAssistant', async() => {
|
it('should confirm verified data button is enabled for salesAssistant', async() => {
|
||||||
const result = await nightmare
|
const isDisabled = await nightmare
|
||||||
.wait(selectors.clientFiscalData.verifiedDataCheckbox)
|
.waitForClassPresent(selectors.clientFiscalData.verifiedDataCheckbox, 'md-checked')
|
||||||
.evaluate(selector => {
|
.evaluate(selector => {
|
||||||
return document.querySelector(selector).getAttribute('disabled');
|
return document.querySelector(selector).getAttribute('aria-disabled');
|
||||||
}, selectors.clientFiscalData.verifiedDataCheckbox);
|
}, selectors.clientFiscalData.verifiedDataCheckbox);
|
||||||
|
|
||||||
expect(result).toBeFalsy();
|
expect(isDisabled).toEqual('false');
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should now edit the social name', async() => {
|
it('should now edit the social name', async() => {
|
||||||
const result = await nightmare
|
const result = await nightmare
|
||||||
.clearInput(selectors.clientFiscalData.socialNameInput)
|
.clearInput(selectors.clientFiscalData.socialNameInput)
|
||||||
.write(selectors.clientFiscalData.socialNameInput, 'salesAssistant was here')
|
.write(selectors.clientFiscalData.socialNameInput, 'new social name edition')
|
||||||
.waitToClick(selectors.clientFiscalData.saveButton)
|
.waitToClick(selectors.clientFiscalData.saveButton)
|
||||||
.waitForLastSnackbar();
|
.waitForLastSnackbar();
|
||||||
|
|
||||||
|
@ -278,65 +161,26 @@ describe('Client lock verified data path', () => {
|
||||||
.reloadSection('client.card.fiscalData')
|
.reloadSection('client.card.fiscalData')
|
||||||
.waitToGetProperty(selectors.clientFiscalData.socialNameInput, 'value');
|
.waitToGetProperty(selectors.clientFiscalData.socialNameInput, 'value');
|
||||||
|
|
||||||
expect(result).toEqual('salesAssistant was here');
|
expect(result).toEqual('new social name edition');
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('as salesPerson third run', () => {
|
describe('as salesPerson third run', () => {
|
||||||
beforeAll(() => {
|
beforeAll(() => {
|
||||||
nightmare
|
nightmare
|
||||||
.waitForLogin('salesPerson');
|
.loginAndModule('salesPerson', 'client')
|
||||||
});
|
.accessToSearchResult('Hank Pym')
|
||||||
|
.accessToSection('client.card.fiscalData');
|
||||||
it('should now click on the Clients button of the top bar menu', async() => {
|
|
||||||
const url = await nightmare
|
|
||||||
.waitToClick(selectors.globalItems.applicationsMenuButton)
|
|
||||||
.wait(selectors.globalItems.applicationsMenuVisible)
|
|
||||||
.waitToClick(selectors.globalItems.clientsButton)
|
|
||||||
.wait(selectors.clientsIndex.createClientButton)
|
|
||||||
.parsedUrl();
|
|
||||||
|
|
||||||
expect(url.hash).toEqual('#!/client/index');
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should once again search for the user Petter Parker', async() => {
|
|
||||||
const resultCount = await nightmare
|
|
||||||
.write(selectors.clientsIndex.searchClientInput, 'Petter Parker')
|
|
||||||
.waitToClick(selectors.clientsIndex.searchButton)
|
|
||||||
.waitForNumberOfElements(selectors.clientsIndex.searchResult, 1)
|
|
||||||
.countElement(selectors.clientsIndex.searchResult);
|
|
||||||
|
|
||||||
expect(resultCount).toEqual(1);
|
|
||||||
});
|
|
||||||
|
|
||||||
it(`should click on the search result to access to the client's fiscal data`, async() => {
|
|
||||||
const url = await nightmare
|
|
||||||
.waitForTextInElement(selectors.clientsIndex.searchResult, 'Petter Parker')
|
|
||||||
.waitToClick(selectors.clientsIndex.searchResult)
|
|
||||||
.waitToClick(selectors.clientFiscalData.fiscalDataButton)
|
|
||||||
.waitForURL('fiscal-data')
|
|
||||||
.parsedUrl();
|
|
||||||
|
|
||||||
expect(url.hash).toContain('fiscal-data');
|
|
||||||
});
|
|
||||||
|
|
||||||
it(`should click on the fiscal data button to start editing`, async() => {
|
|
||||||
const url = await nightmare
|
|
||||||
.waitToClick(selectors.clientFiscalData.fiscalDataButton)
|
|
||||||
.waitForURL('fiscal-data')
|
|
||||||
.parsedUrl();
|
|
||||||
|
|
||||||
expect(url.hash).toContain('fiscal-data');
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should confirm verified data button is enabled once again', async() => {
|
it('should confirm verified data button is enabled once again', async() => {
|
||||||
const result = await nightmare
|
const isChecked = await nightmare
|
||||||
.wait(selectors.clientFiscalData.verifiedDataCheckbox)
|
.waitForClassPresent(selectors.clientFiscalData.verifiedDataCheckbox, 'md-checked')
|
||||||
.evaluate(selector => {
|
.evaluate(selector => {
|
||||||
return document.querySelector(selector).getAttribute('disabled');
|
return document.querySelector(selector).getAttribute('disabled');
|
||||||
}, selectors.clientFiscalData.verifiedDataCheckbox);
|
}, selectors.clientFiscalData.verifiedDataCheckbox);
|
||||||
|
|
||||||
expect(result).toBeTruthy();
|
expect(isChecked).toBeTruthy();
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should confirm the form is enabled for salesPerson', async() => {
|
it('should confirm the form is enabled for salesPerson', async() => {
|
||||||
|
|
|
@ -12,7 +12,7 @@ describe('Ticket descriptor path', () => {
|
||||||
describe('Delete ticket', () => {
|
describe('Delete ticket', () => {
|
||||||
it('should search for an specific ticket', async() => {
|
it('should search for an specific ticket', async() => {
|
||||||
const result = await nightmare
|
const result = await nightmare
|
||||||
.write(selectors.ticketsIndex.searchTicketInput, 17)
|
.write(selectors.ticketsIndex.searchTicketInput, 18)
|
||||||
.waitToClick(selectors.ticketsIndex.searchButton)
|
.waitToClick(selectors.ticketsIndex.searchButton)
|
||||||
.waitForNumberOfElements(selectors.ticketsIndex.searchResult, 1)
|
.waitForNumberOfElements(selectors.ticketsIndex.searchResult, 1)
|
||||||
.countElement(selectors.ticketsIndex.searchResult);
|
.countElement(selectors.ticketsIndex.searchResult);
|
||||||
|
@ -22,7 +22,7 @@ describe('Ticket descriptor path', () => {
|
||||||
|
|
||||||
it(`should click on the search result to access to the ticket summary`, async() => {
|
it(`should click on the search result to access to the ticket summary`, async() => {
|
||||||
const url = await nightmare
|
const url = await nightmare
|
||||||
.waitForTextInElement(selectors.ticketsIndex.searchResult, 'Your pocket')
|
.waitForTextInElement(selectors.ticketsIndex.searchResult, 'Cerebro')
|
||||||
.waitToClick(selectors.ticketsIndex.searchResult)
|
.waitToClick(selectors.ticketsIndex.searchResult)
|
||||||
.waitForURL('/summary')
|
.waitForURL('/summary')
|
||||||
.parsedUrl();
|
.parsedUrl();
|
||||||
|
@ -49,7 +49,7 @@ describe('Ticket descriptor path', () => {
|
||||||
|
|
||||||
it(`should search for the deleted ticket and check it's date`, async() => {
|
it(`should search for the deleted ticket and check it's date`, async() => {
|
||||||
const result = await nightmare
|
const result = await nightmare
|
||||||
.write(selectors.ticketsIndex.searchTicketInput, 17)
|
.write(selectors.ticketsIndex.searchTicketInput, 18)
|
||||||
.waitToClick(selectors.ticketsIndex.searchButton)
|
.waitToClick(selectors.ticketsIndex.searchButton)
|
||||||
.waitForNumberOfElements(selectors.ticketsIndex.searchResult, 1)
|
.waitForNumberOfElements(selectors.ticketsIndex.searchResult, 1)
|
||||||
.wait(selectors.ticketsIndex.searchResultDate)
|
.wait(selectors.ticketsIndex.searchResultDate)
|
||||||
|
@ -63,7 +63,7 @@ describe('Ticket descriptor path', () => {
|
||||||
it('should search for a ticket', async() => {
|
it('should search for a ticket', async() => {
|
||||||
const result = await nightmare
|
const result = await nightmare
|
||||||
.clearInput(selectors.ticketsIndex.searchTicketInput)
|
.clearInput(selectors.ticketsIndex.searchTicketInput)
|
||||||
.write(selectors.ticketsIndex.searchTicketInput, 20)
|
.write(selectors.ticketsIndex.searchTicketInput, 16)
|
||||||
.waitToClick(selectors.ticketsIndex.searchButton)
|
.waitToClick(selectors.ticketsIndex.searchButton)
|
||||||
.waitForNumberOfElements(selectors.ticketsIndex.searchResult, 1)
|
.waitForNumberOfElements(selectors.ticketsIndex.searchResult, 1)
|
||||||
.countElement(selectors.ticketsIndex.searchResult);
|
.countElement(selectors.ticketsIndex.searchResult);
|
||||||
|
@ -73,7 +73,7 @@ describe('Ticket descriptor path', () => {
|
||||||
|
|
||||||
it(`should now click on the search result to access to the ticket summary`, async() => {
|
it(`should now click on the search result to access to the ticket summary`, async() => {
|
||||||
const url = await nightmare
|
const url = await nightmare
|
||||||
.waitForTextInElement(selectors.ticketsIndex.searchResult, 'Somewhere in Thailand')
|
.waitForTextInElement(selectors.ticketsIndex.searchResult, 'Many Places')
|
||||||
.waitToClick(selectors.ticketsIndex.searchResult)
|
.waitToClick(selectors.ticketsIndex.searchResult)
|
||||||
.waitForURL('/summary')
|
.waitForURL('/summary')
|
||||||
.parsedUrl();
|
.parsedUrl();
|
||||||
|
@ -104,29 +104,29 @@ describe('Ticket descriptor path', () => {
|
||||||
const url = await nightmare
|
const url = await nightmare
|
||||||
.waitToClick(selectors.ticketDescriptor.closeStowawayDialog)
|
.waitToClick(selectors.ticketDescriptor.closeStowawayDialog)
|
||||||
.waitToClick(selectors.ticketDescriptor.shipButton)
|
.waitToClick(selectors.ticketDescriptor.shipButton)
|
||||||
.waitForURL('#!/ticket/19/summary')
|
.waitForURL('#!/ticket/17/summary')
|
||||||
.parsedUrl();
|
.parsedUrl();
|
||||||
|
|
||||||
expect(url.hash).toContain('#!/ticket/19/summary');
|
expect(url.hash).toContain('#!/ticket/17/summary');
|
||||||
});
|
});
|
||||||
|
|
||||||
it(`should navigate to the ship ticket using the descriptors ship button`, async() => {
|
it(`should navigate to the ship ticket using the descriptors ship button`, async() => {
|
||||||
const url = await nightmare
|
const url = await nightmare
|
||||||
.waitToClick(selectors.ticketDescriptor.shipButton)
|
.waitToClick(selectors.ticketDescriptor.shipButton)
|
||||||
.waitForURL('#!/ticket/20/summary')
|
.waitForURL('#!/ticket/16/summary')
|
||||||
.parsedUrl();
|
.parsedUrl();
|
||||||
|
|
||||||
expect(url.hash).toContain('#!/ticket/20/summary');
|
expect(url.hash).toContain('#!/ticket/16/summary');
|
||||||
});
|
});
|
||||||
|
|
||||||
it(`should navigate back to the added ticket using the descriptors ship button`, async() => {
|
it(`should navigate back to the added ticket using the descriptors ship button`, async() => {
|
||||||
const url = await nightmare
|
const url = await nightmare
|
||||||
.waitToClick(selectors.ticketDescriptor.closeStowawayDialog)
|
.waitToClick(selectors.ticketDescriptor.closeStowawayDialog)
|
||||||
.waitToClick(selectors.ticketDescriptor.shipButton)
|
.waitToClick(selectors.ticketDescriptor.shipButton)
|
||||||
.waitForURL('#!/ticket/19/summary')
|
.waitForURL('#!/ticket/17/summary')
|
||||||
.parsedUrl();
|
.parsedUrl();
|
||||||
|
|
||||||
expect(url.hash).toContain('#!/ticket/19/summary');
|
expect(url.hash).toContain('#!/ticket/17/summary');
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should delete the stowaway', async() => {
|
it('should delete the stowaway', async() => {
|
||||||
|
@ -149,7 +149,7 @@ describe('Ticket descriptor path', () => {
|
||||||
|
|
||||||
describe('Make invoice', () => {
|
describe('Make invoice', () => {
|
||||||
it('should login as adminBoss role then search for a ticket', async() => {
|
it('should login as adminBoss role then search for a ticket', async() => {
|
||||||
const invoiceableTicketId = 18;
|
const invoiceableTicketId = 14;
|
||||||
|
|
||||||
const url = await nightmare
|
const url = await nightmare
|
||||||
.loginAndModule('adminBoss', 'ticket')
|
.loginAndModule('adminBoss', 'ticket')
|
||||||
|
|
|
@ -7,6 +7,6 @@ describe('Client get', () => {
|
||||||
|
|
||||||
expect(result.id).toEqual(101);
|
expect(result.id).toEqual(101);
|
||||||
expect(result.name).toEqual('Bruce Wayne');
|
expect(result.name).toEqual('Bruce Wayne');
|
||||||
expect(result.debt).toEqual(-111.86);
|
expect(result.debt).toEqual(-101.85);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
|
@ -4,7 +4,7 @@ describe('client getDebt()', () => {
|
||||||
it('should return the client debt', async() => {
|
it('should return the client debt', async() => {
|
||||||
let result = await app.models.Client.getDebt(101);
|
let result = await app.models.Client.getDebt(101);
|
||||||
|
|
||||||
expect(result.debt).toEqual(-111.86);
|
expect(result.debt).toEqual(-101.85);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
@ -17,7 +17,7 @@ describe('client summary()', () => {
|
||||||
it('should return a summary object containing debt', async() => {
|
it('should return a summary object containing debt', async() => {
|
||||||
let result = await app.models.Client.summary(101);
|
let result = await app.models.Client.summary(101);
|
||||||
|
|
||||||
expect(result.debt.debt).toEqual(-111.86);
|
expect(result.debt.debt).toEqual(-101.85);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should return a summary object containing averageInvoiced', async() => {
|
it('should return a summary object containing averageInvoiced', async() => {
|
||||||
|
|
|
@ -2,37 +2,35 @@ const app = require('vn-loopback/server/server');
|
||||||
|
|
||||||
describe('invoiceOut delete()', () => {
|
describe('invoiceOut delete()', () => {
|
||||||
const invoiceOutId = 2;
|
const invoiceOutId = 2;
|
||||||
let OriginalInvoiceOut;
|
let originalInvoiceOut;
|
||||||
let OriginalTickets;
|
let originalTicket;
|
||||||
|
|
||||||
afterAll(async done => {
|
afterAll(async done => {
|
||||||
const newInvoiceOut = await app.models.InvoiceOut.create(OriginalInvoiceOut);
|
const newInvoiceOut = await app.models.InvoiceOut.create(originalInvoiceOut);
|
||||||
await newInvoiceOut.updateAttribute('ref', OriginalInvoiceOut.ref);
|
await newInvoiceOut.updateAttribute('ref', originalInvoiceOut.ref);
|
||||||
|
|
||||||
const promises = [];
|
const promises = [];
|
||||||
OriginalTickets.forEach(ticket => {
|
promises.push(originalTicket.updateAttribute('refFk', newInvoiceOut.ref));
|
||||||
promises.push(ticket.updateAttribute('refFk', newInvoiceOut.ref));
|
|
||||||
});
|
|
||||||
Promise.all(promises);
|
Promise.all(promises);
|
||||||
|
|
||||||
done();
|
done();
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should check that there is two tickets from the invoice id 2', async() => {
|
it('should check that there is one ticket in the target invoiceOut', async() => {
|
||||||
const invoiceOut = await app.models.InvoiceOut.findById(invoiceOutId);
|
const invoiceOut = await app.models.InvoiceOut.findById(invoiceOutId);
|
||||||
const tickets = await app.models.Ticket.find({where: {refFk: invoiceOut.ref}});
|
const tickets = await app.models.Ticket.find({where: {refFk: invoiceOut.ref}});
|
||||||
|
|
||||||
expect(tickets.length).toEqual(2);
|
expect(tickets.length).toEqual(1);
|
||||||
expect(tickets[0].id).toEqual(2);
|
expect(tickets[0].id).toEqual(3);
|
||||||
});
|
});
|
||||||
|
|
||||||
it(`should check the two tickets from the invoice id 2 that are not invoiced`, async() => {
|
it(`should delete the target invoiceOut then check the ticket doesn't have a refFk anymore`, async() => {
|
||||||
OriginalInvoiceOut = await app.models.InvoiceOut.findById(invoiceOutId);
|
originalInvoiceOut = await app.models.InvoiceOut.findById(invoiceOutId);
|
||||||
await app.models.InvoiceOut.delete(invoiceOutId);
|
await app.models.InvoiceOut.delete(invoiceOutId);
|
||||||
OriginalTickets = await app.models.Ticket.find({where: {id: {inq: [2, 3]}}});
|
originalTicket = await app.models.Ticket.findById(3);
|
||||||
const invoiceOut = await app.models.InvoiceOut.findById(invoiceOutId);
|
const deletedInvoiceOut = await app.models.InvoiceOut.findById(invoiceOutId);
|
||||||
|
|
||||||
expect(OriginalTickets[0].refFk).toBeNull();
|
expect(deletedInvoiceOut).toBeNull();
|
||||||
expect(OriginalTickets[1].refFk).toBeNull();
|
expect(originalTicket.refFk).toBeNull();
|
||||||
expect(invoiceOut).toBeNull();
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
|
@ -58,8 +58,8 @@ describe('InvoiceOut filter()', () => {
|
||||||
it('should return the invoice out matching min and max', async() => {
|
it('should return the invoice out matching min and max', async() => {
|
||||||
let ctx = {
|
let ctx = {
|
||||||
args: {
|
args: {
|
||||||
min: 20.10,
|
min: 100,
|
||||||
max: 200,
|
max: 300,
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -8,26 +8,26 @@ describe('invoiceOut summary()', () => {
|
||||||
});
|
});
|
||||||
|
|
||||||
it(`should return a summary object containing data from it's tickets`, async() => {
|
it(`should return a summary object containing data from it's tickets`, async() => {
|
||||||
const result = await app.models.InvoiceOut.summary(1);
|
const summary = await app.models.InvoiceOut.summary(1);
|
||||||
const tickets = result.invoiceOut.tickets();
|
const tickets = summary.invoiceOut.tickets();
|
||||||
|
|
||||||
expect(result.invoiceOut.ref).toEqual('T1111111');
|
expect(summary.invoiceOut.ref).toEqual('T1111111');
|
||||||
expect(tickets.length).toEqual(1);
|
expect(tickets.length).toEqual(2);
|
||||||
});
|
});
|
||||||
|
|
||||||
it(`should return a summary object containing it's supplier country`, async() => {
|
it(`should return a summary object containing it's supplier country`, async() => {
|
||||||
const result = await app.models.InvoiceOut.summary(1);
|
const summary = await app.models.InvoiceOut.summary(1);
|
||||||
const supplier = result.invoiceOut.supplier();
|
const supplier = summary.invoiceOut.supplier();
|
||||||
|
|
||||||
expect(result.invoiceOut.ref).toEqual('T1111111');
|
expect(summary.invoiceOut.ref).toEqual('T1111111');
|
||||||
expect(supplier.id).toEqual(442);
|
expect(supplier.id).toEqual(442);
|
||||||
expect(supplier.countryFk).toEqual(1);
|
expect(supplier.countryFk).toEqual(1);
|
||||||
});
|
});
|
||||||
|
|
||||||
it(`should return a summary object containing idata from it's tax types`, async() => {
|
it(`should return a summary object containing idata from it's tax types`, async() => {
|
||||||
const result = await app.models.InvoiceOut.summary(1);
|
const summary = await app.models.InvoiceOut.summary(1);
|
||||||
|
|
||||||
expect(result.invoiceOut.ref).toEqual('T1111111');
|
expect(summary.invoiceOut.ref).toEqual('T1111111');
|
||||||
expect(result.invoiceOut.taxesBreakdown.length).toEqual(2);
|
expect(summary.invoiceOut.taxesBreakdown.length).toEqual(2);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
|
@ -51,7 +51,7 @@ describe('Route filter()', () => {
|
||||||
|
|
||||||
let result = await app.models.Route.filter(ctx);
|
let result = await app.models.Route.filter(ctx);
|
||||||
|
|
||||||
expect(result.length).toEqual(2);
|
expect(result.length).toEqual(4);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should return the routes matching "description"', async() => {
|
it('should return the routes matching "description"', async() => {
|
||||||
|
|
|
@ -7,18 +7,18 @@ describe('sale priceDifference()', () => {
|
||||||
tomorrow.setDate(tomorrow.getDate() + 1);
|
tomorrow.setDate(tomorrow.getDate() + 1);
|
||||||
let data = {
|
let data = {
|
||||||
landed: tomorrow,
|
landed: tomorrow,
|
||||||
addressFk: 121,
|
addressFk: 122,
|
||||||
agencyModeFk: 7,
|
agencyModeFk: 7,
|
||||||
warehouseFk: 1
|
warehouseFk: 1
|
||||||
};
|
};
|
||||||
let result = await app.models.Sale.priceDifference(11, data);
|
let result = await app.models.Sale.priceDifference(11, data);
|
||||||
|
|
||||||
expect(result.totalUnitPrice).toEqual(4.03);
|
expect(result.totalUnitPrice).toEqual(4.13);
|
||||||
expect(result.totalNewPrice).toEqual(4.13);
|
expect(result.totalNewPrice).toEqual(4.13);
|
||||||
expect(result.totalDifference).toEqual(0);
|
expect(result.totalDifference).toEqual(0);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should return an error if the ticket state is not valid for modifications', async() => {
|
it('should return an error if the ticket is not editable', async() => {
|
||||||
let error;
|
let error;
|
||||||
let data = {
|
let data = {
|
||||||
landed: new Date(),
|
landed: new Date(),
|
||||||
|
@ -35,4 +35,3 @@ describe('sale priceDifference()', () => {
|
||||||
expect(error).toEqual(new UserError(`The sales of this ticket can't be modified`));
|
expect(error).toEqual(new UserError(`The sales of this ticket can't be modified`));
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
@ -5,22 +5,26 @@ describe('sale updatePrice()', () => {
|
||||||
let originalSalesPersonMana;
|
let originalSalesPersonMana;
|
||||||
let createdSaleComponent;
|
let createdSaleComponent;
|
||||||
let saleId = 7;
|
let saleId = 7;
|
||||||
|
let manaComponentId;
|
||||||
afterAll(async done => {
|
|
||||||
await originalSale.save();
|
|
||||||
await app.models.SaleComponent.updateAll({componentFk: 37, saleFk: saleId}, {value: 0});
|
|
||||||
await originalSalesPersonMana.save();
|
|
||||||
|
|
||||||
done();
|
|
||||||
});
|
|
||||||
|
|
||||||
beforeAll(async done => {
|
beforeAll(async done => {
|
||||||
|
let componentRate = await app.models.ComponentRate.findOne({where: {code: 'mana'}});
|
||||||
|
manaComponentId = componentRate.id;
|
||||||
originalSale = await app.models.Sale.findById(saleId);
|
originalSale = await app.models.Sale.findById(saleId);
|
||||||
originalSalesPersonMana = await app.models.WorkerMana.findById(18);
|
originalSalesPersonMana = await app.models.WorkerMana.findById(18);
|
||||||
|
|
||||||
done();
|
done();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
afterAll(async done => {
|
||||||
|
await originalSale.save();
|
||||||
|
await app.models.SaleComponent.updateAll({componentFk: manaComponentId, saleFk: saleId}, {value: 0});
|
||||||
|
await originalSalesPersonMana.save();
|
||||||
|
|
||||||
|
done();
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
it('should throw an error if the ticket is not editable', async() => {
|
it('should throw an error if the ticket is not editable', async() => {
|
||||||
let immutableSaleId = 1;
|
let immutableSaleId = 1;
|
||||||
let price = 5;
|
let price = 5;
|
||||||
|
@ -54,14 +58,13 @@ describe('sale updatePrice()', () => {
|
||||||
|
|
||||||
it('should set price as a decimal number and check the sale has the mana component', async() => {
|
it('should set price as a decimal number and check the sale has the mana component', async() => {
|
||||||
let price = 5.5;
|
let price = 5.5;
|
||||||
let manaComponentId = 37;
|
|
||||||
|
|
||||||
await app.models.Sale.updatePrice(saleId, price);
|
await app.models.Sale.updatePrice(saleId, price);
|
||||||
let saleUpdated = await app.models.Sale.findById(saleId);
|
let saleUpdated = await app.models.Sale.findById(saleId);
|
||||||
createdSaleComponent = await app.models.SaleComponent.findOne({where: {saleFk: saleId, componentFk: manaComponentId}});
|
createdSaleComponent = await app.models.SaleComponent.findOne({where: {saleFk: saleId, componentFk: manaComponentId}});
|
||||||
|
|
||||||
expect(saleUpdated.price).toEqual(5.5);
|
expect(saleUpdated.price).toEqual(5.5);
|
||||||
expect(createdSaleComponent.value).toEqual(4.48);
|
expect(createdSaleComponent.value).toEqual(4.43);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should check that the mana of salesPerson changed', async() => {
|
it('should check that the mana of salesPerson changed', async() => {
|
||||||
|
|
|
@ -26,20 +26,20 @@ module.exports = function(Self) {
|
||||||
|
|
||||||
Self.makeInvoice = async(ctx, id) => {
|
Self.makeInvoice = async(ctx, id) => {
|
||||||
let userId = ctx.req.accessToken.userId;
|
let userId = ctx.req.accessToken.userId;
|
||||||
let $ = Self.app.models;
|
let models = Self.app.models;
|
||||||
let tx = await Self.beginTransaction({});
|
let tx = await Self.beginTransaction({});
|
||||||
|
|
||||||
try {
|
try {
|
||||||
let options = {transaction: tx};
|
let options = {transaction: tx};
|
||||||
|
|
||||||
let filter = {fields: ['id', 'clientFk', 'companyFk']};
|
let filter = {fields: ['id', 'clientFk', 'companyFk']};
|
||||||
let ticket = await $.Ticket.findById(id, filter, options);
|
let ticket = await models.Ticket.findById(id, filter, options);
|
||||||
|
|
||||||
let clientCanBeInvoiced = await $.Client.canBeInvoiced(ticket.clientFk);
|
let clientCanBeInvoiced = await models.Client.canBeInvoiced(ticket.clientFk);
|
||||||
if (!clientCanBeInvoiced)
|
if (!clientCanBeInvoiced)
|
||||||
throw new UserError(`This client can't be invoiced`);
|
throw new UserError(`This client can't be invoiced`);
|
||||||
|
|
||||||
let ticketCanBeInvoiced = await $.Ticket.canBeInvoiced(ticket.id);
|
let ticketCanBeInvoiced = await models.Ticket.canBeInvoiced(ticket.id);
|
||||||
if (!ticketCanBeInvoiced)
|
if (!ticketCanBeInvoiced)
|
||||||
throw new UserError(`This ticket can't be invoiced`);
|
throw new UserError(`This ticket can't be invoiced`);
|
||||||
|
|
||||||
|
@ -64,7 +64,7 @@ module.exports = function(Self) {
|
||||||
await Self.rawSql(query, [invoice], options);
|
await Self.rawSql(query, [invoice], options);
|
||||||
}
|
}
|
||||||
|
|
||||||
let user = await $.Worker.findOne({where: {userFk: userId}}, options);
|
let user = await models.Worker.findOne({where: {userFk: userId}}, options);
|
||||||
|
|
||||||
query = `INSERT INTO printServerQueue(reportFk, param1, workerFk) VALUES (?, ?, ?)`;
|
query = `INSERT INTO printServerQueue(reportFk, param1, workerFk) VALUES (?, ?, ?)`;
|
||||||
await Self.rawSql(query, [3, invoice, user.id], options);
|
await Self.rawSql(query, [3, invoice, user.id], options);
|
||||||
|
|
|
@ -22,8 +22,8 @@ module.exports = Self => {
|
||||||
});
|
});
|
||||||
|
|
||||||
Self.new = async(ctx, params, options) => {
|
Self.new = async(ctx, params, options) => {
|
||||||
let $ = Self.app.models;
|
let models = Self.app.models;
|
||||||
let address = await $.Address.findOne({
|
let address = await models.Address.findOne({
|
||||||
where: {id: params.addressFk},
|
where: {id: params.addressFk},
|
||||||
fields: ['id', 'clientFk'],
|
fields: ['id', 'clientFk'],
|
||||||
include: [
|
include: [
|
||||||
|
@ -42,7 +42,7 @@ module.exports = Self => {
|
||||||
|
|
||||||
let agencyMode;
|
let agencyMode;
|
||||||
if (params && params.agencyModeFk)
|
if (params && params.agencyModeFk)
|
||||||
agencyMode = await $.AgencyMode.findById(params.agencyModeFk);
|
agencyMode = await models.AgencyMode.findById(params.agencyModeFk);
|
||||||
|
|
||||||
if (address.client().type().code === 'normal' && (!agencyMode || agencyMode.code != 'refund')) {
|
if (address.client().type().code === 'normal' && (!agencyMode || agencyMode.code != 'refund')) {
|
||||||
if (address.client().isFreezed)
|
if (address.client().isFreezed)
|
||||||
|
@ -64,7 +64,7 @@ module.exports = Self => {
|
||||||
|
|
||||||
try {
|
try {
|
||||||
if (!params.shipped && params.landed) {
|
if (!params.shipped && params.landed) {
|
||||||
params.shipped = await $.Agency.getShipped(ctx, {
|
params.shipped = await models.Agency.getShipped(ctx, {
|
||||||
landed: params.landed,
|
landed: params.landed,
|
||||||
addressFk: address.id,
|
addressFk: address.id,
|
||||||
agencyModeFk: params.agencyModeFk,
|
agencyModeFk: params.agencyModeFk,
|
||||||
|
@ -73,7 +73,7 @@ module.exports = Self => {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (params.shipped && !params.landed) {
|
if (params.shipped && !params.landed) {
|
||||||
const landedResult = await $.Agency.getLanded(ctx, {
|
const landedResult = await models.Agency.getLanded(ctx, {
|
||||||
shipped: params.shipped,
|
shipped: params.shipped,
|
||||||
addressFk: address.id,
|
addressFk: address.id,
|
||||||
agencyModeFk: params.agencyModeFk,
|
agencyModeFk: params.agencyModeFk,
|
||||||
|
@ -99,7 +99,7 @@ module.exports = Self => {
|
||||||
params.userId
|
params.userId
|
||||||
], options);
|
], options);
|
||||||
|
|
||||||
let ticket = await $.Ticket.findById(result[1][0].newTicketId, null, options);
|
let ticket = await models.Ticket.findById(result[1][0].newTicketId, null, options);
|
||||||
let cleanInstance = JSON.parse(JSON.stringify(ticket));
|
let cleanInstance = JSON.parse(JSON.stringify(ticket));
|
||||||
|
|
||||||
let logRecord = {
|
let logRecord = {
|
||||||
|
@ -112,7 +112,7 @@ module.exports = Self => {
|
||||||
newInstance: cleanInstance
|
newInstance: cleanInstance
|
||||||
};
|
};
|
||||||
|
|
||||||
await $.TicketLog.create(logRecord, options);
|
await models.TicketLog.create(logRecord, options);
|
||||||
|
|
||||||
if (tx) await tx.commit();
|
if (tx) await tx.commit();
|
||||||
return await ticket;
|
return await ticket;
|
||||||
|
|
|
@ -1,19 +1,23 @@
|
||||||
const app = require('vn-loopback/server/server');
|
const app = require('vn-loopback/server/server');
|
||||||
|
|
||||||
describe('ticket componentUpdate()', () => {
|
describe('ticket componentUpdate()', () => {
|
||||||
let firstvalueBeforeChange;
|
const ticketId = 11;
|
||||||
let secondvalueBeforeChange;
|
|
||||||
let componentOfSaleSeven = `SELECT value FROM vn.saleComponent
|
|
||||||
WHERE saleFk = 7 AND componentFk = 15`;
|
|
||||||
|
|
||||||
let componentOfSaleEight = `SELECT value FROM vn.saleComponent
|
|
||||||
WHERE saleFk = 8 AND componentFk = 15`;
|
|
||||||
const today = new Date();
|
const today = new Date();
|
||||||
const tomorrow = new Date();
|
const tomorrow = new Date();
|
||||||
tomorrow.setDate(tomorrow.getDate() + 1);
|
tomorrow.setDate(tomorrow.getDate() + 1);
|
||||||
let ticketId = 11;
|
|
||||||
|
let deliveryComponentId;
|
||||||
|
let firstvalueBeforeChange;
|
||||||
|
let secondvalueBeforeChange;
|
||||||
|
let componentOfSaleSeven;
|
||||||
|
let componentOfSaleEight;
|
||||||
|
|
||||||
beforeAll(async done => {
|
beforeAll(async done => {
|
||||||
|
let deliveryComponenet = await app.models.ComponentRate.findOne({where: {code: 'delivery'}});
|
||||||
|
deliveryComponentId = deliveryComponenet.id;
|
||||||
|
componentOfSaleSeven = `SELECT value FROM vn.saleComponent WHERE saleFk = 7 AND componentFk = ${deliveryComponentId}`;
|
||||||
|
componentOfSaleEight = `SELECT value FROM vn.saleComponent WHERE saleFk = 8 AND componentFk = ${deliveryComponentId}`;
|
||||||
|
|
||||||
[componentValue] = await app.models.SaleComponent.rawSql(componentOfSaleSeven);
|
[componentValue] = await app.models.SaleComponent.rawSql(componentOfSaleSeven);
|
||||||
firstvalueBeforeChange = componentValue.value;
|
firstvalueBeforeChange = componentValue.value;
|
||||||
|
|
||||||
|
@ -25,9 +29,9 @@ describe('ticket componentUpdate()', () => {
|
||||||
|
|
||||||
it('should change the agencyMode to modify the sale components value', async() => {
|
it('should change the agencyMode to modify the sale components value', async() => {
|
||||||
let data = {
|
let data = {
|
||||||
clientFk: 101,
|
clientFk: 102,
|
||||||
agencyModeFk: 8,
|
agencyModeFk: 8,
|
||||||
addressFk: 121,
|
addressFk: 122,
|
||||||
warehouseFk: 1,
|
warehouseFk: 1,
|
||||||
companyFk: 442,
|
companyFk: 442,
|
||||||
shipped: today,
|
shipped: today,
|
||||||
|
@ -53,9 +57,9 @@ describe('ticket componentUpdate()', () => {
|
||||||
|
|
||||||
it('should change the agencyMode to go back to the originals sale components value', async() => {
|
it('should change the agencyMode to go back to the originals sale components value', async() => {
|
||||||
let data = {
|
let data = {
|
||||||
clientFk: 101,
|
clientFk: 102,
|
||||||
agencyModeFk: 7,
|
agencyModeFk: 7,
|
||||||
addressFk: 121,
|
addressFk: 122,
|
||||||
warehouseFk: 1,
|
warehouseFk: 1,
|
||||||
companyFk: 442,
|
companyFk: 442,
|
||||||
shipped: today,
|
shipped: today,
|
||||||
|
|
|
@ -1,25 +1,25 @@
|
||||||
const app = require('vn-loopback/server/server');
|
const app = require('vn-loopback/server/server');
|
||||||
|
|
||||||
describe('ticket isEditable()', () => {
|
describe('ticket isEditable()', () => {
|
||||||
it('should return false if the ticket given is not editable', async() => {
|
it('should return false if the given ticket is not editable', async() => {
|
||||||
let result = await app.models.Ticket.isEditable(2);
|
let result = await app.models.Ticket.isEditable(2);
|
||||||
|
|
||||||
expect(result).toEqual(false);
|
expect(result).toEqual(false);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should return false if the ticket given does not exist', async() => {
|
it('should return false if the given ticket does not exist', async() => {
|
||||||
let result = await app.models.Ticket.isEditable(99999);
|
let result = await app.models.Ticket.isEditable(99999);
|
||||||
|
|
||||||
expect(result).toEqual(false);
|
expect(result).toEqual(false);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should return false if the ticket given isDeleted', async() => {
|
it('should return false if the given ticket isDeleted', async() => {
|
||||||
let result = await app.models.Ticket.isEditable(21);
|
let result = await app.models.Ticket.isEditable(19);
|
||||||
|
|
||||||
expect(result).toEqual(false);
|
expect(result).toEqual(false);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should return true if the ticket given is editable', async() => {
|
it('should return true if the given ticket is editable', async() => {
|
||||||
let result = await app.models.Ticket.isEditable(16);
|
let result = await app.models.Ticket.isEditable(16);
|
||||||
|
|
||||||
expect(result).toEqual(true);
|
expect(result).toEqual(true);
|
||||||
|
|
|
@ -2,6 +2,7 @@ const app = require('vn-loopback/server/server');
|
||||||
|
|
||||||
describe('ticket makeInvoice()', () => {
|
describe('ticket makeInvoice()', () => {
|
||||||
let invoice;
|
let invoice;
|
||||||
|
let ticketId = 11;
|
||||||
|
|
||||||
afterAll(async done => {
|
afterAll(async done => {
|
||||||
let ticket = await app.models.Ticket.findById(11);
|
let ticket = await app.models.Ticket.findById(11);
|
||||||
|
@ -18,8 +19,7 @@ describe('ticket makeInvoice()', () => {
|
||||||
|
|
||||||
it('should invoice a ticket', async() => {
|
it('should invoice a ticket', async() => {
|
||||||
let ctx = {req: {accessToken: {userId: 9}}};
|
let ctx = {req: {accessToken: {userId: 9}}};
|
||||||
let ticketFk = 11;
|
invoice = await app.models.Ticket.makeInvoice(ctx, ticketId);
|
||||||
invoice = await app.models.Ticket.makeInvoice(ctx, ticketFk);
|
|
||||||
|
|
||||||
expect(invoice.invoiceFk).not.toBeNaN();
|
expect(invoice.invoiceFk).not.toBeNaN();
|
||||||
expect(invoice.serial).toEqual('T');
|
expect(invoice.serial).toEqual('T');
|
||||||
|
@ -27,10 +27,9 @@ describe('ticket makeInvoice()', () => {
|
||||||
|
|
||||||
it('should not invoice an already invoiced ticket', async() => {
|
it('should not invoice an already invoiced ticket', async() => {
|
||||||
let ctx = {req: {accessToken: {userId: 9}}};
|
let ctx = {req: {accessToken: {userId: 9}}};
|
||||||
let ticketFk = 11;
|
|
||||||
let error;
|
let error;
|
||||||
|
|
||||||
await app.models.Ticket.makeInvoice(ctx, ticketFk).catch(e => {
|
await app.models.Ticket.makeInvoice(ctx, ticketId).catch(e => {
|
||||||
error = e;
|
error = e;
|
||||||
}).finally(() => {
|
}).finally(() => {
|
||||||
expect(error.message).toEqual(`This ticket can't be invoiced`);
|
expect(error.message).toEqual(`This ticket can't be invoiced`);
|
||||||
|
|
Loading…
Reference in New Issue