Files
crawler-plugin/admin-frontend-vue/tests/align-shop-data-grid.test.ts
T

40 lines
1.7 KiB
TypeScript

import test from 'node:test'
import assert from 'node:assert/strict'
import { readSource } from './helpers.ts'
// 验收反馈:店铺数据记录卡片用宫格排(一行 3 个、一页 9 张卡片)+ 分页组件翻页。
const PAGE = 'src/pages/tasks/ShopDataTasksPage.vue'
test('align_shop_data_grid_normal_primary_path', () => {
const src = readSource(PAGE)
assert.match(src, /grid-template-columns:\s*repeat\(3,\s*1fr\)/, '卡片容器应为 3 列宫格')
})
test('align_shop_data_grid_normal_variant_input', () => {
const src = readSource(PAGE)
assert.match(src, /cardPageSize = ref\(10\)|cardPageSize\.value/, '卡片分页默认 10 张且可调')
assert.match(src, /cardPage\b/, '应有卡片页状态')
assert.match(src, /pagedResultRows|cardPageRows/, '卡片应绑定按 9 张切片的数据')
})
test('align_shop_data_grid_boundary_empty_input', () => {
// 卡片区下方有翻页组件(prev/next),与店铺分页并存(均为旧式分页)。
const src = readSource(PAGE)
const count = (src.match(/class="pagination"/g) || []).length + (src.match(/sd-shop-pager/g) || []).length
assert.ok(count >= 2, '页面应含店铺分页 + 卡片分页两处分页')
assert.match(src, /cardPage/, '卡片分页状态')
})
test('align_shop_data_grid_boundary_single_item', () => {
// 卡片渲染绑定分页后的数组而非全量。
const src = readSource(PAGE)
assert.match(src, /v-for="row in pagedResultRows"/, '卡片 v-for 使用分页后数组')
})
test('align_shop_data_grid_repeated_operation_is_idempotent', () => {
// 切店铺页时卡片页重置为第一页,避免空页。
const src = readSource(PAGE)
assert.match(src, /cardPage\s*(?:\.value)?\s*=\s*1/, '切页需重置卡片页到 1')
})