fix(frontend): code-review polish — replaceState, arrow-key nav, TabId, comment
Fix 4: useHashTab navigate() uses history.replaceState instead of window.location.hash assignment — no spurious history entries, no anchor-jump scroll side-effect. Fix 5: Tabs ArrowLeft/ArrowRight keyboard nav (WAI-ARIA tabs pattern). Fix 6: TabId union type in EngagementDetailPage, cast from string for type-safe switch on activeTab without breaking Tabs.onChange signature. Fix 7: intentional comment on UsersAdminPage reset-password aerated row. Tests: 236/236 (+2 arrow-key assertions in Tabs.test.tsx). Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -59,6 +59,20 @@ describe('Tabs', () => {
|
||||
expect(simsBtn).toHaveAttribute('aria-controls', 'tabpanel-simulations');
|
||||
});
|
||||
|
||||
it('ArrowRight moves focus to the next tab', () => {
|
||||
const onChange = vi.fn();
|
||||
render(<Tabs items={ITEMS} activeId="schedule" onChange={onChange} />);
|
||||
fireEvent.keyDown(screen.getByRole('tab', { name: /Schedule/i }), { key: 'ArrowRight' });
|
||||
expect(onChange).toHaveBeenCalledWith('description');
|
||||
});
|
||||
|
||||
it('ArrowLeft wraps around to the last tab', () => {
|
||||
const onChange = vi.fn();
|
||||
render(<Tabs items={ITEMS} activeId="schedule" onChange={onChange} />);
|
||||
fireEvent.keyDown(screen.getByRole('tab', { name: /Schedule/i }), { key: 'ArrowLeft' });
|
||||
expect(onChange).toHaveBeenCalledWith('simulations');
|
||||
});
|
||||
|
||||
it('has no rounded-md, transition-*, or shadow-* on tab buttons (brutalism)', () => {
|
||||
render(<Tabs items={ITEMS} activeId="schedule" onChange={vi.fn()} />);
|
||||
for (const btn of screen.getAllByRole('tab')) {
|
||||
|
||||
@@ -22,7 +22,7 @@ describe('useHashTab', () => {
|
||||
expect(result.current[0]).toBe('simulations');
|
||||
});
|
||||
|
||||
it('navigate() updates activeId and sets location.hash', () => {
|
||||
it('navigate() updates activeId and sets hash via replaceState (no history entry)', () => {
|
||||
const { result } = renderHook(() => useHashTab('schedule'));
|
||||
act(() => {
|
||||
result.current[1]('description');
|
||||
|
||||
Reference in New Issue
Block a user