Skip to content

Commit 5ce95f2

Browse files
committed
Add contributors loading theme contrast tests
1 parent 477db10 commit 5ce95f2

1 file changed

Lines changed: 44 additions & 36 deletions

File tree

app/contributors/loading.theme-contrast.test.tsx

Lines changed: 44 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,7 @@ import { render, screen } from '@testing-library/react';
22
import { describe, expect, it } from 'vitest';
33
import Loading from './loading';
44

5-
const CONTRAST_RATIO = {
6-
blackOnWhite: 21,
7-
whiteOnBlack: 21,
8-
zinc500OnWhite: 4.83,
9-
zinc400OnBlack: 9.86,
10-
};
11-
12-
function expectClasses(element: Element | null, classes: string[]) {
5+
function hasClasses(element: Element | null, classes: string[]) {
136
expect(element).not.toBeNull();
147

158
for (const className of classes) {
@@ -24,56 +17,71 @@ describe('Contributors loading theme contrast', () => {
2417
const status = screen.getByRole('status');
2518

2619
expect(status.getAttribute('aria-live')).toBe('polite');
27-
expect(screen.getByText('Loading contributors...')).toBeTruthy();
20+
expect(screen.getByText('Loading the collective...')).toBeTruthy();
2821
expect(screen.getByText('Fetching contributor data from GitHub')).toBeTruthy();
2922
});
3023

31-
it('applies cohesive light theme background and text classes', () => {
24+
it('applies cohesive dark visual shell classes', () => {
3225
render(<Loading />);
3326

3427
const page = screen.getByRole('status').parentElement;
3528

36-
expectClasses(page, ['bg-white', 'text-black', 'transition-colors']);
29+
hasClasses(page, [
30+
'flex',
31+
'min-h-screen',
32+
'items-center',
33+
'justify-center',
34+
'bg-[#050505]',
35+
'text-white',
36+
]);
3737
});
3838

39-
it('applies cohesive dark theme background and text classes', () => {
39+
it('keeps contributor loading text visually readable', () => {
4040
render(<Loading />);
4141

42-
const page = screen.getByRole('status').parentElement;
42+
const primaryText = screen.getByText('Loading the collective...');
43+
const secondaryText = screen.getByText('Fetching contributor data from GitHub');
4344

44-
expectClasses(page, ['dark:bg-black', 'dark:text-white']);
45+
hasClasses(primaryText, ['text-zinc-400', 'font-light', 'text-lg']);
46+
hasClasses(secondaryText, ['text-sm', 'text-zinc-600', 'font-mono']);
4547
});
4648

47-
it('keeps all textual elements within expected contrast standards', () => {
49+
it('uses premium spinner styling with visible foreground contrast', () => {
4850
render(<Loading />);
4951

50-
const primaryText = screen.getByText('Loading contributors...');
51-
const secondaryText = screen.getByText('Fetching contributor data from GitHub');
52-
53-
expectClasses(primaryText, ['text-zinc-500', 'dark:text-zinc-400']);
54-
expectClasses(secondaryText, ['text-sm', 'text-zinc-400', 'dark:text-zinc-500']);
55-
56-
expect(CONTRAST_RATIO.blackOnWhite).toBeGreaterThanOrEqual(4.5);
57-
expect(CONTRAST_RATIO.whiteOnBlack).toBeGreaterThanOrEqual(4.5);
58-
expect(CONTRAST_RATIO.zinc500OnWhite).toBeGreaterThanOrEqual(4.5);
59-
expect(CONTRAST_RATIO.zinc400OnBlack).toBeGreaterThanOrEqual(4.5);
52+
const status = screen.getByRole('status');
53+
const spinnerWrapper = status.firstElementChild;
54+
const spinner = spinnerWrapper?.firstElementChild ?? null;
55+
56+
hasClasses(status, ['flex', 'flex-col', 'items-center', 'gap-6']);
57+
hasClasses(spinnerWrapper, ['relative']);
58+
hasClasses(spinner, [
59+
'h-16',
60+
'w-16',
61+
'animate-spin',
62+
'rounded-full',
63+
'border-2',
64+
'border-white/10',
65+
'border-t-cyan-400',
66+
]);
6067
});
6168

62-
it('keeps spinner and overlay styling from clipping foreground colors', () => {
69+
it('keeps glow overlay behind spinner without clipping foreground content', () => {
6370
render(<Loading />);
6471

6572
const status = screen.getByRole('status');
66-
const spinner = status.firstElementChild;
67-
68-
expectClasses(status, ['flex', 'flex-col', 'items-center', 'gap-4']);
69-
expectClasses(spinner, [
70-
'h-14',
71-
'w-14',
72-
'animate-spin',
73+
const spinnerWrapper = status.firstElementChild;
74+
const glowOverlay = spinnerWrapper?.children.item(1) ?? null;
75+
76+
hasClasses(glowOverlay, [
77+
'absolute',
78+
'inset-0',
79+
'h-16',
80+
'w-16',
7381
'rounded-full',
74-
'border-4',
75-
'border-cyan-400',
76-
'border-t-transparent',
82+
'bg-cyan-400/20',
83+
'blur-xl',
84+
'animate-pulse',
7785
]);
7886

7987
expect(status.classList.contains('overflow-hidden')).toBe(false);

0 commit comments

Comments
 (0)