Skip to content

Commit e808a42

Browse files
authored
feat: Track number of users invited to Slack #195 (#196)
Add `invitedUserCount` to Slack config.
1 parent 6e58ac9 commit e808a42

File tree

2 files changed

+16
-0
lines changed

2 files changed

+16
-0
lines changed

packages/spacecat-shared-data-access/src/models/site/config.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ export const configSchema = Joi.object({
1717
slack: Joi.object({
1818
workspace: Joi.string(),
1919
channel: Joi.string(),
20+
invitedUserCount: Joi.number().integer().min(0),
2021
}),
2122
alerts: Joi.array().items(Joi.object({
2223
type: Joi.string().required(),

packages/spacecat-shared-data-access/test/unit/models/site/config.test.js

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ describe('Config Tests', () => {
3434
slack: {
3535
channel: 'channel1',
3636
workspace: 'workspace1',
37+
invitedUserCount: 3,
3738
},
3839
alerts: [{
3940
type: '404',
@@ -55,6 +56,7 @@ describe('Config Tests', () => {
5556
const config = Config(data);
5657
expect(config.slack.channel).to.equal('channel1');
5758
expect(config.slack.workspace).to.equal('workspace1');
59+
expect(config.slack.invitedUserCount).to.equal(3);
5860
expect(config.alerts[0].mentions[0].slack[0]).to.equal('id1');
5961
expect(config.alerts[0].byOrg).to.be.true;
6062
expect(config.audits.auditsDisabled()).to.be.false;
@@ -67,6 +69,7 @@ describe('Config Tests', () => {
6769
slack: {
6870
channel: 'channel1',
6971
workspace: 'workspace1',
72+
invitedUserCount: 19,
7073
},
7174
alerts: [{
7275
type: '404',
@@ -78,6 +81,7 @@ describe('Config Tests', () => {
7881
const config = Config(data);
7982
expect(config.slack.channel).to.equal('channel1');
8083
expect(config.slack.workspace).to.equal('workspace1');
84+
expect(config.slack.invitedUserCount).to.equal(19);
8185
expect(config.alerts[0].mentions[0].slack[0]).to.equal('id1');
8286
expect(config.alerts[0].byOrg).to.be.true;
8387
expect(config.audits.auditsDisabled()).to.be.false;
@@ -97,6 +101,17 @@ describe('Config Tests', () => {
97101
};
98102
expect(() => Config(data)).to.throw('Configuration validation error: "alerts[0].type" must be a string');
99103
});
104+
105+
it('throws an error when invitedUserCount is invalid', () => {
106+
const data = {
107+
slack: {
108+
channel: 'channel1',
109+
workspace: 'workspace1',
110+
invitedUserCount: -12,
111+
},
112+
};
113+
expect(() => Config(data)).to.throw('Configuration validation error: "slack.invitedUserCount" must be greater than or equal to 0');
114+
});
100115
});
101116

102117
describe('fromDynamoItem Static Method', () => {

0 commit comments

Comments
 (0)