fix(ui): корректно отображать историю в карточках трафика
This commit is contained in:
1 parent
ccbc1aa029
commit
f3568d836b
5 files changed
+71
-45
No files matched your search
@@ -15,7 +15,7 @@ async function setup(page: Page) {
|
||||
return route.fulfill({ json: { server: { ...server, rxSeries: control.series ?? server.rxSeries, txSeries: control.txSeries ?? control.series ?? server.txSeries, name: `Детали ${range} ${iface}`, rxNow: range === '24h' ? 24 : 15 } } })
|
||||
}
|
||||
const json = path === '/api/auth/config' ? { required: false }
|
||||
: path === '/api/traffic/servers' ? { servers: [server] }
|
||||
: path === '/api/traffic/servers' ? { servers: [{ ...server, rxSeries: control.series ?? server.rxSeries, txSeries: control.txSeries ?? control.series ?? server.txSeries }] }
|
||||
: path === '/api/traffic/servers/1/interfaces' ? { interfaces: [{ name: 'ether2', running: true, disabled: false, rxNow: 0, txNow: 0 }] }
|
||||
: path.endsWith('/interfaces') || path === '/api/traffic/bound-interfaces' ? { interfaces: [] }
|
||||
: path === '/api/traffic/users' ? { users: [] }
|
||||
@@ -104,3 +104,23 @@ for (const missing of ['RX', 'TX'] as const) {
|
||||
await expect(chart.getByText((missing === 'RX' ? 'TX' : 'RX') + ':', { exact: true })).toBeVisible()
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
test('Карточка трафика: пустая история, одна точка, нулевой TX и разрыв', async ({ page }) => {
|
||||
const control = await setup(page)
|
||||
const card = page.getByRole('button').filter({ hasText: 'Первый сервер' })
|
||||
control.series = []
|
||||
control.txSeries = []
|
||||
await page.getByRole('button', { name: '24ч', exact: true }).click()
|
||||
await expect(card).toContainText('Нет истории трафика')
|
||||
control.series = [2]
|
||||
await page.getByRole('button', { name: '15м', exact: true }).click()
|
||||
await expect(card.locator('circle')).toHaveCount(1)
|
||||
await expect(card.locator('circle')).toHaveAttribute('cx', '150')
|
||||
control.series = [2, 3, -1, 4, 5]
|
||||
control.txSeries = [0, 0, 0, 0, 0]
|
||||
await page.getByRole('button', { name: '4ч', exact: true }).click()
|
||||
await expect(card.locator('[data-direction="rx"] polyline')).toHaveCount(2)
|
||||
await expect(card.locator('[data-direction="tx"] polyline')).toHaveCount(1)
|
||||
expect(await card.locator('svg').last().innerHTML()).not.toMatch(/NaN|Infinity/)
|
||||
})
|
||||
Reference in new issue
Block a user