Enable POST data body override on native automation#8428
Closed
akcyp wants to merge 1 commit intoDevExpress:masterfrom
Closed
Enable POST data body override on native automation#8428akcyp wants to merge 1 commit intoDevExpress:masterfrom
akcyp wants to merge 1 commit intoDevExpress:masterfrom
Conversation
|
Thank you for your contribution to TestCafe. When a member of the TestCafe team becomes available, they will review this PR. |
|
This pull request has been automatically marked as stale because it has not had any activity for a long period. It will be closed and archived if no further activity occurs. However, we may return to this pull request in the future. If it is still relevant or you have any additional information regarding it, please leave a comment and we will keep it open. |
|
We're closing this pull request after a prolonged period of inactivity. If it is still relevant, please ask for this pull request to be reopened. Thank you. |
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.
Purpose
Currently overriding POST data body is only possible when running tests with
--disable-native-automation.Take a look at following example:
This PR will allow this value to be overridden in RequestHooks also when running tests on native automation.
Approach
Based on https://chromedevtools.github.io/devtools-protocol/tot/Fetch/#method-continueRequest we can achieve this feature by just adding
postDataencoded to base64 to contineRequest props.This is already done at
_createContinueEventArgsto fix upload-like requests:The only thing I've noticed that could be improved is that in the case of
--disable-native-automation, we need to explicitly correct thecontent-lengthheader.In the case of native automation, after implementing this feature, the user shouldn't change it, as it leads to query failures, so the example RequestHook would look like this:
class TestHook extends RequestHook { constructor() { super([ { url: /echo.free.beeceptor.com/, method: 'POST' }, ], { includeBody: true, includeHeaders: true, }); } async onRequest(requestEvent: RequestEvent & { requestOptions: any }) { const mockResponse = Buffer.from(JSON.stringify({ test: 'override' })); requestEvent.requestOptions.body = mockResponse; - requestEvent.requestOptions.headers['content-length'] = mockResponse.length.toString(); }Pre-Merge TODO