Standardize public images on WebP and add conversion tooling
All checks were successful
Deploy Sokko G / deploy (push) Successful in 20s

This commit is contained in:
Shinuwa 2026-10-23 12:12:02 +02:00
parent 75592d7d7a
commit ca39b76282
883 changed files with 503 additions and 90 deletions

View file

@ -4,9 +4,9 @@ import { readFile } from "node:fs/promises";
import { Buffer } from "node:buffer";
import { fileURLToPath, URL } from "node:url";
const imagePath = fileURLToPath(new URL("../website/public/static/img/toolbox-icons/sword.png", import.meta.url));
const imagePath = fileURLToPath(new URL("../website/public/static/img/toolbox-icons/sword.webp", import.meta.url));
const fixture = JSON.parse(await readFile(new URL("./fixtures/toolbox-export.json", import.meta.url), "utf8"));
const cover = `data:image/png;base64,${(await readFile(imagePath)).toString("base64")}`;
const cover = `data:image/webp;base64,${(await readFile(imagePath)).toString("base64")}`;
const { games } = JSON.parse(await readFile(new URL("../website/public/data/games.json", import.meta.url), "utf8"));
const gameCover = games.find((game) => game.id === "mhwilds").images.cardCover;
@ -43,7 +43,7 @@ test("saves a cropped cover through reload and export/import, then returns to an
const creation = page.getByRole("dialog", { name: "Nouvelle toolbox" });
await creation.getByLabel("Nom").fill("Cover workflow");
await creation.getByRole("button", { name: "Créer" }).click();
await expect(picker(page).locator("img")).toHaveAttribute("src", /toolbox\.png$/);
await expect(picker(page).locator("img")).toHaveAttribute("src", /toolbox\.webp$/);
await picker(page).click();
await page.getByRole("button", { name: "Utiliser l'icône sword", exact: true }).click();
const editor = await uploadCover(page);
@ -59,7 +59,7 @@ test("saves a cropped cover through reload and export/import, then returns to an
await expect(page.getByRole("link", { name: "Ouvrir Cover workflow", exact: true }).first().locator("img")).toHaveAttribute("src", savedCover);
const exported = await exportToolbox(page, "Cover workflow");
expect(exported.toolbox.customCover).toBe(savedCover);
expect(exported.toolbox.icon).toMatch(/sword\.png$/);
expect(exported.toolbox.icon).toMatch(/sword\.webp$/);
exported.toolbox.name = "Imported cover";
await page.getByText("Importer une toolbox", { exact: true }).locator('input[type="file"]').setInputFiles({
name: "export.json", mimeType: "application/json", buffer: Buffer.from(JSON.stringify(exported)),
@ -70,9 +70,9 @@ test("saves a cropped cover through reload and export/import, then returns to an
await expect(page.getByRole("button", { name: "Remplacer l'image de card" })).toHaveAttribute("aria-pressed", "true");
await expect(page.getByRole("button", { name: "Utiliser l'icône sword", exact: true })).toHaveAttribute("aria-pressed", "false");
await page.getByRole("button", { name: "Utiliser l'icône sword", exact: true }).click();
await expect(picker(page).locator("img")).toHaveAttribute("src", /sword\.png$/);
await expect(picker(page).locator("img")).toHaveAttribute("src", /sword\.webp$/);
await page.reload();
await expect(picker(page).locator("img")).toHaveAttribute("src", /sword\.png$/);
await expect(picker(page).locator("img")).toHaveAttribute("src", /sword\.webp$/);
await page.goto("/#/toolboxes");
expect((await exportToolbox(page, "Imported cover")).toolbox.customCover || "").toBe("");
});