按当前筛选后的完整已载入顺序切换,边界自动禁用,后台续页到达后自动开放。 独立保存选中目标以支持加载及失败时切换,沿用取消/迟到响应隔离,关闭返回原表格焦点。 验证:详情首中尾/未知目标、加载/失败、100到101续页先红后绿;既有流水和看板范围回归、完整门禁及原生备份恢复通过。
This commit is contained in:
@@ -52,6 +52,58 @@ const props = {
|
||||
}
|
||||
|
||||
describe('QA operations workbench', () => {
|
||||
it('puts previous/next in the detail header and follows the entire filtered result, including loading and error states', () => {
|
||||
const items = Array.from({ length: 101 }, (_, index) => ({ ...item, id: 'filtered-' + index }))
|
||||
const cases = [
|
||||
{ index: 0, previous: false, next: true },
|
||||
{ index: 50, previous: true, next: true },
|
||||
{ index: 100, previous: true, next: false },
|
||||
{ index: -1, previous: false, next: false },
|
||||
]
|
||||
for (const state of ['ready', 'loading', 'failed']) {
|
||||
for (const value of cases) {
|
||||
const selected = items[value.index] ?? { ...item, id: 'not-in-this-filter' }
|
||||
const html = renderToStaticMarkup(
|
||||
<QAOperationsView
|
||||
{...props}
|
||||
page={{ ...page, items, total: items.length }}
|
||||
detailID={selected.id}
|
||||
detail={state === 'ready' ? selected : null}
|
||||
detailLoading={state === 'loading'}
|
||||
detailError={state === 'failed' ? '详情读取失败' : null}
|
||||
/>
|
||||
)
|
||||
const drawer = html.slice(html.indexOf('<aside'))
|
||||
const header = drawer.slice(0, drawer.indexOf('</header>'))
|
||||
for (const [label, enabled] of [
|
||||
['上一条', value.previous],
|
||||
['下一条', value.next],
|
||||
] as const) {
|
||||
const button = header.match(new RegExp('<button([^>]*)>' + label + '</button>'))
|
||||
expect(button, state + ': ' + selected.id + ': ' + label).not.toBeNull()
|
||||
expect(button?.[1].includes('disabled=""')).toBe(!enabled)
|
||||
}
|
||||
}
|
||||
}
|
||||
})
|
||||
it('enables next automatically when the background reader appends the next page', () => {
|
||||
const items = Array.from({ length: 101 }, (_, index) => ({ ...item, id: 'filtered-' + index }))
|
||||
for (const loaded of [100, 101]) {
|
||||
const html = renderToStaticMarkup(
|
||||
<QAOperationsView
|
||||
{...props}
|
||||
page={{ ...page, items: items.slice(0, loaded), total: 101, has_more: loaded < 101 }}
|
||||
detail={items[99]}
|
||||
loading={loaded < 101}
|
||||
/>
|
||||
)
|
||||
const drawer = html.slice(html.indexOf('<aside'))
|
||||
const button = drawer.slice(0, drawer.indexOf('</header>')).match(/<button([^>]*)>下一条<\/button>/)
|
||||
expect(button).not.toBeNull()
|
||||
expect(button?.[1].includes('disabled=""')).toBe(loaded === 100)
|
||||
}
|
||||
})
|
||||
|
||||
it('puts all five selectors in their own table header cells, including empty filtered results', () => {
|
||||
const filtering = { filters: { coverage: '否' }, onFiltersChange: vi.fn() }
|
||||
for (const value of [page, { ...page, items: [], total: 0, has_more: false }]) {
|
||||
|
||||
Reference in New Issue
Block a user