7729-devToTest_2430 #2739

Merged
alexm merged 339 commits from 7729-devToTest_2430 into test 2024-07-16 07:11:37 +00:00
12 changed files with 39 additions and 145 deletions
Showing only changes of commit f0ad012835 - Show all commits

View File

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

View File

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

View File

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

View File

@ -1,24 +1,14 @@
const {models} = require('vn-loopback/server/server'); const {models} = require('vn-loopback/server/server');
const LoopBackContext = require('loopback-context'); // const LoopBackContext = require('loopback-context');
describe('toggleStarredModule()', () => { describe('toggleStarredModule()', () => {
const activeCtx = { const {ctx} = beforeAll;
accessToken: {userId: 9},
http: {
req: {
headers: {origin: 'http://localhost'}
}
}
};
const ctx = {
req: activeCtx
};
beforeEach(() => { // beforeEach(() => {
spyOn(LoopBackContext, 'getCurrentContext').and.returnValue({ // spyOn(LoopBackContext, 'getCurrentContext').and.returnValue({
active: activeCtx // active: activeCtx
}); // });
}); // });
it('should create a new starred module and then remove it by calling the method again with same args', async() => { 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'); const starredModule = await models.StarredModule.toggleStarredModule(ctx, 'order');
@ -26,7 +16,7 @@ describe('toggleStarredModule()', () => {
expect(starredModules.length).toEqual(1); expect(starredModules.length).toEqual(1);
expect(starredModule.moduleFk).toEqual('order'); expect(starredModule.moduleFk).toEqual('order');
expect(starredModule.workerFk).toEqual(activeCtx.accessToken.userId); expect(starredModule.workerFk).toEqual(ctx.req.accessToken.userId);
expect(starredModule.position).toEqual(starredModules.length); expect(starredModule.position).toEqual(starredModules.length);
await models.StarredModule.toggleStarredModule(ctx, 'order'); await models.StarredModule.toggleStarredModule(ctx, 'order');

View File

@ -9,7 +9,7 @@
}, },
"vn": { "vn": {
"view": { "view": {
"expeditionPallet_Print": "288cbd6e8289df083ed5eb1a2c808f7a82ba4c90c8ad9781104808a7a54471fb" "expeditionPallet_Print": "06613719475fcdba8309607c38cc78efc2e348cca7bc96b48dc3ae3c12426f54"
} }
} }
} }

View File

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

View File

@ -1,19 +1,9 @@
const models = require('vn-loopback/server/server').models; const models = require('vn-loopback/server/server').models;
const LoopBackContext = require('loopback-context'); const {mockLoopBackContext} = require('vn-loopback/../../back/vn-jasmine');
describe('Model rewriteDbError()', () => { describe('Model rewriteDbError()', () => {
beforeAll(async() => { beforeAll(async() => {
const activeCtx = { mockLoopBackContext();
accessToken: {userId: 9},
http: {
req: {
headers: {origin: 'http://localhost'}
}
}
};
spyOn(LoopBackContext, 'getCurrentContext').and.returnValue({
active: activeCtx
});
}); });
it('should extend rewriteDbError properties to any model passed', () => { it('should extend rewriteDbError properties to any model passed', () => {

View File

@ -1,20 +1,9 @@
const models = require('vn-loopback/server/server').models; const models = require('vn-loopback/server/server').models;
const LoopBackContext = require('loopback-context'); const {mockLoopBackContext} = require('vn-loopback/../../back/vn-jasmine');
describe('Buy editLatestsBuys()', () => { describe('Buy editLatestsBuys()', () => {
beforeAll(async() => { beforeAll(async() => {
const activeCtx = { mockLoopBackContext();
accessToken: {userId: 9},
http: {
req: {
headers: {origin: 'http://localhost'}
}
}
};
spyOn(LoopBackContext, 'getCurrentContext').and.returnValue({
active: activeCtx
});
}); });
it('should change the value of a given column for the selected buys', async() => { it('should change the value of a given column for the selected buys', async() => {

View File

@ -1,14 +1,9 @@
const LoopBackContext = require('loopback-context');
const models = require('vn-loopback/server/server').models; const models = require('vn-loopback/server/server').models;
const {mockLoopBackContext} = require('vn-loopback/../../back/vn-jasmine');
describe('invoiceInDueDay new()', () => { describe('invoiceInDueDay new()', () => {
beforeAll(async() => { beforeAll(async() => {
const activeCtx = { mockLoopBackContext();
accessToken: {userId: 9},
};
spyOn(LoopBackContext, 'getCurrentContext').and.returnValue({
active: activeCtx
});
}); });
it('should correctly create a new due day', async() => { it('should correctly create a new due day', async() => {

View File

@ -1,5 +1,5 @@
const models = require('vn-loopback/server/server').models; const models = require('vn-loopback/server/server').models;
const LoopBackContext = require('loopback-context'); const {mockLoopBackContext} = require('vn-loopback/../../back/vn-jasmine');
describe('loopback model Supplier', () => { describe('loopback model Supplier', () => {
let supplierOne; let supplierOne;
@ -8,18 +8,7 @@ describe('loopback model Supplier', () => {
beforeAll(async() => { beforeAll(async() => {
supplierOne = await models.Supplier.findById(1); supplierOne = await models.Supplier.findById(1);
supplierTwo = await models.Supplier.findById(442); supplierTwo = await models.Supplier.findById(442);
const activeCtx = { mockLoopBackContext();
accessToken: {userId: 9},
http: {
req: {
headers: {origin: 'http://localhost'}
}
}
};
spyOn(LoopBackContext, 'getCurrentContext').and.returnValue({
active: activeCtx
});
}); });
describe('payMethodFk', () => { describe('payMethodFk', () => {

View File

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

View File

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