feat(web): 同步预约演示与兜底渠道优化
This commit is contained in:
@@ -47,14 +47,13 @@ test('uses backend pagination and preserves all business fields and line breaks'
|
||||
await api.fetchDemoReservations({ page: 2, pageSize: 20 }),
|
||||
data,
|
||||
);
|
||||
const [method, path] = api.requests[0];
|
||||
const [method, path, , , { params }] = api.requests[0];
|
||||
assert.equal(method, 'get');
|
||||
const url = new URL(path, 'https://example.com');
|
||||
assert.equal(url.pathname, '/api/website/demo-requests');
|
||||
assert.equal(url.searchParams.get('p'), '2');
|
||||
assert.equal(url.searchParams.get('page_size'), '20');
|
||||
assert.equal(url.searchParams.has('pageNum'), false);
|
||||
assert.equal(url.searchParams.has('pageSize'), false);
|
||||
assert.equal(path, '/api/website/demo-requests');
|
||||
assert.equal(params.p, 2);
|
||||
assert.equal(params.page_size, 20);
|
||||
assert.equal('pageNum' in params, false);
|
||||
assert.equal('pageSize' in params, false);
|
||||
});
|
||||
|
||||
test('encodes three trimmed fuzzy AND filters without losing literal plus and wildcard characters', async () => {
|
||||
@@ -64,13 +63,14 @@ test('encodes three trimmed fuzzy AND filters without losing literal plus and wi
|
||||
contact: ' +86 138%_!& ',
|
||||
companyName: ' 测试科技 ',
|
||||
});
|
||||
const params = new URL(api.requests[0][1], 'https://example.com')
|
||||
.searchParams;
|
||||
assert.equal(params.get('name'), '张');
|
||||
assert.equal(params.get('contact'), '+86 138%_!&');
|
||||
assert.equal(params.get('companyName'), '测试科技');
|
||||
assert.equal(params.get('p'), '1');
|
||||
assert.equal(params.get('page_size'), '10');
|
||||
const { params } = api.requests[0][4];
|
||||
assert.deepEqual(params, {
|
||||
name: '张',
|
||||
contact: '+86 138%_!&',
|
||||
companyName: '测试科技',
|
||||
p: 1,
|
||||
page_size: 10,
|
||||
});
|
||||
});
|
||||
|
||||
test('returns empty matches and out-of-range pages with the actual backend total', async () => {
|
||||
@@ -95,3 +95,27 @@ test('fails visibly on malformed responses or backend errors', async () => {
|
||||
const api = await harness(new Error('没有平台管理员权限'));
|
||||
await assert.rejects(api.fetchDemoReservations(), /没有平台管理员权限/);
|
||||
});
|
||||
|
||||
test('sends status and delete mutations through the website API', async () => {
|
||||
const api = await harness(null);
|
||||
await api.setDemoReservationEnabled(4, false);
|
||||
await api.deleteDemoReservation(4);
|
||||
assert.deepEqual(api.requests[0].slice(0, 3), [
|
||||
'put',
|
||||
'/api/website/demo-requests/4/status',
|
||||
{ enabled: false },
|
||||
]);
|
||||
assert.deepEqual(api.requests[1].slice(0, 2), [
|
||||
'delete',
|
||||
'/api/website/demo-requests/4',
|
||||
]);
|
||||
});
|
||||
|
||||
test('passes an abort signal to the list request so refreshes bypass pending GETs', async () => {
|
||||
const api = await harness(response());
|
||||
const { signal } = new AbortController();
|
||||
await api.fetchDemoReservations({ page: 2 }, { signal });
|
||||
const options = api.requests[0][4];
|
||||
assert.equal(options.signal, signal);
|
||||
assert.equal(options.params.p, 2);
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user