Tests
gitea/salix/pipeline/head There was a failure building this commit
Details
gitea/salix/pipeline/head There was a failure building this commit
Details
This commit is contained in:
parent
a065d77929
commit
c8bad23621
|
@ -24,12 +24,13 @@ describe('Item Component vnClaimDescriptor', () => {
|
||||||
|
|
||||||
window.open = jasmine.createSpy('open');
|
window.open = jasmine.createSpy('open');
|
||||||
const params = {
|
const params = {
|
||||||
recipientId: claim.clientFk,
|
recipientId: claim.clientFk
|
||||||
claimId: claim.id
|
|
||||||
};
|
};
|
||||||
controller.showPickupOrder();
|
controller.showPickupOrder();
|
||||||
|
|
||||||
expect(controller.vnReport.show).toHaveBeenCalledWith('claim-pickup-order', params);
|
const expectedPath = `Claims/${claim.id}/claim-pickup-pdf`;
|
||||||
|
|
||||||
|
expect(controller.vnReport.show).toHaveBeenCalledWith(expectedPath, params);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -39,12 +40,13 @@ describe('Item Component vnClaimDescriptor', () => {
|
||||||
|
|
||||||
const params = {
|
const params = {
|
||||||
recipient: claim.client.email,
|
recipient: claim.client.email,
|
||||||
recipientId: claim.clientFk,
|
recipientId: claim.clientFk
|
||||||
claimId: claim.id
|
|
||||||
};
|
};
|
||||||
controller.sendPickupOrder();
|
controller.sendPickupOrder();
|
||||||
|
|
||||||
expect(controller.vnEmail.send).toHaveBeenCalledWith('claim-pickup-order', params);
|
const expectedPath = `Claims/${claim.id}/claim-pickup-email`;
|
||||||
|
|
||||||
|
expect(controller.vnEmail.send).toHaveBeenCalledWith(expectedPath, params);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
@ -34,15 +34,16 @@ describe('Client', () => {
|
||||||
|
|
||||||
controller.showReport();
|
controller.showReport();
|
||||||
|
|
||||||
|
const clientId = controller.client.id;
|
||||||
const expectedParams = {
|
const expectedParams = {
|
||||||
recipientId: 1101,
|
recipientId: clientId,
|
||||||
from: now,
|
from: now,
|
||||||
to: now
|
to: now
|
||||||
};
|
};
|
||||||
const serializedParams = $httpParamSerializer(expectedParams);
|
const serializedParams = $httpParamSerializer(expectedParams);
|
||||||
const path = `api/report/campaign-metrics?${serializedParams}`;
|
const expectedPath = `api/Clients/${clientId}/campaign-metrics-pdf?${serializedParams}`;
|
||||||
|
|
||||||
expect(window.open).toHaveBeenCalledWith(path);
|
expect(window.open).toHaveBeenCalledWith(expectedPath);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -53,16 +54,10 @@ describe('Client', () => {
|
||||||
from: now,
|
from: now,
|
||||||
to: now
|
to: now
|
||||||
};
|
};
|
||||||
const expectedParams = {
|
const clientId = controller.client.id;
|
||||||
recipientId: 1101,
|
const expectedPath = `Clients/${clientId}/campaign-metrics-email`;
|
||||||
from: now,
|
|
||||||
to: now
|
|
||||||
};
|
|
||||||
|
|
||||||
const serializedParams = $httpParamSerializer(expectedParams);
|
$httpBackend.expect('POST', expectedPath).respond({});
|
||||||
const path = `email/campaign-metrics?${serializedParams}`;
|
|
||||||
|
|
||||||
$httpBackend.expect('GET', path).respond({});
|
|
||||||
controller.sendEmail();
|
controller.sendEmail();
|
||||||
$httpBackend.flush();
|
$httpBackend.flush();
|
||||||
});
|
});
|
||||||
|
|
|
@ -85,7 +85,7 @@ export default class Controller extends Section {
|
||||||
|
|
||||||
this.$http.post('ClientConsumptionQueues', {params})
|
this.$http.post('ClientConsumptionQueues', {params})
|
||||||
.then(() => this.$.filters.hide())
|
.then(() => this.$.filters.hide())
|
||||||
.then(() => this.vnApp.showSuccess(this.$t('Notifications queued')));
|
.then(() => this.vnApp.showSuccess(this.$t('Notifications sent!')));
|
||||||
}
|
}
|
||||||
|
|
||||||
exprBuilder(param, value) {
|
exprBuilder(param, value) {
|
||||||
|
|
|
@ -61,7 +61,6 @@ describe('Client notification', () => {
|
||||||
|
|
||||||
controller.$.filters = {hide: () => {}};
|
controller.$.filters = {hide: () => {}};
|
||||||
controller.campaign = {
|
controller.campaign = {
|
||||||
id: 1,
|
|
||||||
from: new Date(),
|
from: new Date(),
|
||||||
to: new Date()
|
to: new Date()
|
||||||
};
|
};
|
||||||
|
@ -71,10 +70,10 @@ describe('Client notification', () => {
|
||||||
data[1].$checked = true;
|
data[1].$checked = true;
|
||||||
|
|
||||||
const params = Object.assign({
|
const params = Object.assign({
|
||||||
clientIds: [1101, 1102]
|
clients: [1101, 1102]
|
||||||
}, controller.campaign);
|
}, controller.campaign);
|
||||||
|
|
||||||
$httpBackend.expect('POST', `schedule/consumption`, params).respond(200, params);
|
$httpBackend.expect('POST', `ClientConsumptionQueues`, {params}).respond(200, params);
|
||||||
controller.onSendClientConsumption();
|
controller.onSendClientConsumption();
|
||||||
$httpBackend.flush();
|
$httpBackend.flush();
|
||||||
|
|
||||||
|
|
|
@ -40,58 +40,6 @@ class Controller extends Section {
|
||||||
this.$.watcher.realSubmit().then(() => this.send());
|
this.$.watcher.realSubmit().then(() => this.send());
|
||||||
}
|
}
|
||||||
|
|
||||||
// showPreview() {
|
|
||||||
// this.send(true, res => {
|
|
||||||
// this.$.showPreview.show();
|
|
||||||
// const dialog = document.body.querySelector('div.vn-dialog');
|
|
||||||
// const body = dialog.querySelector('tpl-body');
|
|
||||||
// const scroll = dialog.querySelector('div:first-child');
|
|
||||||
|
|
||||||
// body.innerHTML = res.data;
|
|
||||||
// scroll.scrollTop = 0;
|
|
||||||
// });
|
|
||||||
// }
|
|
||||||
|
|
||||||
// sendSample() {
|
|
||||||
// this.send(false, () => {
|
|
||||||
// this.vnApp.showSuccess(this.$t('Notification sent!'));
|
|
||||||
// this.$state.go('client.card.sample.index');
|
|
||||||
// });
|
|
||||||
// }
|
|
||||||
|
|
||||||
// send(isPreview, cb) {
|
|
||||||
// const sampleType = this.$.sampleType.selection;
|
|
||||||
// const params = {
|
|
||||||
// recipientId: this.$params.id,
|
|
||||||
// recipient: this.clientSample.recipient,
|
|
||||||
// replyTo: this.clientSample.replyTo
|
|
||||||
// };
|
|
||||||
|
|
||||||
// if (!params.recipient)
|
|
||||||
// return this.vnApp.showError(this.$t('Email cannot be blank'));
|
|
||||||
|
|
||||||
// if (!sampleType)
|
|
||||||
// return this.vnApp.showError(this.$t('Choose a sample'));
|
|
||||||
|
|
||||||
// if (sampleType.hasCompany && !this.clientSample.companyFk)
|
|
||||||
// return this.vnApp.showError(this.$t('Choose a company'));
|
|
||||||
|
|
||||||
// if (sampleType.hasCompany)
|
|
||||||
// params.companyId = this.clientSample.companyFk;
|
|
||||||
|
|
||||||
// if (sampleType.datepickerEnabled && !this.clientSample.from)
|
|
||||||
// return this.vnApp.showError(this.$t('Choose a date'));
|
|
||||||
|
|
||||||
// if (sampleType.datepickerEnabled)
|
|
||||||
// params.from = this.clientSample.from;
|
|
||||||
|
|
||||||
// let query = `email/${sampleType.code}`;
|
|
||||||
// if (isPreview)
|
|
||||||
// query = `email/${sampleType.code}/preview`;
|
|
||||||
|
|
||||||
// this.$http.get(query, {params}).then(cb);
|
|
||||||
// }
|
|
||||||
|
|
||||||
validateParams(params) {
|
validateParams(params) {
|
||||||
const sampleType = this.$.sampleType.selection;
|
const sampleType = this.$.sampleType.selection;
|
||||||
|
|
||||||
|
|
|
@ -40,6 +40,7 @@ describe('Client', () => {
|
||||||
$httpParamSerializer = _$httpParamSerializer_;
|
$httpParamSerializer = _$httpParamSerializer_;
|
||||||
$element = angular.element('<vn-client-sample-create></vn-client-sample-create>');
|
$element = angular.element('<vn-client-sample-create></vn-client-sample-create>');
|
||||||
controller = $componentController('vnClientSampleCreate', {$element, $scope});
|
controller = $componentController('vnClientSampleCreate', {$element, $scope});
|
||||||
|
controller.client = {id: 1101};
|
||||||
const element = document.createElement('div');
|
const element = document.createElement('div');
|
||||||
document.body.querySelector = () => {
|
document.body.querySelector = () => {
|
||||||
return {
|
return {
|
||||||
|
@ -51,11 +52,11 @@ describe('Client', () => {
|
||||||
}));
|
}));
|
||||||
|
|
||||||
describe('onSubmit()', () => {
|
describe('onSubmit()', () => {
|
||||||
it(`should call sendSample() method`, () => {
|
it(`should call send() method`, () => {
|
||||||
jest.spyOn(controller, 'sendSample');
|
jest.spyOn(controller, 'send');
|
||||||
controller.onSubmit();
|
controller.onSubmit();
|
||||||
|
|
||||||
expect(controller.sendSample).toHaveBeenCalledWith();
|
expect(controller.send).toHaveBeenCalledWith();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -65,7 +66,8 @@ describe('Client', () => {
|
||||||
|
|
||||||
controller.$.sampleType.selection = {
|
controller.$.sampleType.selection = {
|
||||||
hasCompany: false,
|
hasCompany: false,
|
||||||
code: 'MyReport'
|
code: 'MyReport',
|
||||||
|
model: 'Clients'
|
||||||
};
|
};
|
||||||
controller.clientSample = {
|
controller.clientSample = {
|
||||||
recipientId: 1101
|
recipientId: 1101
|
||||||
|
|
|
@ -17,13 +17,10 @@ describe('Entry Component vnEntryDescriptor', () => {
|
||||||
jest.spyOn(controller.vnReport, 'show');
|
jest.spyOn(controller.vnReport, 'show');
|
||||||
|
|
||||||
window.open = jasmine.createSpy('open');
|
window.open = jasmine.createSpy('open');
|
||||||
const params = {
|
|
||||||
clientId: controller.vnConfig.storage.currentUserWorkerId,
|
|
||||||
entryId: entry.id
|
|
||||||
};
|
|
||||||
controller.showEntryReport();
|
controller.showEntryReport();
|
||||||
|
const expectedPath = `Entries/${entry.id}/entry-order-pdf`;
|
||||||
|
|
||||||
expect(controller.vnReport.show).toHaveBeenCalledWith('entry-order', params);
|
expect(controller.vnReport.show).toHaveBeenCalledWith(expectedPath);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
@ -41,11 +41,10 @@ describe('vnInvoiceOutDescriptorMenu', () => {
|
||||||
jest.spyOn(window, 'open').mockReturnThis();
|
jest.spyOn(window, 'open').mockReturnThis();
|
||||||
|
|
||||||
const expectedParams = {
|
const expectedParams = {
|
||||||
recipientId: invoiceOut.client.id,
|
recipientId: invoiceOut.client.id
|
||||||
refFk: invoiceOut.ref
|
|
||||||
};
|
};
|
||||||
const serializedParams = $httpParamSerializer(expectedParams);
|
const serializedParams = $httpParamSerializer(expectedParams);
|
||||||
const expectedPath = `api/csv/invoice/download?${serializedParams}`;
|
const expectedPath = `api/InvoiceOuts/${invoiceOut.ref}/invoice-csv?${serializedParams}`;
|
||||||
controller.showCsvInvoice();
|
controller.showCsvInvoice();
|
||||||
|
|
||||||
expect(window.open).toHaveBeenCalledWith(expectedPath);
|
expect(window.open).toHaveBeenCalledWith(expectedPath);
|
||||||
|
@ -84,14 +83,8 @@ describe('vnInvoiceOutDescriptorMenu', () => {
|
||||||
jest.spyOn(controller.vnApp, 'showMessage');
|
jest.spyOn(controller.vnApp, 'showMessage');
|
||||||
|
|
||||||
const $data = {email: 'brucebanner@gothamcity.com'};
|
const $data = {email: 'brucebanner@gothamcity.com'};
|
||||||
const expectedParams = {
|
|
||||||
recipient: $data.email,
|
|
||||||
recipientId: invoiceOut.client.id,
|
|
||||||
refFk: invoiceOut.ref
|
|
||||||
};
|
|
||||||
const serializedParams = $httpParamSerializer(expectedParams);
|
|
||||||
|
|
||||||
$httpBackend.expectGET(`email/invoice?${serializedParams}`).respond();
|
$httpBackend.expectPOST(`InvoiceOuts/${invoiceOut.ref}/invoice-email`).respond();
|
||||||
controller.sendPdfInvoice($data);
|
controller.sendPdfInvoice($data);
|
||||||
$httpBackend.flush();
|
$httpBackend.flush();
|
||||||
|
|
||||||
|
@ -104,14 +97,8 @@ describe('vnInvoiceOutDescriptorMenu', () => {
|
||||||
jest.spyOn(controller.vnApp, 'showMessage');
|
jest.spyOn(controller.vnApp, 'showMessage');
|
||||||
|
|
||||||
const $data = {email: 'brucebanner@gothamcity.com'};
|
const $data = {email: 'brucebanner@gothamcity.com'};
|
||||||
const expectedParams = {
|
|
||||||
recipient: $data.email,
|
|
||||||
recipientId: invoiceOut.client.id,
|
|
||||||
refFk: invoiceOut.ref
|
|
||||||
};
|
|
||||||
const serializedParams = $httpParamSerializer(expectedParams);
|
|
||||||
|
|
||||||
$httpBackend.expectGET(`csv/invoice/send?${serializedParams}`).respond();
|
$httpBackend.expectPOST(`InvoiceOuts/${invoiceOut.ref}/invoice-csv-email`).respond();
|
||||||
controller.sendCsvInvoice($data);
|
controller.sendCsvInvoice($data);
|
||||||
$httpBackend.flush();
|
$httpBackend.flush();
|
||||||
|
|
||||||
|
|
|
@ -42,7 +42,7 @@ describe('Supplier', () => {
|
||||||
to: now
|
to: now
|
||||||
};
|
};
|
||||||
const serializedParams = $httpParamSerializer(expectedParams);
|
const serializedParams = $httpParamSerializer(expectedParams);
|
||||||
const path = `api/report/supplier-campaign-metrics?${serializedParams}`;
|
const path = `api/Suppliers/${supplierId}/campaign-metrics-pdf?${serializedParams}`;
|
||||||
|
|
||||||
expect(window.open).toHaveBeenCalledWith(path);
|
expect(window.open).toHaveBeenCalledWith(path);
|
||||||
});
|
});
|
||||||
|
@ -66,7 +66,8 @@ describe('Supplier', () => {
|
||||||
controller.sendEmail();
|
controller.sendEmail();
|
||||||
$httpBackend.flush();
|
$httpBackend.flush();
|
||||||
|
|
||||||
expect(controller.vnApp.showError).toHaveBeenCalledWith(`This supplier doesn't have a contact with an email address`);
|
expect(controller.vnApp.showError)
|
||||||
|
.toHaveBeenCalledWith(`This supplier doesn't have a contact with an email address`);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should make a GET query sending the report', () => {
|
it('should make a GET query sending the report', () => {
|
||||||
|
@ -91,16 +92,15 @@ describe('Supplier', () => {
|
||||||
to: now
|
to: now
|
||||||
};
|
};
|
||||||
const expectedParams = {
|
const expectedParams = {
|
||||||
recipientId: 2,
|
|
||||||
recipient: 'batman@gothamcity.com',
|
recipient: 'batman@gothamcity.com',
|
||||||
from: now,
|
from: now,
|
||||||
to: now
|
to: now
|
||||||
};
|
};
|
||||||
|
|
||||||
serializedParams = $httpParamSerializer(expectedParams);
|
serializedParams = $httpParamSerializer(expectedParams);
|
||||||
const path = `email/supplier-campaign-metrics?${serializedParams}`;
|
const path = `Suppliers/${supplierId}/campaign-metrics-email`;
|
||||||
|
|
||||||
$httpBackend.expect('GET', path).respond({});
|
$httpBackend.expect('POST', path).respond({});
|
||||||
controller.sendEmail();
|
controller.sendEmail();
|
||||||
$httpBackend.flush();
|
$httpBackend.flush();
|
||||||
});
|
});
|
||||||
|
|
|
@ -124,12 +124,11 @@ describe('Ticket Component vnTicketDescriptorMenu', () => {
|
||||||
jest.spyOn(window, 'open').mockReturnThis();
|
jest.spyOn(window, 'open').mockReturnThis();
|
||||||
const type = 'deliveryNote';
|
const type = 'deliveryNote';
|
||||||
const expectedParams = {
|
const expectedParams = {
|
||||||
ticketId: ticket.id,
|
|
||||||
recipientId: ticket.client.id,
|
recipientId: ticket.client.id,
|
||||||
type: type
|
type: type
|
||||||
};
|
};
|
||||||
const serializedParams = $httpParamSerializer(expectedParams);
|
const serializedParams = $httpParamSerializer(expectedParams);
|
||||||
const expectedPath = `api/report/delivery-note?${serializedParams}`;
|
const expectedPath = `api/tickets/${ticket.id}/delivery-note-pdf?${serializedParams}`;
|
||||||
controller.showPdfDeliveryNote(type);
|
controller.showPdfDeliveryNote(type);
|
||||||
|
|
||||||
expect(window.open).toHaveBeenCalledWith(expectedPath);
|
expect(window.open).toHaveBeenCalledWith(expectedPath);
|
||||||
|
@ -143,12 +142,13 @@ describe('Ticket Component vnTicketDescriptorMenu', () => {
|
||||||
const $data = {email: 'brucebanner@gothamcity.com'};
|
const $data = {email: 'brucebanner@gothamcity.com'};
|
||||||
const params = {
|
const params = {
|
||||||
recipient: $data.email,
|
recipient: $data.email,
|
||||||
recipientId: ticket.client.id,
|
recipientId: ticket.client.id
|
||||||
ticketId: ticket.id
|
|
||||||
};
|
};
|
||||||
controller.sendPdfDeliveryNote($data);
|
controller.sendPdfDeliveryNote($data);
|
||||||
|
|
||||||
expect(controller.vnEmail.send).toHaveBeenCalledWith('delivery-note', params);
|
const expectedPath = `tickets/${ticket.id}/delivery-note-email`;
|
||||||
|
|
||||||
|
expect(controller.vnEmail.send).toHaveBeenCalledWith(expectedPath, params);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -157,11 +157,10 @@ describe('Ticket Component vnTicketDescriptorMenu', () => {
|
||||||
jest.spyOn(window, 'open').mockReturnThis();
|
jest.spyOn(window, 'open').mockReturnThis();
|
||||||
|
|
||||||
const expectedParams = {
|
const expectedParams = {
|
||||||
ticketId: ticket.id,
|
|
||||||
recipientId: ticket.client.id
|
recipientId: ticket.client.id
|
||||||
};
|
};
|
||||||
const serializedParams = $httpParamSerializer(expectedParams);
|
const serializedParams = $httpParamSerializer(expectedParams);
|
||||||
const expectedPath = `api/csv/delivery-note/download?${serializedParams}`;
|
const expectedPath = `api/tickets/${ticket.id}/delivery-note-csv?${serializedParams}`;
|
||||||
controller.showCsvDeliveryNote();
|
controller.showCsvDeliveryNote();
|
||||||
|
|
||||||
expect(window.open).toHaveBeenCalledWith(expectedPath);
|
expect(window.open).toHaveBeenCalledWith(expectedPath);
|
||||||
|
@ -170,21 +169,18 @@ describe('Ticket Component vnTicketDescriptorMenu', () => {
|
||||||
|
|
||||||
describe('sendCsvDeliveryNote()', () => {
|
describe('sendCsvDeliveryNote()', () => {
|
||||||
it('should make a query to the csv delivery-note send endpoint and show a message snackbar', () => {
|
it('should make a query to the csv delivery-note send endpoint and show a message snackbar', () => {
|
||||||
jest.spyOn(controller.vnApp, 'showMessage');
|
jest.spyOn(controller.vnEmail, 'send');
|
||||||
|
|
||||||
const $data = {email: 'brucebanner@gothamcity.com'};
|
const $data = {email: 'brucebanner@gothamcity.com'};
|
||||||
const expectedParams = {
|
const expectedParams = {
|
||||||
ticketId: ticket.id,
|
|
||||||
recipient: $data.email,
|
recipient: $data.email,
|
||||||
recipientId: ticket.client.id,
|
recipientId: ticket.client.id,
|
||||||
};
|
};
|
||||||
const serializedParams = $httpParamSerializer(expectedParams);
|
|
||||||
|
|
||||||
$httpBackend.expectGET(`csv/delivery-note/send?${serializedParams}`).respond();
|
|
||||||
controller.sendCsvDeliveryNote($data);
|
controller.sendCsvDeliveryNote($data);
|
||||||
$httpBackend.flush();
|
|
||||||
|
|
||||||
expect(controller.vnApp.showMessage).toHaveBeenCalled();
|
const expectedPath = `tickets/${ticket.id}/delivery-note-csv-email`;
|
||||||
|
|
||||||
|
expect(controller.vnEmail.send).toHaveBeenCalledWith(expectedPath, expectedParams);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
@ -29,11 +29,8 @@ export default class Controller extends Section {
|
||||||
}
|
}
|
||||||
|
|
||||||
openDeliveryNotes(ids) {
|
openDeliveryNotes(ids) {
|
||||||
for (let id of ids) {
|
for (let id of ids)
|
||||||
this.vnReport.show('delivery-note', {
|
this.vnReport.show(`Tickets/${id}/delivery-note-pdf`);
|
||||||
ticketId: id,
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
openBalanceDialog() {
|
openBalanceDialog() {
|
||||||
|
|
|
@ -96,8 +96,8 @@ describe('Component vnTicketIndex', () => {
|
||||||
controller.setDelivered();
|
controller.setDelivered();
|
||||||
$httpBackend.flush();
|
$httpBackend.flush();
|
||||||
|
|
||||||
expect($window.open).toHaveBeenCalledWith(`api/report/delivery-note?ticketId=${tickets[1].id}`);
|
expect($window.open).toHaveBeenCalledWith(`Tickets/${tickets[1].id}/delivery-note-pdf`);
|
||||||
expect($window.open).toHaveBeenCalledWith(`api/report/delivery-note?ticketId=${tickets[2].id}`);
|
expect($window.open).toHaveBeenCalledWith(`Tickets/${tickets[2].id}/delivery-note-pdf`);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue