67 lines
3.1 KiB
JSON
67 lines
3.1 KiB
JSON
{
|
|
"info": {
|
|
"_postman_id": "9c586a0e-2db4-4c70-963c-12b41d983b52",
|
|
"name": "MQTT Test Viewer (HTTP checks)",
|
|
"description": "Read-only checks for the local MQTT test viewer. The collection checks the viewer page and its current snapshot. To publish a test MQTT message, use the manual recipe in postman/README.md; Postman HTTP and MQTT requests must be saved in separate collections.",
|
|
"schema": "https://schema.getpostman.com/json/collection/v2.1.0/collection.json"
|
|
},
|
|
"variable": [
|
|
{
|
|
"key": "viewerUrl",
|
|
"value": "http://127.0.0.1:8080",
|
|
"type": "string"
|
|
}
|
|
],
|
|
"item": [
|
|
{
|
|
"name": "1. Viewer page is available",
|
|
"request": {
|
|
"method": "GET",
|
|
"header": [],
|
|
"url": "{{viewerUrl}}/",
|
|
"description": "Confirms the browser viewer is serving its page."
|
|
},
|
|
"event": [
|
|
{
|
|
"listen": "test",
|
|
"script": {
|
|
"type": "text/javascript",
|
|
"exec": [
|
|
"pm.test('viewer returns HTTP 200', function () { pm.response.to.have.status(200); });",
|
|
"pm.test('viewer page is HTML', function () { pm.expect(pm.response.headers.get('Content-Type')).to.include('text/html'); });",
|
|
"pm.test('page identifies the MQTT message viewer', function () { pm.expect(pm.response.text()).to.include('MQTT message viewer'); });"
|
|
]
|
|
}
|
|
}
|
|
]
|
|
},
|
|
{
|
|
"name": "2. Snapshot shows broker and events",
|
|
"request": {
|
|
"method": "GET",
|
|
"header": [],
|
|
"url": "{{viewerUrl}}/api/snapshot",
|
|
"description": "Returns the current observer connection state, event counts, compatibility evidence, and bounded event history. Run this after publishing MQTT telemetry to check whether the observer received it."
|
|
},
|
|
"event": [
|
|
{
|
|
"listen": "test",
|
|
"script": {
|
|
"type": "text/javascript",
|
|
"exec": [
|
|
"pm.test('snapshot returns HTTP 200 JSON', function () { pm.response.to.have.status(200); pm.expect(pm.response.headers.get('Content-Type')).to.include('application/json'); });",
|
|
"const snapshot = pm.response.json();",
|
|
"pm.test('observer is connected to the broker', function () { pm.expect(snapshot.connection).to.eql('connected'); });",
|
|
"pm.test('snapshot contains event history and counters', function () { pm.expect(snapshot.events).to.be.an('array'); pm.expect(snapshot.counts).to.be.an('object'); pm.expect(snapshot.last_event_id).to.be.a('number'); });",
|
|
"const received = (snapshot.counts && snapshot.counts.message_received) || 0;",
|
|
"pm.test('observer has received at least one MQTT message', function () { pm.expect(received, 'Send telemetry using the MQTT recipe, then run this request again').to.be.above(0); });",
|
|
"const latest = snapshot.events && snapshot.events.length ? snapshot.events[snapshot.events.length - 1] : null;",
|
|
"if (latest) console.log('Latest viewer event:', latest.kind, latest.topic || '', latest.payload && latest.payload.text || '');"
|
|
]
|
|
}
|
|
}
|
|
]
|
|
}
|
|
]
|
|
}
|