import {test,expect} from "@playwright/test" for(const width of [320,1440])test("Releases local build is not presented as published and fits/"+width,async({page})=>{ await page.setViewportSize({width,height:900}) await page.route("**/health",r=>r.fulfill({json:{status:"ok"}})) await page.route("**/api/**",r=>r.fulfill({json:new URL(r.request().url()).pathname==="/api/auth/config"?{required:false}:[]})) await page.goto("/releases") await expect(page.getByText("Локальная разработка. Публикация релиза не подтверждена.",{exact:true})).toBeVisible() await expect(page.getByText("Локальная сборка",{exact:true})).toBeVisible() await expect(page.getByText("Сводка коммитов",{exact:true})).toBeVisible() await expect(page.getByRole("link",{name:"Открыть релиз",exact:true})).toHaveCount(0) expect(await page.evaluate(()=>document.documentElement.scrollWidth<=window.innerWidth)).toBe(true) await page.screenshot({path:"docs/ux-ui/screens/releases-local-"+width+".png",fullPage:true}) }) // Server component reads a local manifest. Restore the original bytes even on assertion failure. test("Releases malformed metadata is unknown and long confirmed entries remain readable on mobile",async({page})=>{ const {readFileSync,writeFileSync}=await import("node:fs");const file="public/release-manifest.json";const original=readFileSync(file) const writeManifest=async(content:string|Uint8Array)=>{for(let attempt=0;;attempt++){try{writeFileSync(file,content);return}catch(error){if(attempt>=10||!error||typeof error!=="object"||!("code" in error)||!["UNKNOWN","EBUSY","EPERM","EACCES"].includes(String(error.code)))throw error;await new Promise(resolve=>setTimeout(resolve,100))}}} try{ await page.setViewportSize({width:320,height:900}) await page.route("**/health",r=>r.fulfill({json:{status:"ok"}}));await page.route("**/api/**",r=>r.fulfill({json:new URL(r.request().url()).pathname==="/api/auth/config"?{required:false}:[]})) await writeManifest(JSON.stringify({version:"1.0.0",commits:null}));await page.goto("/releases") await expect(page.getByRole("alert").filter({hasText:"Метаданные релиза недоступны или повреждены"})).toBeVisible() await expect(page.getByText("Нет подтверждённых метаданных.",{exact:true})).toBeVisible() await expect(page.getByRole("link",{name:"Открыть релиз",exact:true})).toHaveCount(0) const sha="a".repeat(40);const subject="fix(ui): "+"ДлинноеОписание".repeat(20) await writeManifest(JSON.stringify({version:"1.0.0",tag:"v1.0.0",publishedAt:"2026-10-03T00:00:00Z",releaseUrl:"https://example.test/releases/tag/v1.0.0",commits:[{sha,shortSha:sha.slice(0,7),subject,author:"Fixture",type:"fix"}]}));await page.reload() await expect(page.getByText("Коммиты манифеста v1.0.0: 1.",{exact:true})).toBeVisible() await expect(page.getByText(subject.replace("fix(ui): ",""),{exact:true})).toBeVisible() const link=page.getByRole("link",{name:"Открыть релиз",exact:true});await expect(link).toHaveAttribute("href","https://example.test/releases/tag/v1.0.0");await expect(link).toHaveAttribute("rel","noopener noreferrer") expect(await page.evaluate(()=>document.documentElement.scrollWidth<=window.innerWidth)).toBe(true) }finally{await writeManifest(original)} })