| | |
| | | |
| | | const statusMap: Record<TestStatusCode, TestStatus> = { |
| | | WAITING: '待测试', RUNNING: '检测中', PAUSED: '暂停', RUNNING_ABNORMAL: '检测中(异常)', |
| | | COMPLETION_PENDING: '完成确认中', COMPLETED: '检测完成', TERMINATED: '已终止', |
| | | COMPLETION_PENDING: '完成确认中', COMPLETED: '检测完成', TERMINATED: '检测完成', |
| | | } |
| | | const receptionStatusMap: Record<ReceptionStatusCode, ReceptionStatus> = { |
| | | NOT_STARTED: '未开始接收', RECEIVING: '接收中', PAUSED: '暂停接收', ENDED: '已结束接收', |
| | |
| | | return (await request<TestDetailResponse>(`/system/test/${testId}/reception/resume`, { method: 'POST' })).data |
| | | } |
| | | |
| | | /** 停止测试并进入不可恢复的已终止状态。 */ |
| | | /** 人工停止测试并将本次接收标记为检测完成。 */ |
| | | export async function stopTest(testId: number): Promise<TestConfigurationDetail> { |
| | | return (await request<TestDetailResponse>(`/system/test/${testId}/stop`, { method: 'POST' })).data |
| | | } |
| | |
| | | liveConnection.value = next.sources.some(source => Boolean(source.latestSnapshot?.observedAt) |
| | | || Boolean(source.latestSnapshot?.measurements?.length)) ? '已连接' : '空数据' |
| | | liveError.value = '' |
| | | testStatusLabel.value = ({ WAITING: '待测试', RUNNING: '检测中', PAUSED: '暂停', RUNNING_ABNORMAL: '检测中(异常)', COMPLETION_PENDING: '完成确认中', COMPLETED: '检测完成', TERMINATED: '已终止' } as Record<string, string>)[next.testStatus] || '未知' |
| | | testStatusLabel.value = ({ WAITING: '待测试', RUNNING: '检测中', PAUSED: '暂停', RUNNING_ABNORMAL: '检测中(异常)', COMPLETION_PENDING: '完成确认中', COMPLETED: '检测完成', TERMINATED: '检测完成' } as Record<string, string>)[next.testStatus] || '未知' |
| | | const mapped = next.receptionStatus |
| | | if (mapped === 'NOT_STARTED') receptionState.value = '未开始接收' |
| | | else if (mapped === 'PAUSED') receptionState.value = '暂停接收' |
| | |
| | | backendDetail.value = await stopTest(testId.value) |
| | | state.value = '已结束' |
| | | receptionState.value = '已结束接收' |
| | | testStatusLabel.value = '已终止' |
| | | testStatusLabel.value = '检测完成' |
| | | ElMessage.success('测试已停止,系统不再请求数据') |
| | | } catch (error) { |
| | | if (error === 'cancel' || error === 'close') return |
| | |
| | | '暂停': 'paused', |
| | | '检测中(异常)': 'abnormal', |
| | | '完成确认中': 'pending', |
| | | '已终止': 'abnormal', |
| | | '已终止': 'completed', |
| | | '未知': 'paused', |
| | | }[status] |
| | | } |
| | |
| | | updatedAt: '2026-08-30T06:00:00Z', sources: [{ |
| | | sourceType: 'COLLECTOR', sourceId: 8, batteryNo: 'BAT-01', deviceStatus: recovered ? 'ONLINE' : 'OFFLINE', |
| | | latestSnapshot: { source: '采集器', measurements: [], units: [] }, |
| | | }], exceptions: recovered ? [{ |
| | | sourceType: 'COLLECTOR', sourceId: 8, channelCode: 'S-01', exceptionType: 'COLLECTOR_DISCONNECTED', |
| | | status: 'CLOSED', missingFrom: '2026-08-30T05:59:00Z', missingTo: '2026-08-30T06:00:00Z', |
| | | }] : [{ |
| | | }], exceptions: recovered ? [] : [{ |
| | | sourceType: 'COLLECTOR', sourceId: 8, channelCode: 'S-01', exceptionType: 'COLLECTOR_DISCONNECTED', |
| | | status: 'OPEN', missingFrom: '2026-08-30T05:59:00Z', |
| | | }], |
| | |
| | | recovered = true |
| | | await page.evaluate(() => window.dispatchEvent(new Event('ticket11-reconnect'))) |
| | | await page.reload() |
| | | await expect(page.getByText('采集器#8断线已恢复 · S-01', { exact: true })).toBeVisible() |
| | | await expect(page.getByText('已恢复 · 2026-08-30T05:59:00Z 至 2026-08-30T06:00:00Z', { exact: true })).toBeVisible() |
| | | await expect(page.getByText('暂无异常', { exact: true })).toBeVisible() |
| | | }) |
| | |
| | | const request = route.request() |
| | | if (request.method() === 'POST' && request.url().endsWith('/reception/pause')) { status = 'PAUSED'; actionRequests.push('pause') } |
| | | if (request.method() === 'POST' && request.url().endsWith('/reception/resume')) { status = 'RECEIVING'; actionRequests.push('resume') } |
| | | if (request.method() === 'POST' && request.url().endsWith('/stop')) { status = 'ENDED'; testStatus = 'TERMINATED'; actionRequests.push('stop') } |
| | | if (request.method() === 'POST' && request.url().endsWith('/stop')) { status = 'ENDED'; testStatus = 'COMPLETED'; actionRequests.push('stop') } |
| | | if (request.url().endsWith('/live-state')) { |
| | | await route.fulfill({ status: 200, contentType: 'application/json', body: JSON.stringify({ code: 200, data: { testId: 42, testStatus, receptionStatus: status, updatedAt: '2026-08-30T06:00:00Z', sources: [], exceptions: [] } }) }) |
| | | return |
| | |
| | | await page.getByRole('button', { name: '停止测试', exact: true }).click() |
| | | await page.getByRole('button', { name: '停止测试', exact: true }).last().click() |
| | | await expect(page.locator('.running-state')).toHaveText('已结束') |
| | | await expect(page.locator('.test-state')).toHaveText('测试状态:已终止') |
| | | await expect(page.locator('.test-state')).toHaveText('测试状态:检测完成') |
| | | await expect(page.locator('.reception-state')).toHaveText('已结束接收') |
| | | await expect(page.locator('button.danger-button')).toBeDisabled() |
| | | await expect(page.locator('.interval-count')).toHaveCount(0) |