Skip to content

Commit 0497f9e

Browse files
committed
fix: restore dark mode styling for activity help popover
1 parent 0971ee3 commit 0497f9e

File tree

2 files changed

+76
-1
lines changed

2 files changed

+76
-1
lines changed
Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
import '@testing-library/jest-dom';
2+
import { fireEvent, render, screen } from '@testing-library/react';
3+
import { Round } from '@wca/helpers';
4+
import { MemoryRouter } from 'react-router-dom';
5+
import { CutoffTimeLimitPanel } from './CutoffTimeLimitPanel';
6+
7+
jest.mock('react-tiny-popover', () => ({
8+
Popover: ({
9+
children,
10+
content,
11+
isOpen,
12+
}: {
13+
children: React.ReactNode;
14+
content: React.ReactNode;
15+
isOpen: boolean;
16+
}) => (
17+
<div>
18+
{children}
19+
{isOpen ? content : null}
20+
</div>
21+
),
22+
}));
23+
24+
jest.mock('react-i18next', () => ({
25+
Trans: ({ i18nKey }: { i18nKey: string }) => i18nKey,
26+
useTranslation: () => ({
27+
t: (key: string) => key,
28+
}),
29+
}));
30+
31+
jest.mock('@/providers/WCIFProvider', () => ({
32+
useWCIF: () => ({
33+
competitionId: 'TestComp2026',
34+
wcif: {
35+
id: 'TestComp2026',
36+
schedule: { venues: [] },
37+
},
38+
setTitle: () => {},
39+
}),
40+
}));
41+
42+
const round = {
43+
id: '333-r1',
44+
cutoff: {
45+
numberOfAttempts: 2,
46+
attemptResult: 1200,
47+
},
48+
timeLimit: null,
49+
advancementCondition: null,
50+
} as unknown as Round;
51+
52+
function renderPanel() {
53+
return render(
54+
<MemoryRouter>
55+
<CutoffTimeLimitPanel round={round} />
56+
</MemoryRouter>,
57+
);
58+
}
59+
60+
describe('CutoffTimeLimitPanel', () => {
61+
it('uses theme-aware popover classes for help content', () => {
62+
renderPanel();
63+
64+
fireEvent.click(screen.getByRole('button', { name: /help/i }));
65+
66+
const popoverContent = screen
67+
.getByText(/common\.cutoffTimeLimitPopover\.timeLimits/i)
68+
.closest('div');
69+
70+
expect(popoverContent).toHaveClass('bg-panel');
71+
expect(popoverContent).toHaveClass('text-default');
72+
expect(popoverContent).not.toHaveClass('bg-white');
73+
});
74+
});

src/components/CutoffTimeLimitPanel/CutoffTimeLimitPanel.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ function CutoffTimeLimitPopover({ cutoff }: { cutoff: Cutoff | null }) {
138138
content={
139139
<div
140140
className={classNames(
141-
'z-1000 max-w-xs md:max-w-md lg:max-w-lg type-body-sm transition-opacity duration-300 bg-white border border-tertiary-weak rounded-lg shadow-md opacity-0 p-4 space-y-2',
141+
'z-1000 max-w-xs p-4 space-y-2 transition-opacity duration-300 border rounded-lg shadow-md md:max-w-md lg:max-w-lg type-body-sm bg-panel text-default border-tertiary-weak opacity-0',
142142
{
143143
'opacity-100': open,
144144
},
@@ -166,6 +166,7 @@ function CutoffTimeLimitPopover({ cutoff }: { cutoff: Cutoff | null }) {
166166
}>
167167
<button
168168
className="px-1 mr-2"
169+
aria-label={t('common.help')}
169170
// className="p-2 px-3 text-sm rounded-full shadow-sm fa-solid fa-question bg-slate-300 hover:opacity-70"
170171
onClick={() => setOpen((prev) => !prev)}>
171172
<svg

0 commit comments

Comments
 (0)