fix(notifications): omit empty incident links
This commit is contained in:
1 parent
865fa7cce6
commit
8d1fd61bb4
2 files changed
+19
-1
No files matched your search
@@ -109,7 +109,7 @@ export class RocketChatProvider extends NotificationProvider {
|
||||
});
|
||||
}
|
||||
|
||||
if (message.content.incident) {
|
||||
if (message.content.incident?.url.trim()) {
|
||||
fields.push({
|
||||
title: "Incident",
|
||||
value: message.content.incident.url,
|
||||
|
||||
@@ -201,6 +201,24 @@ describe("RocketChatProvider", () => {
|
||||
]);
|
||||
});
|
||||
|
||||
it("omits the incident field when its URL is empty", async () => {
|
||||
const { provider } = createProvider();
|
||||
const message = makeMessageWithIncident();
|
||||
|
||||
await provider.sendMessage(
|
||||
makeNotification({ type: "rocket_chat" }),
|
||||
makeMessage({
|
||||
content: {
|
||||
...message.content,
|
||||
incident: { ...message.content.incident!, url: "" },
|
||||
},
|
||||
})
|
||||
);
|
||||
|
||||
const fields = mockGotPost.mock.calls[0][1].json.attachments[0].fields;
|
||||
expect(fields).not.toContainEqual(expect.objectContaining({ title: "Incident" }));
|
||||
});
|
||||
|
||||
it("returns false when the message webhook URL is missing", async () => {
|
||||
const { provider } = createProvider();
|
||||
|
||||
|
||||
Reference in new issue
Block a user