this repo has no description
1const { chromium } = require('playwright');
2
3async function testFeatures() {
4 console.log('Launching browser...');
5 const browser = await chromium.launch({
6 headless: true,
7 args: ['--no-sandbox', '--disable-setuid-sandbox']
8 });
9
10 const page = await browser.newPage();
11
12 // Collect all console messages
13 const consoleMessages = [];
14 page.on('console', msg => {
15 consoleMessages.push(msg.text());
16 console.log('[browser] ' + msg.text());
17 });
18 page.on('pageerror', err => console.log('[page error] ' + err.message));
19
20 console.log('Navigating to demo page...');
21 await page.goto('http://localhost:8091/demo.html');
22
23 // Wait for ready
24 console.log('Waiting for worker to initialize...');
25 try {
26 await page.waitForFunction(
27 () => document.getElementById('status-text')?.textContent === 'Ready',
28 { timeout: 60000 }
29 );
30 console.log('Worker ready!\n');
31 } catch (e) {
32 console.log('Worker init failed');
33 await browser.close();
34 return;
35 }
36
37 // Test 1: MIME Output
38 console.log('=== TEST 1: MIME Output ===');
39 const mimeCode = `let svg = {|<svg width="100" height="100"><circle cx="50" cy="50" r="40" fill="blue"/></svg>|};;
40Mime_printer.push "image/svg+xml" svg;;`;
41 await page.fill('#mime-input', mimeCode);
42 await page.evaluate(() => runMime());
43 await page.waitForTimeout(5000);
44 const mimeOutput = await page.evaluate(() => document.getElementById('mime-output')?.textContent);
45 const mimeRendered = await page.evaluate(() => document.getElementById('mime-rendered')?.innerHTML);
46 console.log('MIME Output:', mimeOutput?.substring(0, 200));
47 console.log('MIME Rendered:', mimeRendered?.substring(0, 200) || '(empty)');
48 console.log('');
49
50 // Test 2: Autocomplete
51 console.log('=== TEST 2: Autocomplete ===');
52 await page.fill('#complete-input', 'List.m');
53 await page.evaluate(() => runComplete());
54 await page.waitForTimeout(3000);
55 const completeOutput = await page.evaluate(() => document.getElementById('complete-output')?.textContent);
56 console.log('Complete Output:', completeOutput?.substring(0, 300));
57 console.log('');
58
59 // Test 3: Type Information
60 console.log('=== TEST 3: Type Information ===');
61 await page.fill('#type-input', 'let x = List.map');
62 await page.fill('#type-pos', '10');
63 await page.evaluate(() => runTypeEnclosing());
64 await page.waitForTimeout(3000);
65 const typeOutput = await page.evaluate(() => document.getElementById('type-output')?.textContent);
66 console.log('Type Output:', typeOutput?.substring(0, 300));
67 console.log('');
68
69 // Test 4: Error Reporting
70 console.log('=== TEST 4: Error Reporting ===');
71 await page.fill('#errors-input', 'let x : string = 42');
72 await page.evaluate(() => runQueryErrors());
73 await page.waitForTimeout(3000);
74 const errorsOutput = await page.evaluate(() => document.getElementById('errors-output')?.textContent);
75 console.log('Errors Output:', errorsOutput?.substring(0, 300));
76 console.log('');
77
78 // Test 5: Custom Printers
79 console.log('=== TEST 5: Custom Printers ===');
80 const printerCode = `type point = { x: int; y: int };;
81let p = { x = 10; y = 20 };;`;
82 await page.fill('#printer-input', printerCode);
83 await page.evaluate(() => runPrinter());
84 await page.waitForTimeout(3000);
85 const printerOutput = await page.evaluate(() => document.getElementById('printer-output')?.textContent);
86 console.log('Printer Output:', printerOutput?.substring(0, 300));
87 console.log('');
88
89 // Test 6: Library Loading
90 console.log('=== TEST 6: Library Loading ===');
91 const requireCode = `#require "str";;
92Str.string_match (Str.regexp "hello") "hello world" 0;;`;
93 await page.fill('#require-input', requireCode);
94 await page.evaluate(() => runRequire());
95 await page.waitForTimeout(5000);
96 const requireOutput = await page.evaluate(() => document.getElementById('require-output')?.textContent);
97 console.log('Require Output:', requireOutput?.substring(0, 300));
98 console.log('');
99
100 // Print any errors from console
101 const errors = consoleMessages.filter(m => m.includes('Error') || m.includes('error') || m.includes('Exception'));
102 if (errors.length > 0) {
103 console.log('=== ERRORS FOUND ===');
104 errors.forEach(e => console.log(e));
105 }
106
107 await browser.close();
108}
109
110testFeatures().catch(console.error);