Add persistent gallery card ratio switch
All checks were successful
Deploy Sokko G / deploy (push) Successful in 18s

This commit is contained in:
Shinuwa 2026-09-28 10:09:58 +02:00
parent bd4059c9c1
commit 3f86d863ac
10 changed files with 72 additions and 10 deletions

View file

@ -153,7 +153,20 @@ test("images open a gallery and navigate the current collection without looping"
await expect(dialog).toBeVisible();
const thumbnails = dialog.locator(".image-viewer-gallery-item");
const gallery = dialog.locator(".image-viewer-gallery");
const ratioButton = dialog.locator(".image-viewer-gallery-ratio-button");
await expect(thumbnails).toHaveCount(3);
await expect(ratioButton).toHaveText("4:3");
await expect(ratioButton).toHaveAccessibleName(/Passer au format 1:1/);
const initialCardBox = await thumbnails.first().boundingBox();
expect(initialCardBox.width / initialCardBox.height).toBeCloseTo(4 / 3, 2);
await ratioButton.click();
await expect(ratioButton).toHaveText("1:1");
await expect(ratioButton).toHaveAccessibleName(/Passer au format 4:3/);
await expect.poll(async () => {
const box = await thumbnails.first().boundingBox();
return box.width / box.height;
}).toBeCloseTo(1, 2);
expect(await page.evaluate(() => globalThis.localStorage.getItem("sokkog:image-gallery-card-ratio"))).toBe("1:1");
const initialThumbnailWidth = (await thumbnails.first().boundingBox()).width;
await dialog.getByRole("button", { name: "Agrandir les aperçus", exact: true }).click();
await expect.poll(async () => (await thumbnails.first().boundingBox()).width).toBeCloseTo(initialThumbnailWidth + 40, 0);
@ -163,6 +176,10 @@ test("images open a gallery and navigate the current collection without looping"
await page.reload();
await tool.getByRole("button", { name: "Galerie", exact: true }).click();
await expect.poll(async () => (await thumbnails.first().boundingBox()).width).toBeCloseTo(300, 0);
await expect(ratioButton).toHaveText("1:1");
await ratioButton.click();
await expect(ratioButton).toHaveText("4:3");
expect(await page.evaluate(() => globalThis.localStorage.getItem("sokkog:image-gallery-card-ratio"))).toBe("4:3");
await dialog.getByRole("button", { name: "Réduire les aperçus", exact: true }).click();
await expect.poll(async () => (await thumbnails.first().boundingBox()).width).toBeCloseTo(260, 0);
await dialog.getByRole("button", { name: "Afficher en grand : Second", exact: true }).click();
@ -188,6 +205,8 @@ test("images open a gallery and navigate the current collection without looping"
expect(galleryBox.y).toBeGreaterThanOrEqual(0);
expect(galleryBox.x + galleryBox.width).toBeLessThanOrEqual(390);
expect(galleryBox.y + galleryBox.height).toBeLessThanOrEqual(844);
await ratioButton.click();
await expect(ratioButton).toHaveText("1:1");
const zoomIn = dialog.getByRole("button", { name: "Agrandir les aperçus", exact: true });
for (let step = 0; step < 4; step += 1) await zoomIn.click();
await expect(zoomIn).toBeDisabled();