polish Semi UI alert subworkspaces

This commit is contained in:
lingniu
2026-07-18 18:56:01 +08:00
parent db1079ae27
commit 84684f2dc1
3 changed files with 282 additions and 30 deletions

View File

@@ -86,7 +86,8 @@ test('loads a paginated notification page and an independent unread total on dir
expect(view.container.querySelector('.v2-alert-notification-empty.semi-empty')).toBeInTheDocument();
expect(view.container.querySelector('.v2-alert-notification-pagination')).toBeInTheDocument();
expect(screen.getByRole('combobox', { name: '每页通知数' })).toBeInTheDocument();
expect(view.container.querySelector('.v2-alert-channel-card.semi-card')).toBeInTheDocument();
expect(view.container.querySelector('.v2-alert-channel-collapse.semi-collapse')).toBeInTheDocument();
expect(screen.getByText('3 个 · 未启用')).toBeInTheDocument();
expect(view.container.querySelector('.v2-alert-channel-descriptions.semi-descriptions')).toBeInTheDocument();
expect(mocks.alertRulesV2).not.toHaveBeenCalled();
expect(mocks.metricCatalog).not.toHaveBeenCalled();
@@ -112,6 +113,18 @@ test('ends notification mutation feedback with a visible retryable error instead
expect(screen.getByRole('button', { name: '标为已读' })).toBeEnabled();
});
test('keeps the mobile notification title, count, and compact bulk action visible together', async () => {
layout.mobile = true;
mocks.alertNotificationsV2.mockResolvedValue({ items: [{ id: 8, eventId: 'event-8', title: '车辆告警', content: '移动端告警', severity: 'major', read: false, createdAt: '2026-07-16T04:00:00Z' }], total: 1, limit: 100, offset: 0 });
const client = new QueryClient({ defaultOptions: { queries: { retry: false } } });
render(<QueryClientProvider client={client}><MemoryRouter future={ROUTER_FUTURE} initialEntries={['/alerts?tab=notifications']}><AlertsPage /></MemoryRouter></QueryClientProvider>);
const heading = await screen.findByRole('heading', { level: 5, name: /通知列表/ });
await waitFor(() => expect(heading).toHaveTextContent('1 条'));
expect(heading.querySelector('.v2-alert-notification-total.semi-tag')).toBeInTheDocument();
expect(screen.getByRole('button', { name: '本页已读' })).toBeInTheDocument();
});
test('clears old alert rows and inspector evidence when the event scope changes', async () => {
const oldEvent = alertEvent('old-event', 'OLDVIN', '旧告警车牌');
oldEvent.actions = [{ id: 1, action: 'detect', fromStatus: '', toStatus: 'unprocessed', actor: 'alert-evaluator', note: '规则首次命中', createdAt: '2026-07-16T04:00:00Z' }];
@@ -324,6 +337,7 @@ test('keeps mobile rule selection focused and opens editing in a Semi bottom Sid
expect(document.querySelector('.v2-alert-rule-editor-sidesheet .semi-sidesheet-inner')).toHaveStyle({ height: 'min(92dvh, 820px)' });
expect(within(editor).getByDisplayValue('测试超速规则')).toBeInTheDocument();
expect(within(editor).getByRole('button', { name: '保存规则' })).toBeInTheDocument();
expect(within(editor).queryByRole('region', { name: '告警规则模板' })).not.toBeInTheDocument();
expect(ruleItem).toHaveAttribute('aria-expanded', 'true');
fireEvent.click(within(editor).getByRole('button', { name: '关闭告警规则编辑' }));
@@ -337,6 +351,7 @@ test('keeps mobile rule selection focused and opens editing in a Semi bottom Sid
await waitFor(() => expect(document.querySelector('.v2-alert-rule-editor')).toBeInTheDocument());
const newEditor = screen.getByRole('dialog', { name: '告警规则编辑' });
expect(within(newEditor).getByText('新建规则')).toBeInTheDocument();
expect(within(newEditor).getByRole('region', { name: '告警规则模板' })).toBeInTheDocument();
expect(newRule).toHaveAttribute('aria-expanded', 'true');
});
@@ -363,7 +378,9 @@ test('creates auditable drafts from simple offline and hydrogen rule templates',
await waitFor(() => expect(ruleItem).toHaveAttribute('aria-pressed', 'true'));
expect(within(ruleItem).getByText('重要').closest('.semi-tag')).toBeTruthy();
expect(within(ruleItem).getByText('已启用').closest('.semi-tag')).toBeTruthy();
expect(screen.queryByRole('region', { name: '告警规则模板' })).not.toBeInTheDocument();
fireEvent.click(screen.getByRole('button', { name: /新建规则/ }));
const offlineTemplate = await screen.findByRole('button', { name: /离线超过 10 小时/ });
expect(offlineTemplate).toHaveClass('semi-button', 'v2-alert-template-card');
expect(within(offlineTemplate).getByText('GB32960 / JT808 / YUTONG_MQTT').closest('.semi-tag')).toBeTruthy();