Skip to content

Commit e3088f0

Browse files
committed
Undo changes to Slack integration
1 parent 6bda9b4 commit e3088f0

File tree

2 files changed

+17
-53
lines changed

2 files changed

+17
-53
lines changed

tests/e2e/reporters/slack-reporter.ts

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -18,14 +18,6 @@ function slugifyForFileName( input: string ): string {
1818

1919
class SlackReporter implements Reporter {
2020
onTestEnd( test: TestCase, result: TestResult ) {
21-
// Skip if Slack is not properly configured
22-
if (
23-
! process.env.E2E_SLACK_TOKEN ||
24-
! process.env.E2E_SLACK_CHANNEL_ID
25-
) {
26-
return;
27-
}
28-
2921
// If the test has already failed, we don't want to send a duplicate message.
3022
if ( result.retry !== 0 ) {
3123
return;

tests/e2e/utils/slack.ts

Lines changed: 17 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -51,9 +51,7 @@ let web: WebClient;
5151
*/
5252
const initializeWeb = (): WebClient => {
5353
if ( ! web ) {
54-
web = new WebClient( E2E_SLACK_TOKEN, {
55-
timeout: 10000, // 10 second timeout to prevent hanging
56-
} );
54+
web = new WebClient( E2E_SLACK_TOKEN );
5755
}
5856
return web;
5957
};
@@ -115,45 +113,27 @@ export const sendFailedTestMessageToSlack = async ( testName: string ) => {
115113
const { branch, commit, webUrl } = slackParams;
116114
const webClient = initializeWeb();
117115

118-
// Add timeout to prevent hanging
119-
const timeoutPromise = new Promise( ( _, reject ) => {
120-
setTimeout( () => reject( new Error( 'Slack API timeout' ) ), 10000 );
121-
} );
122-
123116
try {
124117
// Adding the app does not add the app user to the channel
125-
await Promise.race( [
126-
webClient.conversations.join( {
127-
channel: E2E_SLACK_CHANNEL_ID,
128-
token: E2E_SLACK_TOKEN,
129-
} ),
130-
timeoutPromise,
131-
] );
118+
await webClient.conversations.join( {
119+
channel: E2E_SLACK_CHANNEL_ID,
120+
token: E2E_SLACK_TOKEN,
121+
} );
132122
} catch ( error ) {
133-
// Handle the case where the bot is already in the channel
134-
if ( ( error as CodedError ).code === 'already_in_channel' ) {
135-
// This is expected and not an error - the bot is already in the channel
136-
console.log( 'Bot is already in the Slack channel' );
137-
} else {
138-
handleRequestError( error, 'Failed to join the channel' );
139-
return; // Don't proceed if we can't join the channel
140-
}
123+
handleRequestError( error, 'Failed to join the channel' );
141124
}
142125

143126
try {
144-
await Promise.race( [
145-
webClient.chat.postMessage( {
146-
channel: E2E_SLACK_CHANNEL_ID,
147-
token: E2E_SLACK_TOKEN,
148-
text: `Test failed on *${ branch }* branch. \n
127+
await webClient.chat.postMessage( {
128+
channel: E2E_SLACK_CHANNEL_ID,
129+
token: E2E_SLACK_TOKEN,
130+
text: `Test failed on *${ branch }* branch. \n
149131
The commit this build is testing is *${ commit }*. \n
150132
The name of the test that failed: *${ testName }*. \n
151133
See screenshot of the failed test below. ${
152134
webUrl ? `*Build log* can be found here: ${ webUrl }` : ''
153135
}`,
154-
} ),
155-
timeoutPromise,
156-
] );
136+
} );
157137
} catch ( error ) {
158138
handleRequestError( error, 'Failed to post message to Slack' );
159139
}
@@ -173,21 +153,13 @@ export const sendFailedTestScreenshotToSlack = async (
173153
const filename = `screenshot_of_${ testName || 'failed_test' }.png`;
174154
const webClient = initializeWeb();
175155

176-
// Add timeout to prevent hanging
177-
const timeoutPromise = new Promise( ( _, reject ) => {
178-
setTimeout( () => reject( new Error( 'Slack API timeout' ) ), 15000 );
179-
} );
180-
181156
try {
182-
await Promise.race( [
183-
webClient.filesUploadV2( {
184-
filename,
185-
file: createReadStream( screenshotOfFailedTest ),
186-
token: E2E_SLACK_TOKEN,
187-
channel_id: E2E_SLACK_CHANNEL_ID,
188-
} ),
189-
timeoutPromise,
190-
] );
157+
await webClient.filesUploadV2( {
158+
filename,
159+
file: createReadStream( screenshotOfFailedTest ),
160+
token: E2E_SLACK_TOKEN,
161+
channel_id: E2E_SLACK_CHANNEL_ID,
162+
} );
191163
} catch ( error ) {
192164
handleRequestError( error, 'Failed to upload screenshot to Slack' );
193165
}

0 commit comments

Comments
 (0)