feat: implement smoketest and extend host provisioning with template linking

- Add runSmoketest mutation to automate end-to-end verification.

- Add SmoketestExecutor and HostDeleter to support automated testing and cleanup.

- Extend createHost and importHosts to allow linking templates by name or ID.

- Update docs/howtos/cookbook.md with new recipe steps and AI/MCP guidance.

- Update .junie/guidelines.md with new verification and deployment standards.

- Add src/test/template_link.test.ts and update existing tests to cover new functionality.

- Regenerate GraphQL types to match schema updates.
This commit is contained in:
Andreas Hilbig 2026-01-31 11:46:02 +01:00
parent b56255ffaa
commit 67357d0bc3
20 changed files with 690 additions and 50 deletions

View file

@ -140,14 +140,15 @@ Execute the `importTemplates` mutation to create the template and items automati
Verify that the new type is available and correctly mapped by creating a test host and querying it.
#### 1. Create a Test Host
Use the `importHosts` mutation (or `createHost` if IDs are already known) to create a host and explicitly set its `deviceType` to `DistanceTrackerDevice`.
Use the `importHosts` mutation (or `createHost` if IDs are already known) to create a host. Set its `deviceType` to `DistanceTrackerDevice` and link it to the `DISTANCE_TRACKER` template (created in Step 3) using the `templateNames` parameter.
```graphql
mutation CreateTestDistanceTracker($host: String!, $groupNames: [String!]!) {
mutation CreateTestDistanceTracker($host: String!, $groupNames: [String!]!, $templateNames: [String]) {
importHosts(hosts: [{
deviceKey: $host,
deviceType: "DistanceTrackerDevice",
groupNames: $groupNames
groupNames: $groupNames,
templateNames: $templateNames
}]) {
hostid
message
@ -209,8 +210,8 @@ For more details on the input fields, see the [Reference: createHost](../../sche
AI agents should prefer using the `importHosts` MCP tool for provisioning as it allows using names for host groups instead of IDs.
```graphql
mutation CreateNewHost($host: String!, $groups: [Int!]!, $templates: [Int!]!) {
createHost(host: $host, hostgroupids: $groups, templateids: $templates) {
mutation CreateNewHost($host: String!, $groups: [Int!]!, $templates: [Int], $templateNames: [String]) {
createHost(host: $host, hostgroupids: $groups, templateids: $templates, templateNames: $templateNames) {
hostids
error {
message

View file

@ -12,8 +12,14 @@ The project uses [GraphQL Codegen](https://the-guild.dev/graphql/codegen) to gen
- **Generated Output**: `src/schema/generated/graphql.ts`
#### How to Regenerate Types
Whenever you modify any `.graphql` files in the `schema/` directory, you must regenerate the TypeScript types:
Whenever you modify any `.graphql` files in the `schema/` directory, you must regenerate the TypeScript types.
For a one-off update (e.g. in a script or before commit):
```bash
npx graphql-codegen --config codegen.ts
```
If you are a developer and want to watch for schema changes continuously:
```bash
npm run codegen
```