@@ -66,43 +66,17 @@ describe('slack-utils', () => {
6666 beforeEach ( ( ) => {
6767 log = { error : sinon . spy ( ) } ;
6868 env = {
69- SLACK_BOT_TOKEN : 'test-bot-token' ,
70- SLACK_SIGNING_SECRET : 'test-signing-secret' ,
71- SLACK_TOKEN_WORKSPACE_INTERNAL : 'test-workspace-token' ,
72- SLACK_OPS_CHANNEL_WORKSPACE_INTERNAL : 'test-ops-channel' ,
69+ slackBotToken : 'test-bot-token' ,
70+ slackSigningSecret : 'test-signing-secret' ,
71+ slackTokenWorkspaceInternal : 'test-workspace-token' ,
72+ slackOpsChannelWorkspaceInternal : 'test-ops-channel' ,
7373 } ;
7474 slackContext = {
7575 channelId : 'C12345678' ,
7676 threadTs : '12345.67890' ,
7777 } ;
7878 } ) ;
7979
80- it ( 'should send a message to Slack when all parameters are valid' , async ( ) => {
81- mockHasText . returns ( true ) ;
82-
83- await say ( env , log , slackContext , 'Test message' ) ;
84-
85- expect ( mockBaseSlackClient . createFrom . calledOnce ) . to . be . true ;
86- expect ( mockBaseSlackClient . createFrom . calledWith ( {
87- channelId : 'C12345678' ,
88- threadTs : '12345.67890' ,
89- env : {
90- SLACK_BOT_TOKEN : 'test-bot-token' ,
91- SLACK_SIGNING_SECRET : 'test-signing-secret' ,
92- SLACK_TOKEN_WORKSPACE_INTERNAL : 'test-workspace-token' ,
93- SLACK_OPS_CHANNEL_WORKSPACE_INTERNAL : 'test-ops-channel' ,
94- } ,
95- } , 'workspace_internal' ) ) . to . be . true ;
96-
97- expect ( mockSlackClient . postMessage . calledOnce ) . to . be . true ;
98- expect ( mockSlackClient . postMessage . calledWith ( {
99- channel : 'C12345678' ,
100- thread_ts : '12345.67890' ,
101- text : 'Test message' ,
102- unfurl_links : false ,
103- } ) ) . to . be . true ;
104- } ) ;
105-
10680 it ( 'should not send message if threadTs is missing or empty' , async ( ) => {
10781 mockHasText . withArgs ( 'C12345678' ) . returns ( true ) ;
10882 mockHasText . withArgs ( '' ) . returns ( false ) ;
@@ -182,32 +156,6 @@ describe('slack-utils', () => {
182156 } ) ) . to . be . true ;
183157 } ) ;
184158
185- it ( 'should handle error when env is missing required properties' , async ( ) => {
186- const incompleteEnv = {
187- SLACK_BOT_TOKEN : 'test-bot-token' ,
188- // Missing other required properties
189- } ;
190-
191- // Make BaseSlackClient.createFrom throw when it receives incomplete env
192- mockBaseSlackClient . createFrom . withArgs ( sinon . match ( {
193- env : sinon . match ( {
194- SLACK_BOT_TOKEN : 'test-bot-token' ,
195- SLACK_SIGNING_SECRET : undefined ,
196- SLACK_TOKEN_WORKSPACE_INTERNAL : undefined ,
197- SLACK_OPS_CHANNEL_WORKSPACE_INTERNAL : undefined ,
198- } ) ,
199- } ) ) . throws ( new Error ( 'Missing required environment variables' ) ) ;
200-
201- await say ( incompleteEnv , log , slackContext , 'Test message' ) ;
202-
203- expect ( log . error . calledOnce ) . to . be . true ;
204- expect ( log . error . calledWith ( 'Error sending Slack message:' , {
205- error : 'Missing required environment variables' ,
206- stack : sinon . match . string ,
207- errorType : 'Error' ,
208- } ) ) . to . be . true ;
209- } ) ;
210-
211159 it ( 'should handle empty message string' , async ( ) => {
212160 mockHasText . returns ( true ) ;
213161
0 commit comments