temp: transfert entre ordinateurs
This commit is contained in:
parent
a0d91a0ef7
commit
d81acac380
46 changed files with 18652 additions and 1328 deletions
24
tests/playwright/utils.ts
Normal file
24
tests/playwright/utils.ts
Normal file
|
|
@ -0,0 +1,24 @@
|
|||
import { Option, pipe } from "effect";
|
||||
import { Page } from "playwright/test";
|
||||
|
||||
export type BackendHeaders = {
|
||||
authString: string;
|
||||
nonce: string;
|
||||
};
|
||||
|
||||
/**
|
||||
* @throws Lève une exception si la balise du JSON est introuvable.
|
||||
*/
|
||||
export const getBackendHeadersFromHtml = async (page: Page): Promise<BackendHeaders> => {
|
||||
const backendHeaders: BackendHeaders | undefined = pipe(
|
||||
Option.fromNullable(await page.locator("#injection-v2").textContent()),
|
||||
Option.andThen(j => JSON.parse(j) as BackendHeaders),
|
||||
Option.getOrUndefined,
|
||||
);
|
||||
|
||||
if (backendHeaders === undefined) {
|
||||
throw new Error("The JSON of the backend headers in the page's HTML can't be null.");
|
||||
}
|
||||
|
||||
return backendHeaders;
|
||||
};
|
||||
Loading…
Add table
Add a link
Reference in a new issue