Skip to content

Commit 03a7bd5

Browse files
test: do not hardcode slack webhook (#86)
1 parent b7b1822 commit 03a7bd5

File tree

1 file changed

+12
-9
lines changed

1 file changed

+12
-9
lines changed

test/integration/slack.test.js renamed to test/e2e/slack.test.js

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5,29 +5,32 @@
55
import { expect } from 'chai';
66
import { describe, it } from 'mocha';
77
import Slack from '../../src/services/Slack.js';
8+
import dotenv from 'dotenv';
89

910
describe('Slack Services', function () {
1011
this.timeout(40000);
1112

13+
before(function () {
14+
console.log("⚠️ Running slack e2e tests with real env vars");
15+
dotenv.config();
16+
if(!process.env.SLACK_DEFAULT_MESSAGE_CHANNEL_WEBHOOK_URL){
17+
console.error("❌ SLACK_DEFAULT_MESSAGE_CHANNEL_WEBHOOK_URL env is not set. Skipping slack e2e tests.");
18+
this.skip();
19+
}
20+
});
21+
1222
describe('sendMessage', function () {
1323
// Happy path
1424
it('should send a message to the default channel', async function () {
1525
const res = await Slack.sendMessage(':mag: <https://github.com/gitcommitshow/rudder-github-app/pull/82|#82: Test message from our GitHub App>\n*Author:* gitcommitshow\n*Created:* Sep 18, 2025 at 10:00 AM\n\n<!channel>', {
16-
webhookUrl: "https://hooks.slack.com/services/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"
26+
webhookUrl: process.env.SLACK_DEFAULT_MESSAGE_CHANNEL_WEBHOOK_URL
1727
});
1828
expect(res).to.not.throw;
1929
});
2030

2131
// Error path 1 - no message
2232
it('should throw an error if the message is not set', async function () {
23-
expect(Slack.sendMessage(null, {
24-
webhookUrl: "https://hooks.slack.com/services/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"
25-
})).to.throw;
26-
});
27-
28-
// Error path 2 - no webhook url
29-
it('should throw an error if the webhook url is not set', async function () {
30-
expect(Slack.sendMessage("testing error path 2 - no webhook url")).to.throw;
33+
expect(Slack.sendMessage()).to.throw;
3134
});
3235
});
3336

0 commit comments

Comments
 (0)