From cf5012b1e37d196fe33588e43f6cee45d2e39edb Mon Sep 17 00:00:00 2001 From: gcch Date: Tue, 5 May 2026 09:23:41 +0200 Subject: [PATCH] 2026-05-05 --- mise.lock | 32 +++++++++++++++++++ mise.toml | 1 + tests/playwright/shop.spec.ts | 58 ++++++++++++++++++++++------------- tsconfig.json | 2 +- 4 files changed, 71 insertions(+), 22 deletions(-) diff --git a/mise.lock b/mise.lock index 7abb424e..9c1793c2 100644 --- a/mise.lock +++ b/mise.lock @@ -1,5 +1,37 @@ # @generated - this file is auto-generated by `mise lock` https://mise.en.dev/dev-tools/mise-lock.html +[[tools."aqua:blopker/codebook"]] +version = "0.3.39" +backend = "aqua:blopker/codebook" + +[tools."aqua:blopker/codebook"."platforms.linux-arm64"] +checksum = "sha256:38302c6e719ce67083e9229c373943ebe45aa359a7a2cfb06e48221c33b59516" +url = "https://github.com/blopker/codebook/releases/download/v0.3.39/codebook-lsp-aarch64-unknown-linux-musl.tar.gz" + +[tools."aqua:blopker/codebook"."platforms.linux-arm64-musl"] +checksum = "sha256:38302c6e719ce67083e9229c373943ebe45aa359a7a2cfb06e48221c33b59516" +url = "https://github.com/blopker/codebook/releases/download/v0.3.39/codebook-lsp-aarch64-unknown-linux-musl.tar.gz" + +[tools."aqua:blopker/codebook"."platforms.linux-x64"] +checksum = "sha256:fdb419ed332aacba5757a3b34ec2a8cba3a94b50134ab34a8dc1af8106101dc5" +url = "https://github.com/blopker/codebook/releases/download/v0.3.39/codebook-lsp-x86_64-unknown-linux-musl.tar.gz" + +[tools."aqua:blopker/codebook"."platforms.linux-x64-musl"] +checksum = "sha256:fdb419ed332aacba5757a3b34ec2a8cba3a94b50134ab34a8dc1af8106101dc5" +url = "https://github.com/blopker/codebook/releases/download/v0.3.39/codebook-lsp-x86_64-unknown-linux-musl.tar.gz" + +[tools."aqua:blopker/codebook"."platforms.macos-arm64"] +checksum = "sha256:c3f8f36a4747542ece10c65cd8dd724aa0dbd31c08a1fd03fb53813eff87b8ce" +url = "https://github.com/blopker/codebook/releases/download/v0.3.39/codebook-lsp-aarch64-apple-darwin.tar.gz" + +[tools."aqua:blopker/codebook"."platforms.macos-x64"] +checksum = "sha256:b3392e8eb080f3e6e083ada59bafcc6e50681d99b0cbd4f420ab4c7123d08baa" +url = "https://github.com/blopker/codebook/releases/download/v0.3.39/codebook-lsp-x86_64-apple-darwin.tar.gz" + +[tools."aqua:blopker/codebook"."platforms.windows-x64"] +checksum = "sha256:dc6c89bdd9e20c00de10d8eb68ffc0e581831eae5a62c9e4efd25905eba78413" +url = "https://github.com/blopker/codebook/releases/download/v0.3.39/codebook-lsp-x86_64-pc-windows-msvc.zip" + [[tools."aqua:numtide/treefmt"]] version = "2.5.0" backend = "aqua:numtide/treefmt" diff --git a/mise.toml b/mise.toml index 3b01852c..6398b18f 100644 --- a/mise.toml +++ b/mise.toml @@ -6,6 +6,7 @@ watchexec = "latest" "aqua:numtide/treefmt" = "latest" "github:AJenbo/phpantom_lsp" = "latest" + "aqua:blopker/codebook" = "latest" [tasks.format] alias = "f" diff --git a/tests/playwright/shop.spec.ts b/tests/playwright/shop.spec.ts index 465f4816..571b38f5 100644 --- a/tests/playwright/shop.spec.ts +++ b/tests/playwright/shop.spec.ts @@ -1,38 +1,34 @@ /** @effect-diagnostics asyncFunction:skip-file */ import type { APIRequestContext, Locator, Page, Response } from "@playwright/test"; import { expect, test } from "@playwright/test"; +import { Effect, ManagedRuntime } from "effect"; +import { ATTRIBUT_PAGE } from "../../web/app/themes/haiku-atelier-2024/src/scripts/constantes/dom.ts"; import type { WCV3Products } from "../../web/app/themes/haiku-atelier-2024/src/scripts/lib/types/api/v3/products"; +import ShopPageRuntime from "../../web/app/themes/haiku-atelier-2024/src/scripts/page-boutique/runtime.ts"; +import ShopPageElements from "../../web/app/themes/haiku-atelier-2024/src/scripts/page-boutique/service-elements.ts"; import type { BackendHeaders } from "./utils.ts"; import { getBackendHeadersFromHtml } from "./utils.ts"; +import { APIClient } from "../../web/app/themes/haiku-atelier-2024/src/scripts-effect/lib/api.ts"; test.describe.configure({ mode: "parallel", timeout: 60_000 }); -test("can scroll to the end of the grid", async ({ page }): Promise => { - await scrollToGridsEnd(page); -}); +/** _Runtime_ pour effectuer les appels API. */ +const TestRuntime = ManagedRuntime.make(APIClient.Live); -test("can access all Products' pages", async ({ page, request }): Promise => { - await page["goto"]("https://haikuatelier.gcch.local/shop/"); - const links = await getAllProductsLinks(page, request); +test("can do stuff", async ({ page }) => { + await page.goto("https://haikuatelier.gcch.local/shop/"); - for (const link of links) { - // Vérifie que le lien de la page retourne OK. - const req = await request.get(link); - await expect(req, "The Product's page is accessible").toBeOK(); - } -}); + const doStuff = Effect.fn("doStuff")(function*() { + const Elements = yield* ShopPageElements; -const getAllProductsLinks = async (page: Page, request: APIRequestContext): Promise> => { - const backendHeaders: BackendHeaders = await getBackendHeadersFromHtml(page); - const response = await request.get("/wp-json/wc/v3/products?page=1&per_page=100&status=publish", { - headers: { Authorization: `Basic ${backendHeaders.authString}`, Nonce: backendHeaders.nonce }, + expect(Elements.ProductsGrid.getAttribute(ATTRIBUT_PAGE)).toBe(1); }); - const json = (await response.json()) as WCV3Products; - return json.map(p => p.permalink); -}; -const scrollToGridsEnd = async (page: Page): Promise => { - await page["goto"]("https://haikuatelier.gcch.local/shop/"); + ShopPageRuntime.runSync(doStuff()); +}); + +test.skip("can scroll to the end of the grid", async ({ page }): Promise => { + await page.goto("https://haikuatelier.gcch.local/shop/"); let hasMoreProducts = true; let currentPageNumber = "1"; @@ -67,4 +63,24 @@ const scrollToGridsEnd = async (page: Page): Promise => { hasMoreProducts = false; } } +}); + +test.skip("can access all Products' pages", async ({ page, request }): Promise => { + 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); + await expect(req, "The Product's page is accessible").toBeOK(); + } +}); + +const getAllProductsLinks = async (page: Page, request: APIRequestContext): Promise> => { + const backendHeaders: BackendHeaders = await getBackendHeadersFromHtml(page); + const response = await request.get("/wp-json/wc/v3/products?page=1&per_page=100&status=publish", { + headers: { Authorization: `Basic ${backendHeaders.authString}`, Nonce: backendHeaders.nonce }, + }); + const json = (await response.json()) as WCV3Products; + return json.map(p => p.permalink); }; diff --git a/tsconfig.json b/tsconfig.json index 42793b84..56330120 100755 --- a/tsconfig.json +++ b/tsconfig.json @@ -39,7 +39,7 @@ { "diagnosticSeverity": { "anyUnknownInErrorContext": "error", - "asyncFunction": "warning", + "asyncFunction": "off", "catchAllToMapError": "error", "catchUnfailableEffect": "error", "classSelfMismatch": "error",