chore: add tests for schema and API config mocking

- Added unit tests for schema loader, mocking Config variables and resolvers.
- Added unit tests for Zabbix API configuration, verifying constants derived from Config.
- Mocked relevant modules and filesystem behaviors to enable isolated testing.
- Optimized imports on all files and include this within a new .junie/guidelines.md file
This commit is contained in:
Andreas Hilbig 2026-01-28 07:34:08 +01:00
parent 5e41aa5cc4
commit 7adaf82c1b
23 changed files with 204 additions and 110 deletions

View file

@ -1,4 +1,3 @@
import {createResolvers} from "../api/resolvers.js";
import {zabbixAPI} from "../datasources/zabbix-api.js";
@ -11,6 +10,13 @@ jest.mock("../datasources/zabbix-api.js", () => ({
}
}));
// Mocking Config
jest.mock("../common_utils.js", () => ({
Config: {
ZABBIX_PERMISSION_TEMPLATE_GROUP_NAME_PREFIX: "CustomPerms"
}
}));
describe("User Rights and Permissions Resolvers", () => {
let resolvers: any;
@ -53,7 +59,7 @@ describe("User Rights and Permissions Resolvers", () => {
}
]);
if (path === "templategroup.get.permissions") return Promise.resolve([
{ groupid: "1001", name: "Permissions/Hostgroup/1001" }
{ groupid: "1001", name: "CustomPerms/Hostgroup/1001" }
]);
return Promise.resolve([]);
});
@ -79,7 +85,7 @@ describe("User Rights and Permissions Resolvers", () => {
}
]);
if (path === "templategroup.get.permissions") return Promise.resolve([
{ groupid: "1002", name: "Permissions/Hostgroup/1002" }
{ groupid: "1002", name: "CustomPerms/Hostgroup/1002" }
]);
return Promise.resolve([]);
});