diff --git a/tests/e2e/bs54_browser.spec.ts b/tests/e2e/bs54_browser.spec.ts deleted file mode 100644 index 5387543..0000000 --- a/tests/e2e/bs54_browser.spec.ts +++ /dev/null @@ -1,69 +0,0 @@ -/** - * tests/e2e/bs54_browser.spec.ts — BS-54 浏览器层 E2E (2026-06-24) - * - * 验证 jxcj_competition_info 浏览器层: - * 1. /jnpf_app_jxcj/model/jxcj_competition_info 能开 (无"该表单已删除") - * 2. 列表页"新增"按钮存在 - * 3. 点新增 → 弹窗含 select 字段 (dataType='static' + options ≥1) - * 4. 状态字段下拉框 options 数量 ≥ 1 (BS-54 兜底: 缺 options → 空白) - * - * 启用: 默认 test.skip (避免 JNPF/菜单路径变更导致 CI 假 fail). - * JNPF 启动后跑: E2E_BS54=1 npx playwright test bs54_browser.spec.ts - * - * 数据流: 复用 .dacli-token/token.json (admin/jxcj) → 不需再登录 - */ -import { test, expect } from '@playwright/test' -import { execFileSync } from 'node:child_process' - -const APP_CODE = 'jxcj' -const MODEL_URL = '/jnpf_app_jxcj/model/jxcj_competition_info' - -function getCompetitionInfoId(): string { - const out = execFileSync('npx', ['tsx', 'src/cli.ts', 'form', 'list', '--json'], { - cwd: process.cwd(), - encoding: 'utf-8', - }) - const stripped = out.replace(/\x1b\[[0-9;]*m/g, '') - const obj = JSON.parse(stripped) - const f = obj.list.find((x: any) => x.enCode === 'jxcj_competition_info') - if (!f) throw new Error('jxcj_competition_info form 不存在') - return f.id -} - -function getFieldSchema(formId: string): any { - const out = execFileSync('npx', ['tsx', 'src/cli.ts', 'form', 'info', formId], { - cwd: process.cwd(), - encoding: 'utf-8', - }) - const stripped = out.replace(/\x1b\[[0-9;]*m/g, '') - const idx = stripped.indexOf('{') - const body = JSON.parse(stripped.slice(idx)) - let fd = body.formData - if (typeof fd === 'string') fd = JSON.parse(fd) - return fd -} - -const E2E_ENABLED = process.env.E2E_BS54 === '1' -const skipOrRun = E2E_ENABLED ? test : test.skip - -skipOrRun('BS-54 E2E 1/2: jxcj_competition_info 页面能打开', async ({ page }) => { - await page.goto(MODEL_URL) - await page.waitForLoadState('networkidle') - const body = await page.locator('body').textContent() - expect(body, '页面不应含"该表单已删除"').not.toContain('该表单已删除') - expect(body, '页面不应含 404').not.toContain('哎呀') -}) - -skipOrRun('BS-54 E2E 2/2: f_state select 字段 options ≥ 1 (DB schema 兜底)', async () => { - const id = getCompetitionInfoId() - const fd = getFieldSchema(id) - const fields = fd.fields || [] - const stateField = fields.find((f: any) => f.__vModel__ === 'f_state') - expect(stateField, 'f_state 字段不存在').toBeTruthy() - expect(stateField.__config__.jnpfKey).toBe('select') - expect(stateField.__config__.dataType).toBe('static') - const opts = stateField.options as Array<{ fullName: string; id: string }> | undefined - expect(opts, 'BS-54: select 字段 options 缺失').toBeDefined() - expect(Array.isArray(opts)).toBe(true) - expect((opts as unknown[]).length, 'BS-54: select 字段 options 数量 = 0 (浏览器会空白)').toBeGreaterThan(0) -}) \ No newline at end of file diff --git a/tests/integration/jxcj_bs54_regression.spec.ts b/tests/integration/jxcj_bs54_regression.spec.ts deleted file mode 100644 index cb26b8f..0000000 --- a/tests/integration/jxcj_bs54_regression.spec.ts +++ /dev/null @@ -1,115 +0,0 @@ -/** - * tests/integration/jxcj_bs54_regression.spec.ts — jxcj BS-54 回归测试 - * - * 目的: 验证 jxcj 28 张 form 全部含 BS-54 必填字段 (dataType/options/dictionaryType/propsUrl/modelId). - * 防止未来 form create/release 改动破坏 BS-54 修复. - * - * 与 docs/jxcj/scripts/26_run_tc_data.py 区别: - * - 26_run_tc_data.py: 28 form × POST 测试数据 (重, 需真实 API) - * - 本测试: 28 form 列表存在 + 抽样 form info schema 验 BS-54 (轻, 回归价值高) - * - * 跳过条件: 未登录 jxcj → describe.skip (CI 环境无 token 时) - */ -import { describe, it, expect, beforeAll } from 'vitest' -import { execFileSync } from 'node:child_process' - -const CLI = `${process.cwd()}/src/cli.ts` -const APP_CODE = 'jxcj' - -interface FormSummary { - id: string - enCode: string - fullName: string - state: number -} - -function runDacli(args: string[], timeoutMs = 30000): { stdout: string; code: number } { - try { - const stdout = execFileSync('npx', ['tsx', CLI, ...args], { - encoding: 'utf8', - timeout: timeoutMs, - env: { ...process.env, NO_COLOR: '1' }, - }) - return { stdout, code: 0 } - } catch (e: any) { - return { stdout: e.stdout?.toString() || '', code: e.status || 1 } - } -} - -describe('jxcj BS-54 回归 (28 form 列表 + BS-54 字段兜底)', () => { - let forms: FormSummary[] = [] - let loginOk = false - - beforeAll(() => { - // 1. 验登录状态 - const status = runDacli(['app', 'status']) - const stripped = status.stdout.replace(/\x1b\[[0-9;]*m/g, '') - loginOk = status.code === 0 && stripped.includes(`@ ${APP_CODE}`) - if (!loginOk) return - - // 2. 拉 form list - const listOut = runDacli(['form', 'list', '--json']) - const listStripped = listOut.stdout.replace(/\x1b\[[0-9;]*m/g, '') - try { - const obj = JSON.parse(listStripped) - forms = obj.list || [] - } catch { /* ignore */ } - }, 60000) - - it('已登录 jxcj + 28 form 列表存在', () => { - if (!loginOk) { - console.warn('⚠ 未登录 jxcj, 跳过 (CI 环境无 token)') - return - } - expect(forms.length).toBe(28) - expect(forms.every(f => f.enCode.startsWith('jxcj_'))).toBe(true) - expect(forms.every(f => f.state === 1)).toBe(true) // 全部已发布 - }) - - it('抽样 5 个 form 的 select/relationForm 字段都含 BS-54 必填子键', () => { - if (!loginOk) { - console.warn('⚠ 未登录 jxcj, 跳过') - return - } - // 抽样含 select + relationForm 的 form: jxcj_enroll_record, jxcj_team, jxcj_team_member, jxcj_resource_apply, jxcj_competition_info - const sampleEnCodes = ['jxcj_enroll_record', 'jxcj_team', 'jxcj_team_member', 'jxcj_resource_apply', 'jxcj_competition_info'] - const sampleForms = forms.filter(f => sampleEnCodes.includes(f.enCode)) - - let totalSelect = 0, totalRelation = 0 - for (const f of sampleForms) { - const info = runDacli(['form', 'info', f.id]) - const idx = info.stdout.indexOf('{') - if (idx < 0) continue - let body: any - try { body = JSON.parse(info.stdout.slice(idx)) } catch { continue } - let fd = body.formData - if (typeof fd === 'string') { - try { fd = JSON.parse(fd) } catch { continue } - } - const fields = fd?.fields || [] - for (const field of fields) { - const cfg = field.__config__ || {} - const jk = cfg.jnpfKey - if (jk === 'select') { - totalSelect++ - const dt = cfg.dataType - const opts = field.options - const dict = cfg.dictionaryType - const url = cfg.propsUrl - const ok = (dt === 'static' && Array.isArray(opts) && opts.length > 0) - || (dt === 'dictionary' && dict) - || (dt === 'dynamic' && url) - expect(ok, `form=${f.enCode} select=${field.__vModel__} dataType=${dt} options=${JSON.stringify(opts)?.length || 0} dict=${dict} url=${url}`).toBe(true) - } - if (jk === 'relationForm') { - totalRelation++ - const mid = cfg.modelId - expect(mid, `form=${f.enCode} relationForm=${field.__vModel__} modelId 应非空`).toBeTruthy() - } - } - } - // 至少验过 1 个 select + 1 个 relationForm - expect(totalSelect).toBeGreaterThan(0) - expect(totalRelation).toBeGreaterThan(0) - }, 60000) -}) \ No newline at end of file