feat(web-api): include a blocks argument for file uploads#2261
Conversation
Codecov ReportAll modified and coverable lines are covered by tests ✅
✅ All tests successful. No failed tests found. Additional details and impacted files@@ Coverage Diff @@
## main #2261 +/- ##
==========================================
+ Coverage 92.67% 92.71% +0.03%
==========================================
Files 38 38
Lines 10554 10609 +55
Branches 682 683 +1
==========================================
+ Hits 9781 9836 +55
Misses 761 761
Partials 12 12
Flags with carried forward coverage won't be shown. Click here to find out more. 🚀 New features to boost your workflow:
|
WilliamBergamin
left a comment
There was a problem hiding this comment.
Thanks for putting this together 🥇
Left one addressable comment around tests, but this PR is great quality
| .post('/api/files.completeUploadExternal', { | ||
| blocks: '[{"type":"section","text":{"type":"plain_text","text":"Hello"}}]', | ||
| channel_id: 'C010101010', | ||
| files: '[{"id":"F0123456789","title":"test-txt.txt"}]', | ||
| }) |
There was a problem hiding this comment.
Since blocks is optional should we leave this unit test as it is and move this to its own test? 🤔
There was a problem hiding this comment.
@WilliamBergamin Super good call! It also gave us a chance to test content in a more complete unit with the e23b066 changes 🧪 ✨
| A posted message can be formatted with [Block Kit](https://docs.slack.dev/block-kit) using the `blocks` argument instead | ||
| of the `initial_comment` text. | ||
|
|
| const { blocks, channel_id, thread_ts, initial_comment, file_id, title } = upload; | ||
| if (file_id) { | ||
| const compareString = `:::${channel_id}:::${thread_ts}:::${initial_comment}`; | ||
| const compareString = `:::${channel_id}:::${thread_ts}:::${initial_comment}:::${JSON.stringify(blocks)}`; |
There was a problem hiding this comment.
Thanks! 😌
I'm sometimes thankful to use manual testing during development, but I also thinking improving tests according to an above comment could show this change too 🚀
| file_uploads: ExcludeFromUnion<FileUploadV2, 'channel_id' | 'channels' | 'initial_comment' | 'thread_ts'>[]; | ||
| file_uploads: ExcludeFromUnion< | ||
| FileUploadV2, | ||
| 'blocks' | 'channel_id' | 'channels' | 'initial_comment' | 'thread_ts' |
There was a problem hiding this comment.
Alphabetical order 😮 🌟
|
@WilliamBergamin No problem at all! I think file uploading is a useful feature to have 🤖 ✨ Your testing suggestions are once more incredible for testing the right things and I'm feeling confident that these cases continue to work with actual tokens and channel IDs so I will merge this 🚢 💨 |
|
📣 I do think a similar change is needed in the Python |
Summary
This PR includes a
blocksargument for file uploads when using either thefiles.completeUploadExternalmethod or thefilesUploadV2function. Fixes #2208. 📠 ✨Reviewers
Please feel free to upload multiple files or one file multiple times with
blocksusing the following examples! 🤖A bot with the
files:writescope added to a channel is required!Blocks
Single file upload
Multiple file upload
Requirements