2026-04-10
- corvée: met à jour les deps - corvée: formate
This commit is contained in:
parent
00f87fedcd
commit
d50de6d534
85 changed files with 132090 additions and 31346 deletions
|
|
@ -37,7 +37,7 @@ Array.from<TestPage>([
|
|||
},
|
||||
]).forEach(({ pageName, url }) => {
|
||||
test.skip(pageName, async ({ page }, testInfo) => {
|
||||
await page.goto(url);
|
||||
await page["goto"](url);
|
||||
|
||||
const projectName = testInfo.project.name;
|
||||
const timestamp: string = genTimestamp();
|
||||
|
|
|
|||
|
|
@ -1,11 +1,13 @@
|
|||
import { test as base, expect, Response } from "@playwright/test";
|
||||
import {
|
||||
import type { Response } from "@playwright/test";
|
||||
import { expect, test as base } from "@playwright/test";
|
||||
import { pipe } from "effect";
|
||||
import { not } from "effect/Boolean";
|
||||
import type {
|
||||
WCV3Product,
|
||||
WCV3Products,
|
||||
} from "../../web/app/themes/haiku-atelier-2024/src/scripts/lib/types/api/v3/products";
|
||||
import { BackendHeaders, getBackendHeadersFromHtml } from "./utils.ts";
|
||||
import { pipe } from "effect";
|
||||
import { not } from "effect/Boolean";
|
||||
import type { BackendHeaders } from "./utils.ts";
|
||||
import { getBackendHeadersFromHtml } from "./utils.ts";
|
||||
|
||||
/*
|
||||
* Faire un premier test simple où l'on clic sur la première carte du shop
|
||||
|
|
@ -30,7 +32,7 @@ type ProductsKinds = {
|
|||
|
||||
export const test = base.extend<ProductsFixture>({
|
||||
products: async ({ page, request }, use) => {
|
||||
await page.goto("/shop");
|
||||
await page["goto"]("/shop");
|
||||
const backendHeaders: BackendHeaders = await getBackendHeadersFromHtml(page);
|
||||
|
||||
const response = await request.get("/wp-json/wc/v3/products?page=1&per_page=100&status=publish", {
|
||||
|
|
@ -68,7 +70,7 @@ test("can add a Product without variation with stock to the Cart", async ({ page
|
|||
}
|
||||
|
||||
// Va à la page du Produit.
|
||||
await page.goto(randomProduct.permalink);
|
||||
await page["goto"](randomProduct.permalink);
|
||||
|
||||
// Vérifie le bon état du bouton de l'ajout au Panier.
|
||||
const addToCartButton = page.getByRole("button", { disabled: false, name: "Add to cart" });
|
||||
|
|
@ -101,7 +103,7 @@ test("can't add a Product without variation without stock to the Cart", async ({
|
|||
}
|
||||
|
||||
// Va à la page du Produit.
|
||||
await page.goto(randomProduct.permalink);
|
||||
await page["goto"](randomProduct.permalink);
|
||||
|
||||
// Vérifie le bon état du bouton de l'ajout au Panier.
|
||||
const outOfStockButton = page.getByRole("button", { disabled: true, name: "Out of stock" });
|
||||
|
|
|
|||
|
|
@ -1,6 +1,8 @@
|
|||
import { APIRequestContext, expect, Locator, Page, Response, test } 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";
|
||||
import type { APIRequestContext, Locator, Page, Response } from "@playwright/test";
|
||||
import { expect, test } from "@playwright/test";
|
||||
import type { WCV3Products } from "../../web/app/themes/haiku-atelier-2024/src/scripts/lib/types/api/v3/products";
|
||||
import type { BackendHeaders } from "./utils.ts";
|
||||
import { getBackendHeadersFromHtml } from "./utils.ts";
|
||||
|
||||
test.describe.configure({ mode: "parallel", timeout: 60_000 });
|
||||
|
||||
|
|
@ -9,13 +11,13 @@ test("can scroll to the end of the grid", async ({ page }): Promise<void> => {
|
|||
});
|
||||
|
||||
test.skip("can access all Products' pages", async ({ page, request }): Promise<void> => {
|
||||
await page.goto("https://haikuatelier.gcch.local/shop/");
|
||||
await page["goto"]("https://haikuatelier.gcch.local/shop/");
|
||||
const links = await getAllProductsLinks(page, request);
|
||||
|
||||
for (const link of links) {
|
||||
// Vérifie que le lien de la page retourne OK.
|
||||
const req = await request.get(link as string);
|
||||
expect(req, "The Product's page is accessible").toBeOK();
|
||||
const req = await request.get(link);
|
||||
await expect(req, "The Product's page is accessible").toBeOK();
|
||||
}
|
||||
});
|
||||
|
||||
|
|
@ -25,11 +27,11 @@ const getAllProductsLinks = async (page: Page, request: APIRequestContext): Prom
|
|||
headers: { Authorization: `Basic ${backendHeaders.authString}`, Nonce: backendHeaders.nonce },
|
||||
});
|
||||
const json = (await response.json()) as WCV3Products;
|
||||
return json.map((p) => p.permalink);
|
||||
return json.map(p => p.permalink);
|
||||
};
|
||||
|
||||
const scrollToGridsEnd = async (page: Page): Promise<void> => {
|
||||
await page.goto("https://haikuatelier.gcch.local/shop/");
|
||||
await page["goto"]("https://haikuatelier.gcch.local/shop/");
|
||||
|
||||
let hasMoreProducts = true;
|
||||
let currentPageNumber = "1";
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
import { Option, pipe } from "effect";
|
||||
import { Page } from "playwright/test";
|
||||
import type { Page } from "playwright/test";
|
||||
|
||||
export type BackendHeaders = {
|
||||
authString: string;
|
||||
|
|
@ -12,7 +12,7 @@ export type BackendHeaders = {
|
|||
export const getBackendHeadersFromHtml = async (page: Page): Promise<BackendHeaders> => {
|
||||
const backendHeaders: BackendHeaders | undefined = pipe(
|
||||
Option.fromNullishOr(await page.locator("#injection-v2").textContent()),
|
||||
Option.andThen((j) => JSON.parse(j) as BackendHeaders),
|
||||
Option.andThen(j => JSON.parse(j) as BackendHeaders),
|
||||
Option.getOrUndefined,
|
||||
);
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue