mirror of
https://github.com/gristlabs/grist-core.git
synced 2026-03-02 04:09:24 +00:00
(core) GET endpoint for webhooks returns now data in format {webhooks:[...]}
Summary:
Rework of endpoint GET for webhooks to make it coherent with other endpoints. Now data should be return in {webhooks:[{id:"...",fields:{"..."}]} format
```
{
"webhooks": [
{
"id": ...
"fields": {
"url": ...
"unsubscribeKey": ...
"eventTypes": [
"add",
"update"
],
"isReadyColumn": null,
"tableId": "...",
"enabled": false,
"name": "...",
"memo": "..."
},
"usage": {
"status": "idle",
"numWaiting": 0,
"lastEventBatch": null
}
},
{
"id": "...",
"fields": {
"url": "...",
"unsubscribeKey": "...",
"eventTypes": [
"add",
"update"
],
"isReadyColumn": null,
"tableId": "...",
"enabled": true,
"name": "...",
"memo": "..."
},
"usage": {
"status": "error",
"numWaiting": 0,
"updatedTime": 1689076978098,
"lastEventBatch": {
"status": "rejected",
"httpStatus": 404,
"errorMessage": "{\"success\":false,\"error\":{\"message\":\"Alias 5a9bf6a8-4865-403a-bec6-b4ko not found\",\"id\":null}}",
"size": 49,
"attempts": 5
},
"lastSuccessTime": null,
"lastFailureTime": 1689076978097,
"lastErrorMessage": "{\"success\":false,\"error\":{\"message\":\"Alias 5a9bf6a8-4865-403a-bec6-b4ko not found\",\"id\":null}}",
"lastHttpStatus": 404
}
}
]
}
```
Test Plan: new test added to check if GET data fromat is correct. Other tests fixed to handle changed endpoint.
Reviewers: paulfitz
Reviewed By: paulfitz
Differential Revision: https://phab.getgrist.com/D3966
This commit is contained in:
@@ -2800,9 +2800,23 @@ function testDocApi() {
|
||||
return resp.data;
|
||||
}
|
||||
|
||||
it("GET /docs/{did}/webhooks retrieves a list of webhooks", async function () {
|
||||
const registerResponse = await postWebhookCheck({webhooks:[{fields:{tableId: "Table1", eventTypes: ["add"], url: "https://example.com"}}]}, 200);
|
||||
const resp = await axios.get(`${serverUrl}/api/docs/${docIds.Timesheets}/webhooks`, chimpy);
|
||||
try{
|
||||
assert.equal(resp.status, 200);
|
||||
assert.isAtLeast(resp.data.webhooks.length, 1);
|
||||
assert.containsAllKeys(resp.data.webhooks[0], ['id', 'fields']);
|
||||
assert.containsAllKeys(resp.data.webhooks[0].fields,
|
||||
['enabled', 'isReadyColumn', 'memo', 'name', 'tableId', 'eventTypes', 'url']);
|
||||
}
|
||||
finally{
|
||||
//cleanup
|
||||
await deleteWebhookCheck(registerResponse.webhooks[0].id);
|
||||
}
|
||||
});
|
||||
|
||||
it("POST /docs/{did}/tables/{tid}/_subscribe validates inputs", async function () {
|
||||
|
||||
|
||||
await oldSubscribeCheck({}, 400, /eventTypes is missing/);
|
||||
await oldSubscribeCheck({eventTypes: 0}, 400, /url is missing/, /eventTypes is not an array/);
|
||||
await oldSubscribeCheck({eventTypes: []}, 400, /url is missing/);
|
||||
@@ -2922,7 +2936,7 @@ function testDocApi() {
|
||||
async function getRegisteredWebhooks() {
|
||||
const response = await axios.get(
|
||||
`${serverUrl}/api/docs/${docIds.Timesheets}/webhooks`, chimpy);
|
||||
return response.data;
|
||||
return response.data.webhooks;
|
||||
}
|
||||
|
||||
async function deleteWebhookCheck(webhookId: any) {
|
||||
@@ -3311,7 +3325,7 @@ function testDocApi() {
|
||||
`${serverUrl}/api/docs/${docId}/webhooks`, chimpy
|
||||
);
|
||||
assert.equal(result.status, 200);
|
||||
return result.data;
|
||||
return result.data.webhooks;
|
||||
}
|
||||
|
||||
before(async function () {
|
||||
|
||||
Reference in New Issue
Block a user