@bigbinary/neeto-playwright-commons 1.12.10 → 1.12.11
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/index.cjs.js +8 -8
- package/index.cjs.js.map +1 -1
- package/index.d.ts +2 -1
- package/index.js +8 -8
- package/index.js.map +1 -1
- package/package.json +1 -1
package/index.cjs.js
CHANGED
|
@@ -3471,6 +3471,12 @@ const getImagePathAndName = (localImagePath) => {
|
|
|
3471
3471
|
class CustomCommands {
|
|
3472
3472
|
constructor(page, request, baseURL = process.env.BASE_URL) {
|
|
3473
3473
|
this.waitUntilTimeout = (timeout) => new Promise(resolve => setTimeout(resolve, timeout));
|
|
3474
|
+
this.initializeCsrfToken = async () => {
|
|
3475
|
+
this.csrfToken = await this.page
|
|
3476
|
+
.locator("[name='csrf-token']")
|
|
3477
|
+
.getAttribute("content");
|
|
3478
|
+
return this.csrfToken;
|
|
3479
|
+
};
|
|
3474
3480
|
this.interceptMultipleResponses = ({ responseUrl = "", responseStatus = 200, times = 1, baseUrl, customPageContext, timeout = 35000, } = {}) => {
|
|
3475
3481
|
const pageContext = customPageContext !== null && customPageContext !== void 0 ? customPageContext : this.page;
|
|
3476
3482
|
return Promise.all([...new Array(times)].map(() => pageContext.waitForResponse((response) => {
|
|
@@ -3553,12 +3559,13 @@ class CustomCommands {
|
|
|
3553
3559
|
};
|
|
3554
3560
|
this.apiRequest = async ({ url, failOnStatusCode = true, headers: additionalHeaders, body: data, method = "get", params = {}, ...otherOptions }) => {
|
|
3555
3561
|
var _a;
|
|
3562
|
+
const csrfToken = (_a = this.csrfToken) !== null && _a !== void 0 ? _a : (await this.initializeCsrfToken());
|
|
3556
3563
|
const requestOptions = {
|
|
3557
3564
|
failOnStatusCode,
|
|
3558
3565
|
headers: {
|
|
3559
3566
|
...additionalHeaders,
|
|
3560
3567
|
"accept-encoding": "gzip",
|
|
3561
|
-
"x-csrf-token":
|
|
3568
|
+
"x-csrf-token": csrfToken !== null && csrfToken !== void 0 ? csrfToken : "",
|
|
3562
3569
|
},
|
|
3563
3570
|
data,
|
|
3564
3571
|
...otherOptions,
|
|
@@ -3648,13 +3655,6 @@ class CustomCommands {
|
|
|
3648
3655
|
this.responses = [];
|
|
3649
3656
|
this.request = request;
|
|
3650
3657
|
this.baseURL = baseURL;
|
|
3651
|
-
this.page
|
|
3652
|
-
.locator("[name='csrf-token']")
|
|
3653
|
-
.getAttribute("content")
|
|
3654
|
-
.then(csrfToken => {
|
|
3655
|
-
this.csrfToken = csrfToken;
|
|
3656
|
-
}, reason => console.error(reason) // eslint-disable-line
|
|
3657
|
-
);
|
|
3658
3658
|
}
|
|
3659
3659
|
}
|
|
3660
3660
|
|