Skip to content

Commit d7cdba8

Browse files
authored
test: add personality tag coverage in compare mode (JhaSourav07#2036)
2 parents 0cb47f8 + 8f37dba commit d7cdba8

1 file changed

Lines changed: 31 additions & 0 deletions

File tree

components/dashboard/DashboardClient.test.tsx

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -354,6 +354,37 @@ describe('DashboardClient', () => {
354354
// 5. Assert input value is empty
355355
expect((input as HTMLInputElement).value).toBe('');
356356
});
357+
358+
// =========================================================================
359+
// ISSUE OBJECTIVE: Verify personality tags render in compare mode
360+
// =========================================================================
361+
it('renders personality tags for both profiles in compare mode', async () => {
362+
const mockFetch = vi.fn().mockResolvedValue({
363+
ok: true,
364+
json: async () => mockSecondData,
365+
});
366+
367+
vi.stubGlobal('fetch', mockFetch);
368+
369+
render(<DashboardClient initialData={mockInitialData} username="Shivangi1515" />);
370+
371+
fireEvent.click(screen.getByText('Compare Profile'));
372+
373+
fireEvent.change(screen.getByPlaceholderText('Enter GitHub Username'), {
374+
target: { value: 'JhaSourav07' },
375+
});
376+
377+
fireEvent.click(screen.getByText('Compare'));
378+
379+
await waitFor(() => {
380+
expect(screen.getByText('Exit Compare Mode')).toBeDefined();
381+
});
382+
383+
// Both profiles have stats that generate the "Consistency Beast 🔥" tag
384+
// Using Regex /.../i to match the text even if there is an emoji next to it!
385+
const tags = screen.getAllByText(/Consistency Beast/i);
386+
expect(tags).toHaveLength(2);
387+
});
357388
});
358389
it('shows Most Consistent badge for profile with higher peak streak in compare mode', async () => {
359390
const mockFetch = vi.fn().mockResolvedValue({

0 commit comments

Comments
 (0)