25'ten fazla konu seçemezsiniz Konular bir harf veya rakamla başlamalı, kısa çizgiler ('-') içerebilir ve en fazla 35 karakter uzunluğunda olabilir.
 
 
 
 

27 satır
1.5 KiB

  1. const fs = require('node:fs');
  2. const path = require('node:path');
  3. const { pathToFileURL } = require('node:url');
  4. const { chromium } = require('@playwright/test');
  5. (async()=>{
  6. const dir=path.resolve(__dirname,'../reports/bridge-005-moss-junhao-v2-20260919');
  7. const browser=await chromium.launch({headless:true,channel:'chrome'});
  8. try {
  9. const page=await browser.newPage({viewport:{width:1280,height:1000}});
  10. await page.goto(pathToFileURL(path.join(dir,'index.html')).href);
  11. if(await page.locator('video').count()!==10) throw new Error('Expected five pairs of videos');
  12. const results=[];
  13. for(let step=0;step<5;step++){
  14. const video=page.locator('video').nth(step*2);
  15. await video.scrollIntoViewIfNeeded();
  16. await video.evaluate(v=>v.play());
  17. await page.waitForFunction(index=>{const v=document.querySelectorAll('video')[index];return v.currentTime>.15&&!v.paused&&!v.error},step*2);
  18. results.push(await video.evaluate(v=>({width:v.videoWidth,height:v.videoHeight,duration:v.duration,playing:!v.paused,error:v.error?.code||null})));
  19. await video.evaluate(v=>v.pause());
  20. }
  21. await page.evaluate(()=>scrollTo(0,0));
  22. await page.screenshot({path:path.join(dir,'preview-page.png')});
  23. fs.writeFileSync(path.join(dir,'playback-validation.json'),JSON.stringify(results,null,2));
  24. console.log('PASS: five new videos played, five original comparisons present',results);
  25. } finally {await browser.close()}
  26. })().catch(e=>{console.error(e.message);process.exitCode=1});