diff --git a/neode-ui/test-openwrt.mjs b/neode-ui/test-openwrt.mjs new file mode 100644 index 00000000..3124c39a --- /dev/null +++ b/neode-ui/test-openwrt.mjs @@ -0,0 +1,49 @@ +import { chromium } from './node_modules/playwright/index.mjs'; + +const BASE = 'https://100.66.157.121'; +const PASS = 'ThisIsWeb54321@'; +const DIR = '/tmp/claude-1000/-home-debian/97c10035-69a8-40a0-9b55-219eb8ad683a/scratchpad'; + +// Find the OpenWrt router IP from the Tailscale/LAN +const { execSync } = await import('child_process'); +let routerIp = '192.168.1.1'; +try { + const route = execSync("ssh archipelago@100.66.157.121 'ip route | grep default'", { encoding: 'utf8' }).trim(); + const match = route.match(/default via ([\d.]+)/); + if (match) routerIp = match[1]; +} catch {} +console.log('Detected router IP:', routerIp); + +const browser = await chromium.launch({ headless: true }); +const ctx = await browser.newContext({ ignoreHTTPSErrors: true }); +const page = await ctx.newPage(); + +// Login +await page.goto(`${BASE}/login`, { waitUntil: 'networkidle', timeout: 20000 }); +await page.fill('input[type="password"]', PASS); +await page.keyboard.press('Enter'); +await page.waitForURL(/dashboard/, { timeout: 20000 }); + +// Server page +await page.goto(`${BASE}/dashboard/server`, { waitUntil: 'networkidle', timeout: 20000 }); +await page.screenshot({ path: `${DIR}/01-server.png` }); + +// Click OpenWrt Gateway +await page.getByText('OpenWrt Gateway').click(); +await page.waitForURL(/openwrt/, { timeout: 10000 }); +await page.waitForTimeout(2000); +await page.screenshot({ path: `${DIR}/02-connect-form.png` }); +console.log('Connect form visible'); + +// Fill in the connect form +await page.fill('input[placeholder="192.168.1.1"]', routerIp); +await page.screenshot({ path: `${DIR}/03-form-filled.png` }); +await page.getByRole('button', { name: 'Connect' }).click(); + +// Wait for SSH connection + UCI read (can take up to 30s) +console.log('Connecting to router, waiting for data...'); +await page.waitForTimeout(15000); +await page.screenshot({ path: `${DIR}/04-result.png` }); +console.log('Result page text:\n', (await page.innerText('body')).replace(/\s+/g, ' ').substring(0, 800)); + +await browser.close();