fix: refs #7917 userId tests
gitea/salix/pipeline/pr-dev There was a failure building this commit
Details
gitea/salix/pipeline/pr-dev There was a failure building this commit
Details
This commit is contained in:
parent
223ccb9a9a
commit
80e8071ae0
|
@ -83,7 +83,7 @@ module.exports = Self => {
|
|||
filter = mergeFilters(ctx.args?.filter ?? {}, {where});
|
||||
const getRouteByAgency = await models.ACL.checkAccessAcl(ctx, 'Route', 'getRouteByAgency', 'WRITE');
|
||||
|
||||
const supplier = await models.Supplier.isSupplier(ctx.req.accessToken.userId, myOptions);
|
||||
const supplier = await models.Supplier.isSupplier(userId, myOptions);
|
||||
if (supplier && getRouteByAgency) {
|
||||
if (!filter.where) filter.where = {};
|
||||
filter.where[`a.supplierFk`] = supplier.id;
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
const app = require('vn-loopback/server/server');
|
||||
|
||||
describe('route getTickets()', () => {
|
||||
fdescribe('route getTickets()', () => {
|
||||
const ctx = beforeAll.getCtx();
|
||||
|
||||
it('should return the tickets for a given route', async() => {
|
||||
|
@ -9,4 +9,22 @@ describe('route getTickets()', () => {
|
|||
|
||||
expect(result.length).toEqual(1);
|
||||
});
|
||||
|
||||
it('should return only routes belonging to the supplier', async() => {
|
||||
const filter = {}; // No especificamos un filtro específico, se debería aplicar el de supplier automáticamente
|
||||
|
||||
// Mock para simular que el usuario es un supplier específico
|
||||
spyOn(app.models.Supplier, 'isSupplier').and.returnValue({
|
||||
id: 1101 // ID del proveedor ficticio
|
||||
});
|
||||
|
||||
let result = await app.models.Route.getTickets(ctx, filter, options);
|
||||
console.log('ctx: ', ctx);
|
||||
|
||||
// Verifica que todas las rutas pertenecen al proveedor simulado
|
||||
expect(result.length).toBeGreaterThan(0);
|
||||
// result.forEach(route => {
|
||||
// expect(route.supplierFk).toEqual(123); // Asegúrate de comparar con el campo adecuado
|
||||
// });
|
||||
});
|
||||
});
|
||||
|
|
Loading…
Reference in New Issue