refactor: refs #6436 end first wave of changes in modules
gitea/salix/pipeline/pr-dev This commit looks good
Details
gitea/salix/pipeline/pr-dev This commit looks good
Details
This commit is contained in:
parent
665d03f048
commit
944355d54f
|
@ -1,19 +1,11 @@
|
||||||
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('ticket moveExpeditions()', () => {
|
describe('ticket moveExpeditions()', () => {
|
||||||
beforeAll(async() => {
|
const {ctx} = beforeAll;
|
||||||
mockLoopBackContext();
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should move the selected expeditions to new ticket', async() => {
|
it('should move the selected expeditions to new ticket', async() => {
|
||||||
const tx = await models.Expedition.beginTransaction({});
|
const tx = await models.Expedition.beginTransaction({});
|
||||||
const ctx = {
|
const myCtx = ctx;
|
||||||
req: {accessToken: {userId: 9}},
|
|
||||||
args: {},
|
|
||||||
params: {}
|
|
||||||
};
|
|
||||||
const myCtx = Object.assign({}, ctx);
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const options = {transaction: tx};
|
const options = {transaction: tx};
|
||||||
|
@ -28,7 +20,7 @@ describe('ticket moveExpeditions()', () => {
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
const ticket = await models.Expedition.moveExpeditions(myCtx, options);
|
const ticket = await models.Expedition.moveExpeditions(ctx, options);
|
||||||
|
|
||||||
const newestTicketIdInFixtures = 27;
|
const newestTicketIdInFixtures = 27;
|
||||||
|
|
||||||
|
|
|
@ -1,14 +1,12 @@
|
||||||
const models = require('vn-loopback/server/server').models;
|
const models = require('vn-loopback/server/server').models;
|
||||||
|
|
||||||
describe('ticket isEditableOrThrow()', () => {
|
describe('ticket isEditableOrThrow()', () => {
|
||||||
|
const {ctx} = beforeAll;
|
||||||
it('should throw an error as the ticket does not exist', async() => {
|
it('should throw an error as the ticket does not exist', async() => {
|
||||||
const tx = await models.Ticket.beginTransaction({});
|
const tx = await models.Ticket.beginTransaction({});
|
||||||
let error;
|
let error;
|
||||||
try {
|
try {
|
||||||
const options = {transaction: tx};
|
const options = {transaction: tx};
|
||||||
const ctx = {
|
|
||||||
req: {accessToken: {userId: 9}}
|
|
||||||
};
|
|
||||||
|
|
||||||
await models.Ticket.isEditableOrThrow(ctx, 9999, options);
|
await models.Ticket.isEditableOrThrow(ctx, 9999, options);
|
||||||
await tx.rollback();
|
await tx.rollback();
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
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('ticket merge()', () => {
|
describe('ticket merge()', () => {
|
||||||
|
const {ctx} = beforeAll;
|
||||||
const tickets = {
|
const tickets = {
|
||||||
originId: 13,
|
originId: 13,
|
||||||
destinationId: 12,
|
destinationId: 12,
|
||||||
|
@ -10,16 +10,6 @@ describe('ticket merge()', () => {
|
||||||
workerFk: 1
|
workerFk: 1
|
||||||
};
|
};
|
||||||
|
|
||||||
beforeAll(async() => {
|
|
||||||
mockLoopBackContext();
|
|
||||||
});
|
|
||||||
|
|
||||||
const ctx = {
|
|
||||||
req: {
|
|
||||||
accessToken: {userId: 9},
|
|
||||||
headers: {origin: 'http://localhost:5000'},
|
|
||||||
}
|
|
||||||
};
|
|
||||||
ctx.req.__ = value => {
|
ctx.req.__ = value => {
|
||||||
return value;
|
return value;
|
||||||
};
|
};
|
||||||
|
|
|
@ -3,6 +3,7 @@ const ForbiddenError = require('vn-loopback/util/forbiddenError');
|
||||||
|
|
||||||
describe('ticket recalculateComponents()', () => {
|
describe('ticket recalculateComponents()', () => {
|
||||||
const ticketId = 11;
|
const ticketId = 11;
|
||||||
|
const {ctx} = beforeAll;
|
||||||
|
|
||||||
it('should update the ticket components', async() => {
|
it('should update the ticket components', async() => {
|
||||||
const tx = await models.Ticket.beginTransaction({});
|
const tx = await models.Ticket.beginTransaction({});
|
||||||
|
@ -10,7 +11,6 @@ describe('ticket recalculateComponents()', () => {
|
||||||
try {
|
try {
|
||||||
const options = {transaction: tx};
|
const options = {transaction: tx};
|
||||||
|
|
||||||
const ctx = {req: {accessToken: {userId: 9}}};
|
|
||||||
const response = await models.Ticket.recalculateComponents(ctx, ticketId, options);
|
const response = await models.Ticket.recalculateComponents(ctx, ticketId, options);
|
||||||
|
|
||||||
expect(response.affectedRows).toBeDefined();
|
expect(response.affectedRows).toBeDefined();
|
||||||
|
@ -29,7 +29,6 @@ describe('ticket recalculateComponents()', () => {
|
||||||
try {
|
try {
|
||||||
const options = {transaction: tx};
|
const options = {transaction: tx};
|
||||||
|
|
||||||
const ctx = {req: {accessToken: {userId: 9}}};
|
|
||||||
const immutableTicketId = 1;
|
const immutableTicketId = 1;
|
||||||
await models.Ticket.recalculateComponents(ctx, immutableTicketId, options);
|
await models.Ticket.recalculateComponents(ctx, immutableTicketId, options);
|
||||||
|
|
||||||
|
|
|
@ -1,13 +1,13 @@
|
||||||
const models = require('vn-loopback/server/server').models;
|
const models = require('vn-loopback/server/server').models;
|
||||||
|
|
||||||
describe('ticket sendSms()', () => {
|
describe('ticket sendSms()', () => {
|
||||||
|
const {ctx} = beforeAll;
|
||||||
it('should send a message and log it', async() => {
|
it('should send a message and log it', async() => {
|
||||||
const tx = await models.Ticket.beginTransaction({});
|
const tx = await models.Ticket.beginTransaction({});
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const options = {transaction: tx};
|
const options = {transaction: tx};
|
||||||
|
|
||||||
const ctx = {req: {accessToken: {userId: 9}}};
|
|
||||||
const id = 11;
|
const id = 11;
|
||||||
const destination = 222222222;
|
const destination = 222222222;
|
||||||
const message = 'this is the message created in a test';
|
const message = 'this is the message created in a test';
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
const app = require('vn-loopback/server/server');
|
const app = require('vn-loopback/server/server');
|
||||||
|
|
||||||
describe('Worker absences()', () => {
|
describe('Worker absences()', () => {
|
||||||
|
const {ctx} = beforeAll;
|
||||||
it('should get the absence calendar for a full year contract', async() => {
|
it('should get the absence calendar for a full year contract', async() => {
|
||||||
const ctx = {req: {accessToken: {userId: 1106}}};
|
const ctx = {req: {accessToken: {userId: 1106}}};
|
||||||
const workerId = 1106;
|
const workerId = 1106;
|
||||||
|
@ -20,7 +21,6 @@ describe('Worker absences()', () => {
|
||||||
|
|
||||||
it('should get the absence calendar for a permanent contract', async() => {
|
it('should get the absence calendar for a permanent contract', async() => {
|
||||||
const businessId = 1106;
|
const businessId = 1106;
|
||||||
const ctx = {req: {accessToken: {userId: 9}}};
|
|
||||||
|
|
||||||
const now = Date.vnNew();
|
const now = Date.vnNew();
|
||||||
const year = now.getFullYear();
|
const year = now.getFullYear();
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
const models = require('vn-loopback/server/server').models;
|
const models = require('vn-loopback/server/server').models;
|
||||||
|
|
||||||
describe('department getLeaves()', () => {
|
describe('department getLeaves()', () => {
|
||||||
const ctx = {req: {accessToken: {userId: 9}}};
|
const {ctx} = beforeAll;
|
||||||
it('should return the department and the childs containing the search value', async() => {
|
it('should return the department and the childs containing the search value', async() => {
|
||||||
let result = await models.Department.getLeaves(ctx, null, 'INFORMATICA');
|
let result = await models.Department.getLeaves(ctx, null, 'INFORMATICA');
|
||||||
|
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
const app = require('vn-loopback/server/server');
|
const app = require('vn-loopback/server/server');
|
||||||
|
|
||||||
describe('worker mySubordinates()', () => {
|
describe('worker mySubordinates()', () => {
|
||||||
|
const {ctx} = beforeAll;
|
||||||
it('should return an array of subordinates greather than 1', async() => {
|
it('should return an array of subordinates greather than 1', async() => {
|
||||||
let ctx = {req: {accessToken: {userId: 9}}};
|
|
||||||
let result = await app.models.Worker.mySubordinates(ctx);
|
let result = await app.models.Worker.mySubordinates(ctx);
|
||||||
|
|
||||||
expect(result.length).toBeGreaterThan(1);
|
expect(result.length).toBeGreaterThan(1);
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
const app = require('vn-loopback/server/server');
|
const app = require('vn-loopback/server/server');
|
||||||
|
|
||||||
describe('Agency getAgenciesWithWarehouse()', () => {
|
describe('Agency getAgenciesWithWarehouse()', () => {
|
||||||
|
const {ctx} = beforeAll;
|
||||||
const today = Date.vnNew();
|
const today = Date.vnNew();
|
||||||
const ctx = {req: {accessToken: {userId: 9}}};
|
|
||||||
it('should return the agencies that can handle the given delivery request', async() => {
|
it('should return the agencies that can handle the given delivery request', async() => {
|
||||||
const tx = await app.models.Zone.beginTransaction({});
|
const tx = await app.models.Zone.beginTransaction({});
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
const {models} = require('vn-loopback/server/server');
|
const {models} = require('vn-loopback/server/server');
|
||||||
|
|
||||||
describe('Agency landsThatDay()', () => {
|
describe('Agency landsThatDay()', () => {
|
||||||
const ctx = {req: {accessToken: {userId: 9}}};
|
const {ctx} = beforeAll;
|
||||||
const today = Date.vnNew();
|
const today = Date.vnNew();
|
||||||
it('should return a list of agencies that can land a shipment on a day for an address', async() => {
|
it('should return a list of agencies that can land a shipment on a day for an address', async() => {
|
||||||
const tx = await models.Agency.beginTransaction({});
|
const tx = await models.Agency.beginTransaction({});
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
const models = require('vn-loopback/server/server').models;
|
const models = require('vn-loopback/server/server').models;
|
||||||
|
|
||||||
describe('zone getEvents()', () => {
|
describe('zone getEvents()', () => {
|
||||||
const ctx = {req: {accessToken: {userId: 9}}};
|
const {ctx} = beforeAll;
|
||||||
it('should return all events for the specified geo and agency mode', async() => {
|
it('should return all events for the specified geo and agency mode', async() => {
|
||||||
const tx = await models.Zone.beginTransaction({});
|
const tx = await models.Zone.beginTransaction({});
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
const models = require('vn-loopback/server/server').models;
|
const models = require('vn-loopback/server/server').models;
|
||||||
|
|
||||||
describe('zone getLeaves()', () => {
|
describe('zone getLeaves()', () => {
|
||||||
const ctx = {req: {accessToken: {userId: 9}}};
|
const {ctx} = beforeAll;
|
||||||
it('should return the country and the childs containing the search value', async() => {
|
it('should return the country and the childs containing the search value', async() => {
|
||||||
const tx = await models.Zone.beginTransaction({});
|
const tx = await models.Zone.beginTransaction({});
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
const models = require('vn-loopback/server/server').models;
|
const models = require('vn-loopback/server/server').models;
|
||||||
|
|
||||||
describe('zone getUpcomingDeliveries()', () => {
|
describe('zone getUpcomingDeliveries()', () => {
|
||||||
const ctx = {req: {accessToken: {userId: 9}}};
|
const {ctx} = beforeAll;
|
||||||
it('should check returns data', async() => {
|
it('should check returns data', async() => {
|
||||||
const tx = await models.Zone.beginTransaction({});
|
const tx = await models.Zone.beginTransaction({});
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue