add e2e testing on webhooks and booking happy-path (#936)
This commit is contained in:
1 parent
86d292838c
commit
9e69029943
16 files changed
+271
-80
No files matched your search
@@ -8,21 +8,26 @@ const sendPayload = (
|
||||
): Promise<string | Response> =>
|
||||
new Promise((resolve, reject) => {
|
||||
if (!subscriberUrl || !payload) {
|
||||
return reject("Missing required elements to send webhook payload.");
|
||||
return reject(new Error("Missing required elements to send webhook payload."));
|
||||
}
|
||||
const body = {
|
||||
triggerEvent: triggerEvent,
|
||||
createdAt: createdAt,
|
||||
payload: payload,
|
||||
};
|
||||
|
||||
fetch(subscriberUrl, {
|
||||
method: "POST",
|
||||
headers: {
|
||||
"Content-Type": "application/json",
|
||||
},
|
||||
body: JSON.stringify({
|
||||
triggerEvent: triggerEvent,
|
||||
createdAt: createdAt,
|
||||
payload: payload,
|
||||
}),
|
||||
body: JSON.stringify(body),
|
||||
})
|
||||
.then((response) => {
|
||||
if (!response.ok) {
|
||||
reject(new Error(`Response code ${response.status}`));
|
||||
return;
|
||||
}
|
||||
resolve(response);
|
||||
})
|
||||
.catch((err) => {
|
||||
|
||||
Reference in new issue
Block a user