WIP: fix: refs #7917 fix methods, tests, acls #3085

Draft
carlossa wants to merge 9 commits from 7917-freelancerRoute into dev
2 changed files with 29 additions and 5 deletions
Showing only changes of commit 839475a669 - Show all commits

View File

@ -5,6 +5,14 @@ describe('AgencyTerm filter()', () => {
const today = Date.vnNew();
today.setHours(2, 0, 0, 0);
let ctx = beforeAll.getCtx();
beforeAll(async() => {
ctx = {
req: {
accessToken: {},
headers: {origin: 'http://localhost'},
}
};
});
it('should return all results matching the filter', async() => {
const tx = await models.AgencyTerm.beginTransaction({});

View File

@ -1,35 +1,51 @@
const app = require('vn-loopback/server/server');
describe('route summary()', () => {
let ctx = beforeAll.getCtx();
beforeAll(async() => {
ctx = {
req: {
accessToken: {},
headers: {origin: 'http://localhost'},
}
};
});
it('should return a summary object containing data from one route', async() => {
const result = await app.models.Route.summary(ctx, 1);
const filter = {
id: 1
};
const result = await app.models.Route.summary(ctx, filter);
expect(result.route.id).toEqual(1);
});
it(`should return a summary object containing it's agency`, async() => {
const result = await app.models.Route.summary(ctx, 1);
const filter = {
id: 1
};
const result = await app.models.Route.summary(ctx, filter);
const agency = result.route.agencyMode();
expect(agency.name).toEqual('inhouse pickup');
});
it(`should return a summary object containing it's vehicle`, async() => {
const result = await app.models.Route.summary(ctx, 1);
const result = await app.models.Route.summary(ctx, filter);
const vehicle = result.route.vehicle();
expect(vehicle.numberPlate).toEqual('3333-BAT');
});
it(`should return a summary object containing it's worker`, async() => {
const result = await app.models.Route.summary(ctx, 1);
const result = await app.models.Route.summary(ctx, filter);
const worker = result.route.worker().user();
expect(worker.name).toEqual('delivery');
});
it(`should return a summary object containing data from the tickets`, async() => {
const result = await app.models.Route.summary(ctx, 2);
const result = await app.models.Route.summary(ctx, filter);
expect(result.tickets.length).toEqual(1);
});