|
| 1 | +import assert from 'node:assert/strict'; |
| 2 | +import fs from 'node:fs'; |
| 3 | +import path from 'node:path'; |
| 4 | +import { chromium } from 'playwright'; |
| 5 | +import { startFixtureServer } from './server.mjs'; |
| 6 | + |
| 7 | +// Isolated renderer regression for the native Desktop's unbounded recent-session |
| 8 | +// titles. Only the test fixture responds; no production Tauri/API is invoked. |
| 9 | +const root=path.resolve(import.meta.dirname,'../..'); |
| 10 | +const fixture=await startFixtureServer(); |
| 11 | +const chrome='/Applications/Google Chrome.app/Contents/MacOS/Google Chrome'; |
| 12 | +const executablePath=process.env.UI_SMOKE_BROWSER||(fs.existsSync(chrome)?chrome:undefined); |
| 13 | +let browser; |
| 14 | +const results=[]; |
| 15 | +try { |
| 16 | + browser=await chromium.launch({headless:true,...(executablePath?{executablePath}:{})}); |
| 17 | + const page=await browser.newPage(); |
| 18 | + await page.route('**/desktop-shim.js',async route=>{ |
| 19 | + const response=await route.fetch();let source=await response.text(); |
| 20 | + const marker='recent_sessions:{sessions:[],truncated:false,scan_truncated:false}'; |
| 21 | + assert.equal(source.split(marker).length,2); |
| 22 | + const sessions=[0,1,2].map(index=>({session_id:'wc_sess_long_activity_'+index,project_id:'agent:fixture-runner:alpha',title:'Owner review with a deliberately long session description '.repeat(35),updated_at:Math.floor(Date.now()/1000),lifecycle:'active',mode:'normal'})); |
| 23 | + source=source.replace(marker,'recent_sessions:'+JSON.stringify({sessions,truncated:false,scan_truncated:false})); |
| 24 | + await route.fulfill({response,body:source}); |
| 25 | + }); |
| 26 | + for(const width of [768,1180,1440,1920]) { |
| 27 | + await page.setViewportSize({width,height:900}); |
| 28 | + await page.goto(fixture.url+'/desktop/'); |
| 29 | + await page.locator('.dashboard-activity-link').first().waitFor(); |
| 30 | + const metrics=await page.evaluate(()=>{ |
| 31 | + const section=document.querySelector('[aria-labelledby="recent-activity-title"]'); |
| 32 | + const rect=section.getBoundingClientRect(); |
| 33 | + return {viewport:innerWidth,documentWidth:document.documentElement.scrollWidth,sectionRight:rect.right, |
| 34 | + links:[...document.querySelectorAll('.dashboard-activity-link')].map(link=>({right:link.getBoundingClientRect().right,width:link.getBoundingClientRect().width}))}; |
| 35 | + }); |
| 36 | + results.push({width,...metrics}); |
| 37 | + assert(metrics.documentWidth<=width+1,JSON.stringify(metrics)); |
| 38 | + assert(metrics.links.every(link=>link.right<=metrics.sectionRight+1),JSON.stringify(metrics)); |
| 39 | + } |
| 40 | + console.log(JSON.stringify({fixture:true,nativeBackend:false,passed:true,results},null,2)); |
| 41 | +} finally { |
| 42 | + if(browser)await browser.close();await new Promise(resolve=>fixture.server.close(resolve)); |
| 43 | +} |
0 commit comments