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

Draft
carlossa wants to merge 12 commits from 7917-freelancerRoute into dev
1 changed files with 12 additions and 17 deletions
Showing only changes of commit 5e7dea94b1 - Show all commits

View File

@ -3,8 +3,16 @@ const models = require('vn-loopback/server/server').models;
describe('AgencyTerm filter()', () => {
const authUserId = 9;
let ctx;
const today = Date.vnNew();
today.setHours(2, 0, 0, 0);
beforeAll(async() => {
ctx = {
args: {
ctx: {req: {accessToken: {userId: authUserId}}},
}
};
});
it('should return all results matching the filter', async() => {
const tx = await models.AgencyTerm.beginTransaction({});
@ -12,7 +20,6 @@ describe('AgencyTerm filter()', () => {
try {
const options = {transaction: tx};
const filter = {};
const ctx = {req: {accessToken: {userId: authUserId}}};
const agencyTerms = await models.AgencyTerm.filter(ctx, filter, options);
const firstAgencyTerm = agencyTerms[0];
@ -28,9 +35,8 @@ describe('AgencyTerm filter()', () => {
});
it('should return results matching "search" searching by integer', async() => {
let ctx = {
ctx = {
args: {
ctx: {req: {accessToken: {userId: authUserId}}},
search: 1,
}
};
@ -42,9 +48,8 @@ describe('AgencyTerm filter()', () => {
});
it('should return results matching "search" searching by string', async() => {
let ctx = {
ctx = {
args: {
ctx: {req: {accessToken: {userId: authUserId}}},
search: 'Plants SL',
}
};
@ -65,14 +70,6 @@ describe('AgencyTerm filter()', () => {
const to = Date.vnNew();
to.setHours(23, 59, 59, 999);
const ctx = {
args: {
ctx: {req: {accessToken: {userId: authUserId}}},
from: from,
to: to
}
};
const results = await models.AgencyTerm.filter(ctx, options);
expect(results.length).toBe(5);
@ -85,9 +82,8 @@ describe('AgencyTerm filter()', () => {
});
it('should return results matching "agencyModeFk"', async() => {
let ctx = {
ctx = {
args: {
ctx: {req: {accessToken: {userId: authUserId}}},
agencyModeFk: 1,
}
};
@ -99,9 +95,8 @@ describe('AgencyTerm filter()', () => {
});
it('should return results matching "agencyFk"', async() => {
let ctx = {
ctx = {
args: {
ctx: {req: {accessToken: {userId: authUserId}}},
agencyFk: 2,
}
};