refactor: refs #6436 second wave
gitea/salix/pipeline/pr-dev This commit looks good Details

This commit is contained in:
Jon Elias 2024-06-11 10:00:30 +02:00
parent 7df7382346
commit b3fa869757
11 changed files with 23 additions and 120 deletions

View File

@ -1,15 +1,8 @@
const {models} = require('vn-loopback/server/server');
// const LoopBackContext = require('loopback-context');
describe('getStarredModules()', () => {
const {ctx} = beforeAll;
// beforeEach(() => {
// spyOn(LoopBackContext, 'getCurrentContext').and.returnValue({
// active: ctx
// });
// });
it(`should return the starred modules for a given user`, async() => {
const newStarred = await models.StarredModule.create({workerFk: 9, moduleFk: 'customer', position: 1});
const starredModules = await models.StarredModule.getStarredModules(ctx);

View File

@ -1,15 +1,8 @@
const {models} = require('vn-loopback/server/server');
// const LoopBackContext = require('loopback-context');
describe('setPosition()', () => {
const {ctx} = beforeAll;
// beforeEach(() => {
// spyOn(LoopBackContext, 'getCurrentContext').and.returnValue({
// active: activeCtx
// });
// });
it('should increase the orders module position by replacing it with clients and vice versa', async() => {
const tx = await models.StarredModule.beginTransaction({});

View File

@ -1,15 +1,8 @@
const {models} = require('vn-loopback/server/server');
// const LoopBackContext = require('loopback-context');
describe('toggleStarredModule()', () => {
const {ctx} = beforeAll;
// beforeEach(() => {
// spyOn(LoopBackContext, 'getCurrentContext').and.returnValue({
// active: activeCtx
// });
// });
it('should create a new starred module and then remove it by calling the method again with same args', async() => {
const starredModule = await models.StarredModule.toggleStarredModule(ctx, 'order');
let starredModules = await models.StarredModule.getStarredModules(ctx);

View File

@ -2,15 +2,7 @@ const app = require('vn-loopback/server/server');
const models = require('vn-loopback/server/server').models;
describe('claim filter()', () => {
let ctx;
beforeEach(() => {
ctx = {
req: {
accessToken: {userId: 9},
headers: {origin: 'http://localhost'}
}
};
});
const {ctx} = beforeAll;
it('should return 1 result filtering by id', async() => {
const tx = await app.models.Claim.beginTransaction({});

View File

@ -1,5 +1,5 @@
const models = require('vn-loopback/server/server').models;
const LoopBackContext = require('loopback-context');
const {mockLoopBackContext} = require('vn-loopback/../../back/vn-jasmine');
describe('claim regularizeClaim()', () => {
const userId = 18;
@ -41,17 +41,7 @@ describe('claim regularizeClaim()', () => {
}
beforeAll(async() => {
const activeCtx = {
accessToken: {userId: 9},
http: {
req: {
headers: {origin: 'http://localhost'}
}
}
};
spyOn(LoopBackContext, 'getCurrentContext').and.returnValue({
active: activeCtx
});
mockLoopBackContext();
});
it('should send a chat message with value "Trash" and then change claim state to resolved', async() => {

View File

@ -1,22 +1,11 @@
const app = require('vn-loopback/server/server');
const LoopBackContext = require('loopback-context');
const {mockLoopBackContext} = require('vn-loopback/../../back/vn-jasmine');
const i18n = require('i18n');
describe('Update Claim', () => {
let url;
let claimStatesMap = {};
beforeAll(async() => {
url = await app.models.Url.getUrl();
const activeCtx = {
accessToken: {userId: 9},
http: {
req: {
headers: {origin: 'http://localhost'}
}
}
};
spyOn(LoopBackContext, 'getCurrentContext').and.returnValue({
active: activeCtx
});
mockLoopBackContext();
const claimStates = await app.models.ClaimState.find();
claimStatesMap = claimStates.reduce((acc, state) => ({...acc, [state.code]: state.id}), {});
});

View File

@ -1,19 +1,9 @@
const app = require('vn-loopback/server/server');
const LoopBackContext = require('loopback-context');
const {mockLoopBackContext} = require('vn-loopback/../../back/vn-jasmine');
describe('Update Claim', () => {
beforeAll(async() => {
const activeCtx = {
accessToken: {userId: 9},
http: {
req: {
headers: {origin: 'http://localhost'}
}
}
};
spyOn(LoopBackContext, 'getCurrentContext').and.returnValue({
active: activeCtx
});
mockLoopBackContext();
});
const newDate = Date.vnNew();
const original = {

View File

@ -1,21 +1,8 @@
const models = require('vn-loopback/server/server').models;
const LoopBackContext = require('loopback-context');
// const LoopBackContext = require('loopback-context');
describe('AgencyTerm createInvoiceIn()', () => {
const ctx = {req: {accessToken: {userId: 9}}};
beforeAll(async() => {
const activeCtx = {
accessToken: {userId: 9},
http: {
req: {
headers: {origin: 'http://localhost'}
}
}
};
spyOn(LoopBackContext, 'getCurrentContext').and.returnValue({
active: activeCtx
});
});
const {ctx} = beforeAll;
const rows = [
{
routeFk: 2,

View File

@ -1,20 +1,9 @@
const app = require('vn-loopback/server/server');
const LoopBackContext = require('loopback-context');
const {mockLoopBackContext} = require('vn-loopback/../../back/vn-jasmine');
describe('route clone()', () => {
beforeAll(async() => {
const activeCtx = {
accessToken: {userId: 9},
http: {
req: {
headers: {origin: 'http://localhost'}
}
}
};
spyOn(LoopBackContext, 'getCurrentContext').and.returnValue({
active: activeCtx
});
mockLoopBackContext();
});
const createdDate = Date.vnNew();

View File

@ -1,20 +1,17 @@
const app = require('vn-loopback/server/server');
const LoopBackContext = require('loopback-context');
// const LoopBackContext = require('loopback-context');
describe('route guessPriority()', () => {
const targetRouteId = 7;
let routeTicketsToRestore;
const activeCtx = {
accessToken: {userId: 9},
__: () => {}
};
const {ctx} = beforeAll;
beforeAll(() => {
spyOn(LoopBackContext, 'getCurrentContext').and.returnValue({
active: activeCtx
});
});
// beforeAll(() => {
// spyOn(LoopBackContext, 'getCurrentContext').and.returnValue({
// active: activeCtx
// });
// });
afterAll(async() => {
let restoreFixtures = [];
@ -25,9 +22,9 @@ describe('route guessPriority()', () => {
});
it('should call guessPriority() then check all tickets in that route have their priorities defined', async() => {
const ctx = {
req: activeCtx
};
// const ctx = {
// req: activeCtx
// };
routeTicketsToRestore = await app.models.Ticket.find({where: {routeFk: targetRouteId}});
await app.models.Route.guessPriority(ctx, targetRouteId);

View File

@ -1,19 +1,9 @@
const models = require('vn-loopback/server/server').models;
const LoopBackContext = require('loopback-context');
const {mockLoopBackContext} = require('vn-loopback/../../back/vn-jasmine');
describe('route updateWorkCenter()', () => {
beforeAll(async() => {
const activeCtx = {
accessToken: {userId: 9},
http: {
req: {
headers: {origin: 'http://localhost'}
}
}
};
spyOn(LoopBackContext, 'getCurrentContext').and.returnValue({
active: activeCtx
});
mockLoopBackContext();
});
const routeId = 1;