refine Semi UI map controls

This commit is contained in:
lingniu
2026-07-18 07:09:05 +08:00
parent b54d5ba077
commit 45c0d4d9a3
3 changed files with 80 additions and 35 deletions

View File

@@ -603,9 +603,12 @@ test('renders one selected plate and smoothly follows it until the map is dragge
expect(setZoomAndCenter).toHaveBeenCalledTimes(1);
const follow = screen.getByRole('button', { name: '跟随车辆' });
expect(follow).toHaveClass('semi-button', 'v2-map-control-button', 'v2-map-follow-control', 'is-active');
expect(follow).toHaveTextContent('跟随中');
expect(follow).toHaveAttribute('aria-pressed', 'true');
act(() => mapHandlers.get('dragstart')?.({}));
expect(follow).toHaveAttribute('aria-pressed', 'false');
expect(follow).toHaveTextContent('已暂停');
const panCountAfterDrag = panTo.mock.calls.length;
view.rerender(
@@ -640,9 +643,12 @@ test('renders one selected plate and smoothly follows it until the map is dragge
expect(markerOptions[markerOptions.length - 1]?.content).toContain('is-idle');
const toggle = screen.getByRole('button', { name: '悬浮车牌' });
expect(toggle).toHaveClass('semi-button', 'v2-map-control-button', 'v2-map-layer-control', 'is-active');
expect(toggle).toHaveTextContent('已显示');
expect(toggle).toHaveAttribute('aria-pressed', 'true');
fireEvent.click(toggle);
await waitFor(() => expect(toggle).toHaveAttribute('aria-pressed', 'false'));
expect(toggle).toHaveTextContent('已隐藏');
expect(removeLabels).toHaveBeenCalled();
const hiddenFloatingLabels = removeLabels.mock.calls[removeLabels.mock.calls.length - 1]?.[0] as TestLabelMarker[];
expect(hiddenFloatingLabels).toHaveLength(1);