-
Notifications
You must be signed in to change notification settings - Fork 399
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Remote functions: Some processEvent unit tests #2203
Conversation
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## feat-functions #2203 +/- ##
==================================================
+ Coverage 81.59% 82.98% +1.39%
==================================================
Files 19 19
Lines 1646 1646
Branches 464 465 +1
==================================================
+ Hits 1343 1366 +23
+ Misses 194 178 -16
+ Partials 109 102 -7 ☔ View full report in Codecov by Sentry. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Couple of open questions to address/leave at your discretion. Thanks for taking the time to do these tests! 🙇🏼♀️
function_execution_id: 'Fx1234', | ||
bot_access_token: 'xowfp', | ||
}, | ||
function_data: { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I had to double-check, but AFAIK, function_data
only is associated with block_actions
payloads – not function_executed
.
{
type: 'function_executed',
function: {
id: 'Fn0695V91LGN',
callback_id: 'sample_function',
title: 'Sample function 1',
description: 'Runs sample function',
type: 'app',
input_parameters: [ [Object] ],
output_parameters: [ [Object] ],
app_id: 'A06A1C8C5FS',
date_created: 1702069571,
date_released: 0,
date_updated: 1723658242,
date_deleted: 0,
form_enabled: false
},
inputs: { user_id: 'U019GD47LJH' },
function_execution_id: 'Fx07HMB67Y3S',
workflow_execution_id: 'Wx07GVLL7ZTP',
event_ts: '1723658328.841355',
bot_access_token: 'xwfp-444'
}
versus
{
type: 'block_actions',
team: { id: 'T019KFN8A2W', domain: 'misscoded' },
enterprise: null,
user: { id: 'U019GD47LJH', name: 'arenz', team_id: 'T019KFN8A2W' },
channel: { id: 'D0699LNQ3HT', name: 'directmessage' },
message: {
user: 'U069CFDKS03',
type: 'message',
ts: '1723658484.749309',
bot_id: 'B069F2HQSFN',
app_id: 'A06A1C8C5FS',
text: 'Click the button to signal the function has completed',
team: 'T019KFN8A2W',
blocks: [ [Object] ],
assistant_app_thread: { title: '', title_blocks: [] }
},
container: {
type: 'message',
message_ts: '1723658484.749309',
channel_id: 'D0699LNQ3HT',
is_ephemeral: false
},
actions: [
{
block_id: 'I9kjf',
action_id: 'sample_button',
type: 'button',
text: [Object],
action_ts: '1723658488.667103'
}
],
api_app_id: 'A06A1C8C5FS',
state: { values: {} },
bot_access_token: 'xwfp-444',
function_data: {
execution_id: 'Fx07GVMA73NH',
function: { callback_id: 'sample_function' },
inputs: { user_id: 'U019GD47LJH' }
},
interactivity: {
interactor: {
secret: 'xxx',
id: 'U019GD47LJH'
},
interactivity_pointer: '7576612985154.1325532282098.90f3e0899eaced8770aaf84abe894dcd'
}
}
await fakeReceiver.sendEvent({ | ||
body: { | ||
event: { | ||
type: 'function_executed', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same comment about payloads above.
@@ -1624,8 +1624,8 @@ function extractFunctionContext(body: StringIndexed) { | |||
|
|||
// interactivity (block_actions) | |||
if (body.function_data) { | |||
functionExecutionId = body.function_data.execution_id; | |||
functionBotAccessToken = body.bot_access_token; | |||
functionExecutionId = body.function_data.execution_id || functionExecutionId; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't follow the logic here: the two conditions never would happen in one go? body.event.type === 'function_executed'
will never be true if body.function_data
is also true, AFAIK, so the fallback would never be anything other than undefined
.
Good call outs - the event payload processing happens in different spots ( Going to close this PR but keep the branch around; the middleware system needs a desperate redesign anyways. |
No description provided.