test(phase-0): 确认基线全绿并预置迭代验收测试契约

This commit is contained in:
2026-11-10 00:47:25 +08:00
parent 7c7712e7f3
commit a94e59d434
5 changed files with 591 additions and 0 deletions
@@ -0,0 +1,20 @@
/**
* 外观专利无侵权数据页筛选纯函数(v1.3 AC-5)—— Pending Phase 3。
*
* Phase 3 组 B 落 `src/pages/patent/appearance-patent-clean-filter.ts`(照 dedupe-total-filter.ts
* 拆分:createAppearancePatentCleanFilterState / appearancePatentCleanFilterActive /
* toAppearancePatentCleanListParams)后,把下面两条 todo 转成真用例并移除 todo 标记:
*
* 1. **snake 参数形状**:toAppearancePatentCleanListParams({...}) 产出
* `page`/`page_size`(默认 10、上限 100)、`task_id`、`asin`、`country`、
* `start_date`/`end_date`(ISO yyyy-MM-dd;空白不下发)——与后端 §3.2 参数归一逐字对撞;
* 2. **分页钳制**(铁律 15):page < 1 归 1;page_size 上限 100;
* `(page-1)*page_size` 溢出边界样本(page 极大值不得把乘积顶成负数/溢出)。
*
* 跑法:`node --test tests/appearance-patent-clean-filter.test.ts`(node --test 只收顶层
* `tests/*.test.ts`,不递归;纯函数零依赖可直测)
*/
import { test } from 'node:test'
test.todo('Pending Phase 3: AC-5 筛选参数——snake page/page_size/task_id/asin/country/start_date/end_date 形状')
test.todo('Pending Phase 3: AC-5 筛选参数——page 钳制防 (page-1)*page_size 溢出(铁律 15)')
@@ -0,0 +1,61 @@
/**
* 外观专利无侵权数据页(v1.3 AC-5)的挂载契约 —— Pending Phase 3。
*
* 用户拍板(2026-11-10):展示形式参照「去重数据库」页(DedupeRegistryPage 形态:自绘
* `<table>` 行列表 + `OldPagination.vue` 分页,**不做卡片宫格**);`companyScoped: true`
* 公司 Tab;任务号/ASIN/国家/起止时间筛选;`page`/`page_size` snake 参数,响应
* `{items, total, page, pageSize}`。默认仅 super_admin 可见(菜单不预授权,判据在后端
* AdminAppearancePatentCleanItemsControllerTest 的菜单迁移支,这里只管前端接线)。
*
* Phase 0 预置的判据(接缝名是判据的一部分,Phase 3 微调必须同步改本文件并登记蓝图 §5):
* ① 页面组件落位 `src/pages/patent/AppearancePatentCleanItemsPage.vue`,且确实是
* 自绘 table + OldPagination 的分页列表(不是卡片宫格);
* ② routes.ts 注册 `patent-center/clean-items`(menuKey `admin_appearance_patent_clean_items`,
* companyScoped: true),COMPANY_SCOPED_PAGES 同步登记(company-tab-wiring 护栏随注册自动覆盖);
* ③ 挂载行为样本(激活时补齐):mock api 模块 → mount → 翻页/改每页条数、切公司 Tab 重取、
* 任务号/ASIN/国家/起止时间筛选生效、空态与加载失败条。
*
* 跑法:`npx vitest run tests/mount/appearance-patent-clean-page.test.ts`
*/
import { readFileSync } from 'node:fs'
import { fileURLToPath, URL } from 'node:url'
import { describe, expect, it } from 'vitest'
import { adminPages } from '@/router/routes'
import { COMPANY_SCOPED_PAGES } from '@/config/company-scope'
const PAGE_PATH = 'src/pages/patent/AppearancePatentCleanItemsPage.vue'
const MENU_KEY = 'admin_appearance_patent_clean_items'
describe.skip('Pending Phase 3: AC-5 外观专利无侵权数据页(分页列表,参照去重数据库页)', () => {
it('页面组件落位且是自绘 table + OldPagination 的分页列表', () => {
const src = readFileSync(fileURLToPath(new URL(`../../${PAGE_PATH}`, import.meta.url)), 'utf-8')
expect(src).toContain('OldPagination')
expect(src).toContain('<table')
expect(src).not.toContain('el-card')
})
it('路由与公司 Tab 注册齐备(companyScoped: true)', () => {
const page = adminPages.find((p) => p.path === 'patent-center/clean-items')
expect(page).toBeTruthy()
expect(page?.menuKey).toBe(MENU_KEY)
expect(page?.title).toBe('外观专利无侵权数据')
expect(page?.companyScoped).toBe(true)
const scoped = COMPANY_SCOPED_PAGES.find((p) => p.menuKey === MENU_KEY)
expect(scoped).toBeTruthy()
expect(scoped?.pageFiles).toContain(PAGE_PATH)
})
it('挂载后走 snake 分页参数且切公司 Tab 重取(激活时用真组件挂载补齐)', async () => {
// 页面组件 Phase 3 才落盘,vite 的 import-analysis 会在收集期解析动态导入 ⇒
// 这里必须用运行期字符串 + @vite-ignore 推迟解析;skip 期间永不执行。
const pageModule = '@/pages/patent/AppearancePatentCleanItemsPage.vue'
// 激活时补齐:vi.mock('@/pages/patent/appearance-patent-clean-api.ts') →
// const { default: Page } = await import(pageModule)
// mount(Page, { global: { plugins: [createPinia()] } }) →
// 断言首次请求 query 的 page/page_size(snake)与 {items,total,page,pageSize} 解包;
// 改每页条数/翻页重发;companyTab.activeId 变化触发重取(护栏 company-tab-wiring 同口径)。
const { default: Page } = await import(/* @vite-ignore */ pageModule)
expect(Page).toBeTruthy()
})
})