Skip to content

Commit b19e724

Browse files
committed
test(infra): prevent loop when logging in
1 parent 4b426c1 commit b19e724

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

tests/infra/client.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -252,14 +252,15 @@ class AuthenticatedAPI {
252252
): Promise<APIResponse> {
253253
const request = await this.#wroomRequest;
254254
const { cookies } = await request.storageState();
255-
const xsrf = cookies.find((cookie) => cookie.name === "X_XSRF")?.value;
256-
if (!xsrf) {
255+
const auth = cookies.find((cookie) => cookie.name === "prismic-auth");
256+
if (!auth?.value) {
257257
await this.#logInWroom();
258258
return await this.postWroom(...args);
259259
}
260260

261261
const url = new URL(args[0]);
262-
url.searchParams.set("_", xsrf);
262+
const xsrf = cookies.find((cookie) => cookie.name === "X_XSRF");
263+
if (xsrf) url.searchParams.set("_", xsrf.value);
263264
return await request.post(url.toString(), args[1]);
264265
}
265266

0 commit comments

Comments
 (0)