Skip to content

The ultimate harness for coding agents and beyond. All your agents. All your machines. One command center. Start with code, then follow your curiosity and build across disciplines: CAD, circuits, robots, games and music.

2.4 KB
Raw Blame
import {test} from 'node:test';import assert from 'node:assert/strict';import {spawn} from 'node:child_process';import {createServer} from 'node:net';import {once} from 'node:events';import {join} from 'node:path';import {mkdir} from 'node:fs/promises';import {chromium,root} from './helpers.mjs';
test('Sheet & Docs: actual PDF text, navigation, find and zoom in Doc Viewer',{skip:!process.env.SHEET_DOCS_QA_WORKSPACE},async()=>{
 const portServer=createServer();portServer.listen(0,'127.0.0.1');await once(portServer,'listening');const port=portServer.address().port;await new Promise(r=>portServer.close(r));
 const child=spawn(process.execPath,[join(root,'store/viewers/doc-viewer/viewer.mjs')],{env:{...process.env,HARNESS_WORKSPACE:process.env.SHEET_DOCS_QA_WORKSPACE,HARNESS_VIEWER_PORT:String(port),DOC_VIEWER_OPEN:'off'},stdio:['ignore','pipe','pipe']});const browser=await(await chromium()).launch({headless:true});
 try{await once(child.stdout,'data');const page=await browser.newPage({viewport:{width:1600,height:1000}}),errors=[];page.on('pageerror',e=>errors.push(e.message));await page.goto('http://127.0.0.1:'+port+'/?file=out.pdf');await page.locator('canvas').first().waitFor();await page.waitForFunction(()=>document.querySelector('#page-count')?.textContent.includes('1'));await page.getByRole('button',{name:'Find in document',exact:true}).click();await page.locator('#find-input').fill('South');await page.waitForFunction(()=>document.querySelector('#find-count')?.textContent.includes('2'));await page.locator('#find-close').click();const before=await page.locator('#btn-zoom').textContent();await page.locator('#btn-zoom-in').click();assert.notEqual(await page.locator('#btn-zoom').textContent(),before);await page.locator('#btn-zoom-out').click();await page.locator('#btn-zoom').click();await page.getByRole('menuitem',{name:/Fit page/}).click();await page.waitForTimeout(200);if(process.env.HARNESS_QA_DIR){await mkdir(process.env.HARNESS_QA_DIR,{recursive:true});await page.screenshot({path:join(process.env.HARNESS_QA_DIR,'sheet-docs-desktop.png')});}if(process.env.HARNESS_SHOWCASE_DIR){const directory=join(process.env.HARNESS_SHOWCASE_DIR,'sheet-docs');await mkdir(directory,{recursive:true});await page.screenshot({path:join(directory,'starter.jpg'),type:'jpeg',quality:85});}assert.deepEqual(errors,[]);
 }finally{await browser.close();child.kill('SIGTERM');await once(child,'exit').catch(()=>{});}
});