diff --git a/web-admin/scripts/stop-documents.test.ts b/web-admin/scripts/stop-documents.test.ts index 6e414cf05..928230d34 100644 --- a/web-admin/scripts/stop-documents.test.ts +++ b/web-admin/scripts/stop-documents.test.ts @@ -81,7 +81,7 @@ function harness(fixed?: string) { const state = scope.run(() => new Function( ...Object.keys(env), - `${code}; return { rows, details, load, loadDetail, allowed, canUpload, keyword, setFilterState, page, total, expansionStyle, open, save, visible, editing, upload, saving, editorLoading, status, search, statusLabel }` + `${code}; return { rows, details, load, loadDetail, allowed, canUpload, keyword, setFilterState, page, total, expansionStyle, open, save, visible, editing, upload, saving, editorLoading, status, search, statusLabel, reset, visibleColumns }` )(...Object.values(env)) ) return { @@ -509,3 +509,33 @@ test('status is a server single filter and combines with the number filter', asy await flush() h.stop() }) + +test('latest refresh wins and hidden column/reset preserve server filter semantics', async () => { + const h = harness(), + s = h.state + h.permissions[0].resolve({ all: true }) + await flush() + const fresh = s.load() + h.calls[1].resolve({ list: [{ id: 'new' }], total: 45 }) + await fresh + h.calls[0].resolve({ list: [{ id: 'old' }], total: 1 }) + await flush() + assert.equal(s.rows.value[0].id, 'new') + assert.equal(s.total.value, 45) + s.keyword.value = 'quick' + s.status.value = 'pending' + s.page.value = 2 + s.setFilterState('planNo', { text: 'PL' }) + assert.equal(s.page.value, 1) + assert.equal(h.calls.at(-1).args[0].planNo, 'PL') + s.visibleColumns.value = s.visibleColumns.value.filter((key: string) => key !== 'planNo') + await vue.nextTick() + assert.equal(h.calls.at(-1).args[0].planNo, undefined) + assert.equal(h.calls.at(-1).args[0].status, 'pending') + s.reset() + assert.equal(h.calls.at(-1).args[0].keyword, '') + assert.equal(h.calls.at(-1).args[0].status, undefined) + h.calls.forEach((c) => c.resolve({ list: [], total: 0 })) + await flush() + h.stop() +})