feat: add weather sensor support and fix device status mapping
This commit introduces support for provisioning weather sensors with geo-coordinates
via user macros and fixes a critical mapping bug in device status.
Changes:
- fix: Corrected DeviceStatus enum mapping (0=ENABLED, 1=DISABLED).
- feat: Added 'status' field to CreateTemplateItem input in GraphQL schema.
- feat: Enabled user macro assignment during host and template creation/import.
- feat: Added regression tests for user macro assignment and HTTP agent URL support.
- docs: Updated cookbook and sample queries to use {$LAT} and {$LON} macros.
- test: Added unit tests for macro assignment in HostImporter and TemplateImporter.
- chore: Regenerated GraphQL types.
This commit is contained in:
parent
5da4a17e36
commit
41e4c4da1f
12 changed files with 251 additions and 60 deletions
|
|
@ -163,4 +163,32 @@ describe("TemplateImporter", () => {
|
|||
expect(result![0].message).toContain("Invalid params.");
|
||||
expect(result![0].message).toContain("the parameter \"key_\" is missing.");
|
||||
});
|
||||
|
||||
test("importTemplates - with macros", async () => {
|
||||
const templates = [{
|
||||
host: "TemplateWithMacros",
|
||||
groupNames: ["Group1"],
|
||||
macros: [
|
||||
{ macro: "{$LAT}", value: "52.52" },
|
||||
{ macro: "{$LON}", value: "13.41" }
|
||||
]
|
||||
}];
|
||||
|
||||
// Mocking group.get
|
||||
(zabbixAPI.post as jest.Mock).mockResolvedValueOnce([{ groupid: "201", name: "Group1" }]);
|
||||
// Mocking template.create
|
||||
(zabbixAPI.post as jest.Mock).mockResolvedValueOnce({ templateids: ["302"] });
|
||||
|
||||
const result = await TemplateImporter.importTemplates(templates, "token");
|
||||
|
||||
expect(result).toHaveLength(1);
|
||||
expect(result![0].templateid).toBe("302");
|
||||
|
||||
// Verify that template.create was called with macros
|
||||
const templateCreateCall = (zabbixAPI.post as jest.Mock).mock.calls.find(call => call[1].body.method === "template.create");
|
||||
expect(templateCreateCall[1].body.params.macros).toEqual([
|
||||
{ macro: "{$LAT}", value: "52.52" },
|
||||
{ macro: "{$LON}", value: "13.41" }
|
||||
]);
|
||||
});
|
||||
});
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue