Files
flutter_wisetronic/tools/e2e/test_autologin3.js
peima 33b54fe454 feat(e2e): autologin patch (dev) + 登录态路由测试脚本
- util_web devAutologin: localStorage[_test_token]=user|pass -> 登录API写Hive+dispatch currentUser
- 延迟3s执行等 Flutter/Hive ready (否则 httpPost hang)
- main.dart 调用 devAutologin
- run_auth.js: 注入token遍历登录态路由
- 已验证: autologin API 200 OK
2026-08-03 01:50:12 +08:00

21 lines
975 B
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

const { chromium } = require('playwright');
(async () => {
const browser = await chromium.launch({ headless: true });
const ctx = await browser.newContext({ viewport: { width: 1280, height: 900 } });
await ctx.addInitScript(() => { localStorage['_test_token'] = '6477108200|8818'; });
const page = await ctx.newPage();
const logs = [];
page.on('console', m => logs.push(m.text()));
// 第一次访问触发编译
await page.goto('http://127.0.0.1:8099/', { waitUntil: 'load', timeout: 60000 });
await page.waitForSelector('canvas', { timeout: 60000 });
await page.waitForTimeout(3000);
console.log('编译完成 canvas:', await page.locator('canvas').count());
// reload 让 main() 重跑devAutologin
logs.length = 0;
await page.reload({ waitUntil: 'load' });
await page.waitForTimeout(10000);
console.log('reload 后 autologin 日志:', logs.filter(l=>l.includes('CK_AUTOLOGIN')).join(' | ') || '(无)');
await browser.close();
})();