@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.d.ts
CHANGED
|
@@ -85,9 +85,10 @@ declare class CustomCommands {
|
|
|
85
85
|
responses: string[];
|
|
86
86
|
request: APIRequestContext;
|
|
87
87
|
baseURL: string | undefined;
|
|
88
|
-
csrfToken: string | null;
|
|
88
|
+
csrfToken: string | null | undefined;
|
|
89
89
|
constructor(page: Page, request: APIRequestContext, baseURL?: string | undefined);
|
|
90
90
|
private waitUntilTimeout;
|
|
91
|
+
private initializeCsrfToken;
|
|
91
92
|
/**
|
|
92
93
|
*
|
|
93
94
|
* Command to wait until a response with URL responseUrl is found. Optionally,
|
package/index.js
CHANGED
|
@@ -3451,6 +3451,12 @@ const getImagePathAndName = (localImagePath) => {
|
|
|
3451
3451
|
class CustomCommands {
|
|
3452
3452
|
constructor(page, request, baseURL = process.env.BASE_URL) {
|
|
3453
3453
|
this.waitUntilTimeout = (timeout) => new Promise(resolve => setTimeout(resolve, timeout));
|
|
3454
|
+
this.initializeCsrfToken = async () => {
|
|
3455
|
+
this.csrfToken = await this.page
|
|
3456
|
+
.locator("[name='csrf-token']")
|
|
3457
|
+
.getAttribute("content");
|
|
3458
|
+
return this.csrfToken;
|
|
3459
|
+
};
|
|
3454
3460
|
this.interceptMultipleResponses = ({ responseUrl = "", responseStatus = 200, times = 1, baseUrl, customPageContext, timeout = 35000, } = {}) => {
|
|
3455
3461
|
const pageContext = customPageContext !== null && customPageContext !== void 0 ? customPageContext : this.page;
|
|
3456
3462
|
return Promise.all([...new Array(times)].map(() => pageContext.waitForResponse((response) => {
|
|
@@ -3533,12 +3539,13 @@ class CustomCommands {
|
|
|
3533
3539
|
};
|
|
3534
3540
|
this.apiRequest = async ({ url, failOnStatusCode = true, headers: additionalHeaders, body: data, method = "get", params = {}, ...otherOptions }) => {
|
|
3535
3541
|
var _a;
|
|
3542
|
+
const csrfToken = (_a = this.csrfToken) !== null && _a !== void 0 ? _a : (await this.initializeCsrfToken());
|
|
3536
3543
|
const requestOptions = {
|
|
3537
3544
|
failOnStatusCode,
|
|
3538
3545
|
headers: {
|
|
3539
3546
|
...additionalHeaders,
|
|
3540
3547
|
"accept-encoding": "gzip",
|
|
3541
|
-
"x-csrf-token":
|
|
3548
|
+
"x-csrf-token": csrfToken !== null && csrfToken !== void 0 ? csrfToken : "",
|
|
3542
3549
|
},
|
|
3543
3550
|
data,
|
|
3544
3551
|
...otherOptions,
|
|
@@ -3628,13 +3635,6 @@ class CustomCommands {
|
|
|
3628
3635
|
this.responses = [];
|
|
3629
3636
|
this.request = request;
|
|
3630
3637
|
this.baseURL = baseURL;
|
|
3631
|
-
this.page
|
|
3632
|
-
.locator("[name='csrf-token']")
|
|
3633
|
-
.getAttribute("content")
|
|
3634
|
-
.then(csrfToken => {
|
|
3635
|
-
this.csrfToken = csrfToken;
|
|
3636
|
-
}, reason => console.error(reason) // eslint-disable-line
|
|
3637
|
-
);
|
|
3638
3638
|
}
|
|
3639
3639
|
}
|
|
3640
3640
|
|