MCPcopy Create free account
hub / github.com/CommonstackAI/UncommonRoute / run

Function run

tests/e2e_dashboard.mjs:28–131  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

26];
27
28async function run() {
29 const browser = await chromium.launch({ headless: true });
30 const context = await browser.newContext({ viewport: { width: 1440, height: 900 } });
31 const page = await context.newPage();
32
33 const consoleErrors = [];
34 page.on('console', msg => {
35 if (msg.type() === 'error') consoleErrors.push(msg.text());
36 });
37
38 let passed = 0;
39 let failed = 0;
40
41 // ─── Test 1: Load dashboard ───
42 console.log('\n=== Loading dashboard ===');
43 await page.goto(BASE, { waitUntil: 'networkidle', timeout: 30000 });
44 console.log('✓ Dashboard loaded');
45 passed++;
46
47 // ─── Test 2: Screenshot every page ───
48 console.log('\n=== Screenshotting all pages ===');
49 for (const pageName of PAGES) {
50 try {
51 // Click nav item
52 await page.click(`button:has-text("${pageName}")`, { timeout: 5000 });
53 await page.waitForTimeout(1500); // Wait for data to load
54 await page.screenshot({ path: `${SCREENSHOT_DIR}/${pageName.toLowerCase()}.png`, fullPage: true });
55 console.log(`✓ ${pageName} — screenshot saved`);
56 passed++;
57 } catch (e) {
58 console.log(`✗ ${pageName} — ${e.message}`);
59 failed++;
60 }
61 }
62
63 // ─── Test 3: Playground tier predictions ───
64 console.log('\n=== Playground prediction tests ===');
65
66 // Navigate to Playground
67 await page.click('button:has-text("PLAYGROUND")', { timeout: 5000 });
68 await page.waitForTimeout(500);
69
70 for (const test of PLAYGROUND_TESTS) {
71 try {
72 // Clear and type prompt
73 const textarea = page.locator('textarea');
74 await textarea.fill('');
75 await textarea.fill(test.prompt);
76
77 // Wait for debounced API call + embedding model load (first call is slow)
78 await page.waitForTimeout(8000);
79
80 // Read predicted tier
81 const tierEl = page.locator('text=PREDICTED TIER').locator('..').locator('.font-display');
82 const tierText = await tierEl.textContent({ timeout: 5000 });
83 const tier = tierText?.trim().toUpperCase() || 'UNKNOWN';
84
85 // Check signals are rendered

Callers 1

e2e_dashboard.mjsFile · 0.70

Calls 3

pushMethod · 0.80
closeMethod · 0.80
countMethod · 0.45

Tested by

no test coverage detected