-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
FI-705 fix: stricter type of
expect
function
feat: add field `maxIntervalBetweenRequestsInMs` ot abstract class `Page` feat: add examples of `mapBackendResponseErrorToLog`/`mapBackendResponseToLog` tests: more tests of types of selectors methods
- Loading branch information
Showing
9 changed files
with
140 additions
and
48 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
import type {MapBackendResponseErrorToLog} from 'autotests/types/packSpecific'; | ||
|
||
/** | ||
* Maps responses with errors from the backend to "red" logs (as errors) during the test. | ||
* It is assumed that the function will select responses with | ||
* statuse codes of 400 and higher (client and server errors). | ||
* Backend responses with errors are accumulated in separate "red" log step | ||
* (with `logEventStatus: 'failed'`). | ||
* Log the `responseBody` field carefully, as the body of backend response can be very large. | ||
* If the function returns `undefined`, the response is not logged (skipped). | ||
*/ | ||
export const mapBackendResponseErrorToLog: MapBackendResponseErrorToLog = ({ | ||
request, | ||
responseBody, | ||
responseHeaders, | ||
statusCode, | ||
}) => { | ||
if (statusCode < 400) { | ||
return undefined; | ||
} | ||
|
||
const {requestBody, ...requestWithoutBody} = request ?? {}; | ||
|
||
return { | ||
request: { | ||
requestBody: requestBody instanceof Buffer ? String(requestBody) : requestBody, | ||
...requestWithoutBody, | ||
}, | ||
responseBody: responseBody instanceof Buffer ? String(responseBody) : responseBody, | ||
responseHeaders, | ||
}; | ||
}; |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
import type {MapBackendResponseToLog} from 'autotests/types/packSpecific'; | ||
|
||
/** | ||
* Maps responses from the backend to logs during the test. | ||
* Backend responses received during a certain test step are accumulated | ||
* in an array in the `backendResponses` field of the log of this step. | ||
* Log the `responseBody` field carefully, as the body of backend response can be very large. | ||
* If the function returns `undefined`, the response is not logged (skipped). | ||
*/ | ||
export const mapBackendResponseToLog: MapBackendResponseToLog = ({ | ||
request, | ||
responseBody, | ||
responseHeaders, | ||
statusCode, | ||
}) => { | ||
if (statusCode >= 400) { | ||
return undefined; | ||
} | ||
|
||
if (request) { | ||
return {statusCode, url: request?.url}; | ||
} | ||
|
||
return { | ||
responseBody: responseBody instanceof Buffer ? String(responseBody) : responseBody, | ||
responseHeaders, | ||
statusCode, | ||
}; | ||
}; |
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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