temp: transfert entre ordinateurs

This commit is contained in:
gcch 2025-12-23 16:18:28 +01:00
commit d81acac380
46 changed files with 18652 additions and 1328 deletions

View file

@ -1,5 +1,6 @@
import { test, expect, Page, Locator, Response, APIRequestContext } from "@playwright/test";
import { WCV3Products } from "../../web/app/themes/haiku-atelier-2024/src/scripts/lib/types/api/v3/products";
import { BackendHeaders, getBackendHeadersFromHtml } from "./utils.ts";
test.describe.configure({ mode: "parallel", timeout: 60000 });
@ -19,18 +20,9 @@ test("can access all Products' pages", async ({ page, request }): Promise<void>
});
const getAllProductsLinks = async (page: Page, request: APIRequestContext): Promise<Array<string>> => {
const nonce = await page.locator("data#nonce").textContent();
const authString = await page.locator("data#auth-string").textContent();
if (nonce === null || nonce === "") {
throw new Error("Le nonce ne peut être vide.");
}
if (authString === null || authString === "") {
throw new Error("L'en-tête auth-string ne peut être vide.");
}
const backendHeaders: BackendHeaders = await getBackendHeadersFromHtml(page);
const response = await request.get("/wp-json/wc/v3/products?page=1&per_page=100&status=publish", {
headers: { Nonce: nonce, Authorization: `Basic ${authString}` },
headers: { Nonce: backendHeaders.nonce, Authorization: `Basic ${backendHeaders.authString}` },
});
const json = await response.json() as WCV3Products;
const links = json.map(p => p.permalink);
@ -45,14 +37,15 @@ const scrollToGridsEnd = async (page: Page): Promise<void> => {
let currentPageNumber = "1";
const productsGrid: Locator = page.locator(".grille-produits");
await expect(productsGrid).toBeVisible();
await expect(productsGrid, "The Product's grid is visible").toBeVisible();
expect(await (productsGrid.getAttribute("data-page")), "The initial page number attribute is correct").toBe(
currentPageNumber,
);
const showMoreButton: Locator = page.getByRole("button", { name: "Show more" });
await expect(productsGrid).toBeVisible();
await expect(showMoreButton, "The 'Show more' button is visible").toBeVisible();
while (hasMoreProducts) {
expect(await (productsGrid.getAttribute("data-page"))).toBe(currentPageNumber);
const newProductsResponse: Promise<Response> = page.waitForResponse(
new RegExp(".*wp-json\/wc\/v3\/products.*"),
);
@ -65,7 +58,9 @@ const scrollToGridsEnd = async (page: Page): Promise<void> => {
await gridWithNewPageNumber.waitFor();
// Redondance pour expliciter la raison de l'assertion.
expect(await (productsGrid.getAttribute("data-page"))).toBe(newPageNumber);
expect(await (productsGrid.getAttribute("data-page")), "The page number attribute is incremented").toBe(
newPageNumber,
);
currentPageNumber = newPageNumber;
// La fin de la grille est atteint.