Elffuss BraidHub

utopia-ia/elffuss-code public

2df00d521f0c · 2.1 KiBRawPermalink
1import { chromium } from 'playwright';
2const BASE = process.env.BASE || 'https://code.elffuss.com';
3let fails = 0; const ok = (n,c,e='')=>{console.log((c?'✅':'❌')+' '+n+(e?' — '+e:''));if(!c)fails++};
4const b = await chromium.launch(); const ctx = await b.newContext({ locale: 'es-ES' }); // los menús hablan el idioma del navegador; este test mira los textos en español
5await ctx.addInitScript(()=>{try{localStorage.setItem('elffusscode.model','rules')}catch{}});
6const p = await ctx.newPage();
7await p.goto(BASE+'/',{waitUntil:'domcontentloaded'});
8await p.evaluate(async()=>{const o=await navigator.storage.getDirectory();const w=async(d,n,t)=>{const f=await d.getFileHandle(n,{create:true});const s=await f.createWritable();await s.write(t);await s.close()};await w(o,'hola.txt','contenido')});
9await p.goto(BASE+'/?test-opfs',{waitUntil:'domcontentloaded'}); await p.waitForTimeout(2500);
10// botón derecho sobre el fichero
11await p.locator('#tree').getByText('hola.txt').click({button:'right'});
12await p.waitForTimeout(300);
13const items = await p.locator('#tree-menu .tm-item').allInnerTexts().catch(()=>[]);
14ok('el menú contextual aparece con acciones', items.length>=3 && items.some(t=>/Eliminar/.test(t)) && items.some(t=>/Renombrar/.test(t)), items.join(' · '));
15// crear carpeta nueva vía menú (dialog)
16p.once('dialog', d=>d.accept('nueva-carpeta'));
17await p.locator('#tree-menu .tm-item', {hasText:'Nueva carpeta'}).click();
18await p.waitForTimeout(500);
19const hasFolder = await p.locator('#tree').getByText('nueva-carpeta').count();
20ok('«Nueva carpeta» crea la carpeta en el árbol', hasFolder>0);
21// eliminar el fichero vía menú (confirm)
22await p.locator('#tree').getByText('hola.txt').click({button:'right'});
23await p.waitForTimeout(200);
24p.once('dialog', d=>d.accept());
25await p.locator('#tree-menu .tm-item', {hasText:'Eliminar'}).click();
26await p.waitForTimeout(500);
27const gone = await p.locator('#tree').getByText('hola.txt').count();
28ok('«Eliminar» quita el fichero del árbol', gone===0);
29console.log(fails?`\n❌ ${fails} FALLO(S)`:'\n✅ MENÚ CONTEXTUAL OK');
30await b.close(); process.exit(fails?1:0);