test: adding type-level test for chat.postMessage POST bodyParams returning correct type#36456
Draft
ahmed-n-abdeltwab wants to merge 5 commits intoRocketChat:developfrom
Draft
Conversation
Contributor
|
Looks like this PR is not ready to merge, because of the following issues:
Please fix the issues and try again If you have any trouble, please check the PR guidelines |
|
This was referenced Jul 17, 2025
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
This PR adds a test scenario for the POST method of
/v1/chat.postMessage. The purpose is to check whether thebodyParamstype returnsneveror the expectedbodyParamstype content.The test uses type-level assertions with both
ActionTypeandInnerActionTypeto ensure that the return type forbodyParamsis correct. Essentially, it verifies ifbodyParamsreturns its defined type or something else (such asneveror a generic type).Context
Previously, when using the GET method, the returned
bodyParamstype was an abstract version likeRecord<string, unknown>, which is expected because GET does not have a body by default. However, when testing with the POST method, thebodyParamstype was returningneverinstead of its actual defined type. This test is added to validate and prevent such issues in the type inference of our OpenAPI schema definitions.Issue(s) Addressed
roomIDis now required even ifchannelis passed inchat.postMessage. #35923tmidfield in the ChatPostMessage request body schema #36093Steps to Test or Reproduce
Run the type-level tests included in this PR.
Observe the results:
bodyParamstype should return an abstract type likeRecord<string, unknown>, as GET does not define a body schema.bodyParamstype instead ofnever.