const {chromium}=require('playwright'); const assert=require('node:assert/strict'); (async()=>{ const browser=await chromium.launch({headless:true,executablePath:process.env.TEST_CHROME}); try { for(const width of [1440,390]) { const page=await browser.newPage({viewport:{width,height:1000}}); const errors=[];page.on('pageerror',e=>errors.push(e.message)); await page.goto('http://127.0.0.1:7866',{waitUntil:'domcontentloaded'}); const prompt=page.locator('#anima-positive-prompt textarea');await prompt.waitFor(); const negative=page.locator('#anima-negative-prompt textarea'); const oldNegative=await negative.inputValue(); const helper=page.locator('#anima-qwen-prompt'); const source=helper.getByLabel('元になる説明(日本語・英語)',{exact:true}); const instruction=helper.getByLabel('追加・修正の指示(任意)',{exact:true}); const candidate=helper.getByLabel('英語の候補(編集できます)',{exact:true}); assert.equal(await source.isVisible(),false); await helper.getByText('日本語からプロンプトを作成・追加指示を反映(Qwen 3.5 4B)',{exact:true}).click(); await prompt.fill('1girl, solo, red hair, garden'); await helper.getByRole('button',{name:'現在のAnima Promptを取り込む',exact:true}).click(); await page.waitForFunction(()=>[...document.querySelectorAll('textarea')].filter(e=>e.value==='1girl, solo, red hair, garden').length>=2); await instruction.fill('上半身構図と柔らかな日差しだけを追加。'); await helper.getByRole('button',{name:'英語の候補を作成',exact:true}).click(); await page.waitForFunction(()=>[...document.querySelectorAll('textarea')].some(e=>e.value.includes('upper body')&&e.value.includes('sunlight')),{},{timeout:120000}); assert.match(await candidate.inputValue(),/red hair/); assert.equal(await prompt.inputValue(),'1girl, solo, red hair, garden'); await candidate.scrollIntoViewIfNeeded(); await page.screenshot({path:`../outputs/qwen-prompt-${width}.png`}); await candidate.fill('1girl, red hair, garden'); await helper.getByRole('button',{name:'この候補をAnimaのPromptに反映',exact:true}).click(); await page.waitForFunction(()=>document.querySelector('#anima-positive-prompt textarea').value==='1girl, red hair, garden'); assert.equal(await negative.inputValue(),oldNegative); await helper.getByRole('button',{name:'この候補をAnimaのPromptに反映',exact:true}).click(); await helper.getByText('候補作成後にPromptが変更されています。',{exact:false}).waitFor(); await source.fill(''); await helper.getByRole('button',{name:'英語の候補を作成',exact:true}).click(); await helper.getByText('日本語または英語で、元になる説明を入力してください。',{exact:true}).waitFor(); assert.equal(await candidate.inputValue(),''); assert.equal(await prompt.inputValue(),'1girl, red hair, garden'); await helper.getByText('補助モデルのメモリ・出典',{exact:true}).click(); await helper.getByRole('button',{name:'補助モデルをメモリから解放',exact:true}).click(); await helper.getByText('解放しました。次回は保存済みファイルから読み込みます。',{exact:true}).waitFor(); await page.getByRole('tab',{name:'Illustrious',exact:true}).click(); assert.equal(await source.isVisible(),false); assert(await page.evaluate(()=>document.documentElement.scrollWidth<=innerWidth+1)); assert.deepEqual(errors,[]); console.log(`PASS ${width}px: real CPU candidate/import/edit/apply/negative unchanged/stale guard/invalid clear/unload/Anima panel isolation/no overflow`); await page.close(); } }finally{await browser.close();} })().catch(e=>{console.error(e);process.exit(1);});