import { mkdirSync, readFileSync, writeFileSync } from "node:fs"; import { renderToStaticMarkup } from "react-dom/server"; import { describe, expect, it } from "vitest"; import { ProfilePhotoGallery } from "./ProfilePhotoGallery"; import styles from "./profile.module.css"; const photos = Array.from({ length: 10 }, (_, id) => ({ id, url: `/photo-${id}.png`, })); describe("profile photo gallery", () => { it("shows six photos initially and discloses the remaining photos accessibly", () => { const html = renderToStaticMarkup( , ); expect(html.split("Mostra altre foto"); if (process.env.ACCOUNT_VISUAL_FIXTURE) { let css = readFileSync( "src/app/(site)/u/[username]/profile.module.css", "utf8", ); for (const name of ["photos", "photo", "more"]) { const scoped = styles[name]; if (scoped) css = css.replaceAll( new RegExp(`\\.${name}(?=[\\s.{:#>])`, "g"), `.${scoped}`, ); } mkdirSync("storage/account-fixtures", { recursive: true }); writeFileSync( "storage/account-fixtures/photos.html", `

Foto di Alice

${html}
`, ); } }); it("excludes executable URL schemes from full-photo links", () => { const html = renderToStaticMarkup( , ); expect(html).not.toContain(" { expect( renderToStaticMarkup( , ), ).not.toContain("