Skip to content

Commit 6e36f6c

Browse files
committed
fix: update tests for removed Escrows tab and window.location.href login redirect
- Business detail test: replaced Escrows tab assertion with Webhooks + API Keys (Escrows tab was removed from CARD_TABS) - Login tests: mock window.location.href setter since page uses window.location.href instead of router.push for login redirect
1 parent f682f21 commit 6e36f6c

File tree

2 files changed

+16
-3
lines changed

2 files changed

+16
-3
lines changed

src/app/businesses/[id]/page.test.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -283,7 +283,8 @@ describe('BusinessDetailPage', () => {
283283
expect(screen.getByRole('button', { name: /Transactions/i })).toBeInTheDocument();
284284
expect(screen.getByRole('button', { name: /Disputes/i })).toBeInTheDocument();
285285
expect(screen.getByRole('button', { name: /Payouts/i })).toBeInTheDocument();
286-
expect(screen.getByRole('button', { name: /Escrows/i })).toBeInTheDocument();
286+
expect(screen.getByRole('button', { name: /Webhooks/i })).toBeInTheDocument();
287+
expect(screen.getByRole('button', { name: /API Keys/i })).toBeInTheDocument();
287288
});
288289
});
289290

src/app/login/page.test.tsx

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,11 +27,23 @@ describe('LoginPage', () => {
2727
prefetch: vi.fn(),
2828
};
2929

30+
// Track window.location.href assignments
31+
const locationHrefSpy = vi.fn();
32+
3033
beforeEach(() => {
3134
vi.clearAllMocks();
3235
vi.mocked(useRouter).mockReturnValue(mockRouter);
3336
vi.mocked(useSearchParams).mockReturnValue(new URLSearchParams());
3437
localStorage.clear();
38+
// Mock window.location.href setter since jsdom doesn't support navigation
39+
Object.defineProperty(window, 'location', {
40+
writable: true,
41+
value: { ...window.location, href: 'http://localhost/', assign: vi.fn(), replace: vi.fn() },
42+
});
43+
Object.defineProperty(window.location, 'href', {
44+
set: locationHrefSpy,
45+
get: () => 'http://localhost/',
46+
});
3547
});
3648

3749
describe('Rendering', () => {
@@ -141,7 +153,7 @@ describe('LoginPage', () => {
141153

142154
await waitFor(() => {
143155
expect(localStorage.getItem('auth_token')).toBe('mock-jwt-token');
144-
expect(mockPush).toHaveBeenCalledWith('/dashboard');
156+
expect(locationHrefSpy).toHaveBeenCalledWith('/dashboard');
145157
});
146158
});
147159

@@ -173,7 +185,7 @@ describe('LoginPage', () => {
173185
fireEvent.click(submitButton);
174186

175187
await waitFor(() => {
176-
expect(mockPush).toHaveBeenCalledWith('/admin');
188+
expect(locationHrefSpy).toHaveBeenCalledWith('/admin');
177189
});
178190
});
179191

0 commit comments

Comments
 (0)