auto(284e8d004cbb): session end @ 2026-06-30T16:45:06 (+2f)

This commit is contained in:
ssw committed 2026-06-30 16:45:11 +08:00
1 parent b4af748a76
commit 700ad86fd6
3 files changed
-187

No files matched your search

Vendored
BIN
View File
Binary file not shown.
-142
View File
@@ -1,142 +0,0 @@
#!/usr/bin/env -S npx tsx
/**
* scripts/seed-tds-baseline.ts
*
* 把 workSystem 5-7 张代表性 form export 到 /tmp/baseline/, 再 import 到 tds.
* 输出 /tmp/baseline-mapping.json (origId → cloneId) 供 baseline spec 用.
*
* 用户指引: 测试在 tds 做, 数据从官方示例复制 — 官方示例只读不动.
*
* 跑法:
* npx tsx scripts/seed-tds-baseline.ts
*
* 选择标准 (5 张代表性, 5 维度覆盖):
* - yuangongpx (type=1, 无 flow) 单表
* - ruzhishenq (type=1, 无 flow) 单表 (HR)
* - renewal (type=1, 无 flow) 单表 (合同)
* - leaveApply (type=2, flow=1) 工作流表单 (经典)
* - crmOrder (type=2, flow=1) 工作流表单 (订单)
*/
import { execSync } from 'node:child_process'
import { mkdirSync, writeFileSync, existsSync } from 'node:fs'
const SELECTED = [
{ enCode: 'yuangongpx', fullName: '员工培训' },
{ enCode: 'ruzhishenq', fullName: '入职申请' },
{ enCode: 'renewal', fullName: '劳动合同续签' },
{ enCode: 'leaveApply', fullName: '请假申请' },
{ enCode: 'crmOrder', fullName: '订单示例' },
] as const
const EXPORT_DIR = '/tmp/baseline-orig'
const MAPPING_FILE = '/tmp/baseline-mapping.json'
const CLONE_SUFFIX = '_ws' // workSystem 来源标记
interface Form {
id: string
enCode: string
fullName: string
type: number
enableFlow: number | null
}
interface Mapping {
origAppCode: string
origId: string
origEnCode: string
origFullName: string
cloneAppCode: string
cloneId: string
cloneEnCode: string
cloneFullName: string
imported: string
}
function dacli(args: string, opts: { silent?: boolean } = {}): string {
if (!opts.silent) console.log(` $ dacli ${args}`)
return execSync(`npx tsx src/cli.ts ${args}`, { encoding: 'utf-8' })
}
async function main() {
mkdirSync(EXPORT_DIR, { recursive: true })
// 1. 切到 workSystem, 拿 5 张 form 的 id
console.log('▶ 切到 workSystem 拿 id...')
dacli(`switch-app --appCode=workSystem`, { silent: true })
const listRaw = dacli(`form list --limit=200 --json`, { silent: true })
const all = (JSON.parse(listRaw) as { list: Form[] }).list
const targets = SELECTED.map((s) => {
const f = all.find((x) => x.enCode === s.enCode)
if (!f) throw new Error(`workSystem 找不到 ${s.enCode}, list 总数=${all.length}`)
return f
})
console.log(` ✓ 锁定 ${targets.length} 张 workSystem form`)
// 2. export 每张
console.log('▶ export workSystem 5 张 → /tmp/baseline-orig/')
for (const f of targets) {
const out = `${EXPORT_DIR}/${f.enCode}.json`
dacli(`form export ${f.id} --out=${out}`, { silent: true })
console.log(` ✓ ${f.enCode} (${f.fullName})`)
}
// 3. 切到 tds, 清掉旧 _ws 克隆
console.log('▶ 切到 tds, 清理旧 _ws 克隆')
dacli(`switch-app --appCode=tds`, { silent: true })
const tdsRaw = dacli(`form list --limit=200 --json`, { silent: true })
const tdsAll = (JSON.parse(tdsRaw) as { list: Form[] }).list
for (const f of tdsAll.filter((x) => x.enCode.endsWith(CLONE_SUFFIX))) {
try {
dacli(`form delete ${f.id} --yes`, { silent: true })
console.log(` ✗ 删旧 ${f.enCode}`)
} catch (e) {
console.log(` ! 删 ${f.enCode} 失败 (忽略): ${(e as Error).message.slice(0, 80)}`)
}
}
// 4. import 每张 → tds
console.log('▶ import 5 张 → tds')
const mapping: Mapping[] = []
for (const f of targets) {
const file = `${EXPORT_DIR}/${f.enCode}.json`
const cloneEnCode = `${f.enCode}${CLONE_SUFFIX}`
const cloneFullName = `${f.fullName}(ws克隆)`
try {
const out = dacli(
`form import ${file} --enCode=${cloneEnCode} --fullName="${cloneFullName}"${f.enableFlow === 1 ? '' : ' --release'}`,
{ silent: true }
)
// import 输出 "✓ 导入成功 id=XXX enCode=YYY"
const m = out.match(/id=(\S+)\s+enCode=/)
const cloneId = m?.[1] && m[1] !== '(unknown)' ? m[1] : ''
if (!cloneId) {
console.log(` ! ${f.enCode} import 返回未拿到 id: ${out.trim().slice(0, 150)}`)
continue
}
mapping.push({
origAppCode: 'workSystem',
origId: f.id,
origEnCode: f.enCode,
origFullName: f.fullName,
cloneAppCode: 'tds',
cloneId,
cloneEnCode,
cloneFullName,
imported: new Date().toISOString(),
})
console.log(` ✓ ${f.enCode} → ${cloneEnCode} (id=${cloneId})`)
} catch (e) {
console.log(` ✗ ${f.enCode} import 失败: ${(e as Error).message.slice(0, 200)}`)
}
}
// 5. 写 mapping
writeFileSync(MAPPING_FILE, JSON.stringify(mapping, null, 2))
console.log(`\n✓ ${mapping.length}/${targets.length} 张克隆成功`)
console.log(`✓ mapping 写到 ${MAPPING_FILE}`)
console.log('\n后续: npx playwright test tests/e2e/baseline/workSystem/ --project=chromium')
}
void main().catch((e) => {
console.error('FAIL:', e.message)
process.exit(1)
})
-45
View File
@@ -1,45 +0,0 @@
import { chromium } from 'playwright';
const browser = await chromium.launch({headless: true, args: ['--no-sandbox']});
const ctx = await browser.newContext({viewport: {width: 1440, height: 900}, locale: 'zh-CN'});
const page = await ctx.newPage();
await page.goto('http://nginx/jnpf_app_backend_tds2/login', {waitUntil: 'domcontentloaded', timeout: 30000});
await page.waitForTimeout(2000);
await page.fill('input[placeholder="请输入账号"]', 'admin');
await page.fill('input[placeholder="请输入密码"]', '123456');
await page.waitForTimeout(500);
await page.click('button:has-text("登 录")');
await page.waitForTimeout(4000);
console.log('after login URL:', page.url());
// if still on login, dump error
if (page.url().includes('login')) {
const errs = await page.$$eval('[class*="error"], [class*="err-message"]', els => els.map(e => e.innerText));
console.log('login errs:', errs);
const body = await page.innerText('body');
console.log('body:', body.substring(0, 500));
}
// now go to appMenu
await page.goto('http://nginx/jnpf_app_backend_tds2/appConfig/appMenu', {waitUntil: 'domcontentloaded', timeout: 30000});
await page.waitForTimeout(5000);
console.log('appMenu URL:', page.url());
console.log('TITLE:', await page.title());
await page.screenshot({path: '/tmp/tds2-backend-appMenu.png', fullPage: true});
const bodyText = await page.innerText('body');
console.log('--- BODY (first 3000) ---');
console.log(bodyText.substring(0, 3000));
// try to find table
const rows = await page.$$('.vxe-table .vxe-body--row, .ant-table-tbody tr, [class*="tree-node"]');
console.log('--- rows found:', rows.length);
if (rows.length > 0) {
const firstFew = await Promise.all(rows.slice(0, 5).map(r => r.innerText()));
console.log('first 5 rows:', firstFew);
}
await browser.close();