Browse Source

chore: 恢复误删的开发期路由调试脚本

上个提交 a9a787f 用 `rm -f .tmp-*.mjs` 清理临时文件时,
误把仓库里原有的 4 个路由调试脚本(.tmp-routes / .tmp-drawer /
.tmp-flow3 / .tmp-details)一起删掉了。这些是历史遗留的调试工具,
虽以 .tmp- 前缀命名但**已入库**,不是本次产生的临时文件。
现从 a9a787f^ 恢复。

Co-Authored-By: Claude Code <noreply@anthropic.com>
Huccct 3 hours ago
parent
commit
c308d9e36c
4 changed files with 119 additions and 0 deletions
  1. 28 0
      .tmp-details.mjs
  2. 21 0
      .tmp-drawer.mjs
  3. 46 0
      .tmp-flow3.mjs
  4. 24 0
      .tmp-routes.mjs

+ 28 - 0
.tmp-details.mjs

@@ -0,0 +1,28 @@
+import { chromium } from 'playwright';
+const base = 'http://localhost:4200';
+const b = await chromium.launch({ channel: 'msedge' });
+const ctx = await b.newContext({ viewport: { width: 390, height: 844 }, deviceScaleFactor: 2, isMobile: true, hasTouch: true,
+  userAgent: 'Mozilla/5.0 (iPhone; CPU iPhone OS 17_0 like Mac OS X) AppleWebKit/605.1.15 Mobile/15E148 Safari/604.1' });
+const p = await ctx.newPage();
+const errs = [];
+p.on('pageerror', e => errs.push(e.message));
+await p.goto(base + '/login'); await p.waitForTimeout(900);
+await p.locator('input').nth(0).fill('13800000000');
+await p.getByRole('button', { name: /获取验证码/ }).first().click(); await p.waitForTimeout(400);
+await p.locator('input').nth(1).fill('123456');
+await p.getByRole('button', { name: /^登\s*录$/ }).first().click(); await p.waitForTimeout(3500);
+// 从列表页点进真实详情
+await p.goto(base + '/mobile/projects'); await p.waitForTimeout(1500);
+await p.locator('.card.project').first().click(); await p.waitForTimeout(1200);
+console.log('project url', p.url().replace(base, ''));
+await p.screenshot({ path: '.tmp-shots/project-real.png' });
+await p.goto(base + '/mobile/tasks'); await p.waitForTimeout(1500);
+await p.locator('.card.task').first().click(); await p.waitForTimeout(1200);
+console.log('task url', p.url().replace(base, ''));
+await p.screenshot({ path: '.tmp-shots/task-real.png' });
+await p.goto(base + '/mobile/contacts'); await p.waitForTimeout(1500);
+await p.locator('.row').first().click(); await p.waitForTimeout(1500);
+console.log('agent url', p.url().replace(base, ''));
+await p.screenshot({ path: '.tmp-shots/agent-real.png' });
+console.log('errs', [...new Set(errs)].slice(0, 5));
+await b.close();

+ 21 - 0
.tmp-drawer.mjs

@@ -0,0 +1,21 @@
+import { chromium } from 'playwright';
+const base = 'http://localhost:4200';
+const b = await chromium.launch({ channel: 'msedge' });
+const ctx = await b.newContext({ viewport: { width: 390, height: 844 }, isMobile: true, hasTouch: true,
+  userAgent: 'Mozilla/5.0 (iPhone; CPU iPhone OS 17_0 like Mac OS X) AppleWebKit/605.1.15 Mobile/15E148 Safari/604.1' });
+const p = await ctx.newPage();
+await p.goto(base + '/login'); await p.waitForTimeout(900);
+await p.locator('input').nth(0).fill('13800000000');
+await p.getByRole('button', { name: /获取验证码/ }).first().click(); await p.waitForTimeout(400);
+await p.locator('input').nth(1).fill('123456');
+await p.getByRole('button', { name: /^登\s*录$/ }).first().click(); await p.waitForTimeout(3500);
+// 建一条会话
+await p.getByRole('button', { name: '新建对话' }).first().click(); await p.waitForTimeout(700);
+await p.locator('.pick-row').first().click(); await p.waitForTimeout(2500);
+await p.locator('textarea').first().fill('抽屉测试'); await p.locator('textarea').first().press('Enter'); await p.waitForTimeout(2500);
+await p.goto(base + '/mobile/chat-index'); await p.waitForTimeout(2500);
+const txt = await p.evaluate(() => document.body.innerText);
+console.log('LIST:', txt.slice(0, 200).replace(/\n/g, ' | '));
+await p.getByRole('button', { name: '打开会话抽屉' }).click(); await p.waitForTimeout(900);
+console.log('DRAWER:', (await p.evaluate(() => document.body.innerText)).slice(0, 300).replace(/\n/g, ' | '));
+await b.close();

+ 46 - 0
.tmp-flow3.mjs

@@ -0,0 +1,46 @@
+import { chromium } from 'playwright';
+const base = 'http://localhost:4200';
+const b = await chromium.launch({ channel: 'msedge' });
+const ctx = await b.newContext({ viewport: { width: 390, height: 844 }, deviceScaleFactor: 2, isMobile: true, hasTouch: true,
+  userAgent: 'Mozilla/5.0 (iPhone; CPU iPhone OS 17_0 like Mac OS X) AppleWebKit/605.1.15 Mobile/15E148 Safari/604.1' });
+const p = await ctx.newPage();
+const errs = [];
+p.on('pageerror', e => errs.push(e.message));
+p.on('console', m => { if (m.type() === 'error') errs.push(m.text().slice(0, 140)); });
+const r = {};
+await p.goto(base + '/login'); await p.waitForTimeout(900);
+await p.locator('input').nth(0).fill('13800000000');
+await p.getByRole('button', { name: /获取验证码/ }).first().click(); await p.waitForTimeout(400);
+await p.locator('input').nth(1).fill('123456');
+await p.getByRole('button', { name: /^登\s*录$/ }).first().click(); await p.waitForTimeout(3500);
+r.landing = p.url().replace(base, '');
+// 新建对话
+await p.getByRole('button', { name: '新建对话' }).first().click(); await p.waitForTimeout(700);
+r.pick = await p.locator('.pick-row').count();
+await p.locator('.pick-row').first().click(); await p.waitForTimeout(2500);
+r.afterNew = p.url().replace(base, '').slice(0, 60);
+// 发消息
+const ta = p.locator('textarea').first();
+await ta.fill('你好,做个测试'); await ta.press('Enter'); await p.waitForTimeout(2500);
+r.sent = (await p.evaluate(() => document.body.innerText)).includes('你好,做个测试');
+await p.screenshot({ path: '.tmp-shots/chat.png' });
+// 抽屉(会话列表页顶栏 ☰)
+await p.goto(base + '/mobile/chat-index'); await p.waitForTimeout(1800);
+await p.getByRole('button', { name: '打开会话抽屉' }).click(); await p.waitForTimeout(800);
+r.drawer = (await p.evaluate(() => document.body.innerText)).includes('新建对话') && (await p.evaluate(() => document.body.innerText)).includes('更多');
+await p.locator('button:has-text("更多")').first().click(); await p.waitForTimeout(400);
+r.moreList = (await p.evaluate(() => document.body.innerText)).includes('成果');
+await p.screenshot({ path: '.tmp-shots/drawer.png' });
+await p.keyboard.press('Escape');
+// 详情页
+for (const [route, name] of [['projects/pr-0', 'project-detail'], ['tasks/t-0', 'task-detail']]) {
+  await p.goto(`${base}/mobile/${route}`); await p.waitForTimeout(1500);
+  await p.screenshot({ path: `.tmp-shots/${name}.png` });
+}
+// 配色切换
+await p.goto(base + '/mobile/mine'); await p.waitForTimeout(1200);
+await p.locator('.pal').nth(1).click(); await p.waitForTimeout(500);
+r.palette = await p.evaluate(() => document.documentElement.dataset.palette);
+await p.screenshot({ path: '.tmp-shots/mine-ice.png' });
+console.log(JSON.stringify({ r, errs: [...new Set(errs)].slice(0, 6) }, null, 1));
+await b.close();

+ 24 - 0
.tmp-routes.mjs

@@ -0,0 +1,24 @@
+import { chromium } from 'playwright';
+const base = 'http://localhost:4200';
+const b = await chromium.launch({ channel: 'msedge' });
+const ctx = await b.newContext({ viewport: { width: 390, height: 844 }, deviceScaleFactor: 2, isMobile: true, hasTouch: true,
+  userAgent: 'Mozilla/5.0 (iPhone; CPU iPhone OS 17_0 like Mac OS X) AppleWebKit/605.1.15 Mobile/15E148 Safari/604.1' });
+const p = await ctx.newPage();
+const errs = [];
+p.on('pageerror', e => errs.push(e.message));
+p.on('console', m => { if (m.type() === 'error') errs.push(m.text().slice(0, 140)); });
+await p.goto(base + '/login'); await p.waitForTimeout(1000);
+await p.locator('input').nth(0).fill('13800000000');
+await p.getByRole('button', { name: /获取验证码/ }).first().click(); await p.waitForTimeout(400);
+await p.locator('input').nth(1).fill('123456');
+await p.getByRole('button', { name: /^登\s*录$/ }).first().click(); await p.waitForTimeout(3500);
+const routes = ['chat-index', 'contacts', 'projects', 'tasks', 'events', 'workbench', 'deliverables', 'mine'];
+const out = [];
+for (const r of routes) {
+  await p.goto(`${base}/mobile/${r}`); await p.waitForTimeout(1800);
+  const info = await p.evaluate(() => ({ len: document.body.innerText.trim().length, over: document.documentElement.scrollWidth > innerWidth + 1, text: document.body.innerText.slice(0, 40).replace(/\n/g, ' ') }));
+  await p.screenshot({ path: `.tmp-shots/${r}.png` });
+  out.push([r, info.len, info.over, info.text]);
+}
+console.log(JSON.stringify({ out, errs: [...new Set(errs)].slice(0, 8) }, null, 1));
+await b.close();