-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
20 changed files
with
375 additions
and
35 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
exports.up = (pgm) => { | ||
pgm.createType("notification_type", ["report_detail", "degradation"] ) | ||
pgm.addColumn({ schema: "jtl", name: "notifications" }, { | ||
notification_type: { | ||
type: "notification_type", | ||
"default": "report_detail", | ||
notNull: true, | ||
}, | ||
}) | ||
pgm.renameColumn({ schema: "jtl", name: "notifications" }, "type", "channel") | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
55 changes: 55 additions & 0 deletions
55
src/server/utils/notifications/templates/degradation/gchat-degradation-template.spec.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
import { gchatDegradationTemplate } from "./gchat-degradation-template" | ||
|
||
describe("GChat Degradation template", () => { | ||
it("should return correct card payload when url provided", () => { | ||
const template = gchatDegradationTemplate("scenarioName", "http://localhost") | ||
expect(template).toEqual( { | ||
cards: [ | ||
{ | ||
header: { | ||
imageUrl: "", | ||
subtitle: "Performance Degradation Detected for scenario: scenarioName", | ||
title: "JTL Reporter", | ||
}, | ||
sections: [ | ||
{ | ||
widgets: [ | ||
{ | ||
buttons: [ | ||
{ | ||
textButton: { | ||
onClick: { | ||
openLink: { | ||
url: "http://localhost", | ||
}, | ||
}, | ||
text: "OPEN RESULTS", | ||
}, | ||
}, | ||
], | ||
}, | ||
], | ||
}, | ||
], | ||
}, | ||
], | ||
} | ||
) | ||
}) | ||
it("should return card payload when no url provided", () => { | ||
const template = gchatDegradationTemplate("scenarioName", undefined) | ||
expect(template).toEqual({ | ||
cards: [ | ||
{ | ||
header: { | ||
imageUrl: "", | ||
subtitle: "Performance Degradation Detected for scenario: scenarioName", | ||
title: "JTL Reporter", | ||
}, | ||
sections: [], | ||
}, | ||
], | ||
} | ||
) | ||
}) | ||
}) |
35 changes: 35 additions & 0 deletions
35
src/server/utils/notifications/templates/degradation/gchat-degradation-template.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
|
||
export const gchatDegradationTemplate = (scenarioName: string, url) => { | ||
const cardPayload = { | ||
cards: [{ | ||
header: { | ||
title: "JTL Reporter", | ||
subtitle: `Performance Degradation Detected for scenario: ${scenarioName}`, | ||
imageUrl: "", | ||
}, | ||
sections: [], | ||
}], | ||
} | ||
|
||
if (url) { | ||
(cardPayload.cards[0].sections as any).push({ | ||
widgets: [ | ||
{ | ||
buttons: [ | ||
{ | ||
textButton: { | ||
text: "OPEN RESULTS", | ||
onClick: { | ||
openLink: { | ||
url, | ||
}, | ||
}, | ||
}, | ||
}, | ||
], | ||
}, | ||
], | ||
}) | ||
} | ||
return cardPayload | ||
} |
Oops, something went wrong.