|
1 | 1 | import { beforeEach, describe, expect, it, vi } from 'vitest'; |
2 | | -import { render, screen } from '@testing-library/react'; |
| 2 | +import { render, screen, waitFor } from '@testing-library/react'; |
3 | 3 | import { MemoryRouter, Route, Routes } from 'react-router-dom'; |
4 | 4 | import { AuthContext, type AuthContextValue } from '@/lib/supabase/auth-context'; |
5 | 5 | import SharedPage from '@/pages/SharedPage'; |
@@ -54,8 +54,11 @@ describe('a missing share link', () => { |
54 | 54 | expect(screen.queryByRole('heading', { name: 'Shared Content' })).not.toBeInTheDocument(); |
55 | 55 | expect(screen.getByText('This shared content is no longer available')).toBeInTheDocument(); |
56 | 56 | expect(screen.getByRole('link', { name: 'Back to home' })).toHaveAttribute('href', '/'); |
57 | | - expect(document.title).toBe('Shared link not found · DebateLab'); |
58 | | - expect(document.head.querySelector('meta[name="robots"]')?.getAttribute('content')).toBe('noindex, nofollow'); |
| 57 | + // The heading commits before the passive effect that sets the title and robots meta runs. |
| 58 | + await waitFor(() => expect(document.title).toBe('Shared link not found · DebateLab')); |
| 59 | + await waitFor(() => |
| 60 | + expect(document.head.querySelector('meta[name="robots"]')?.getAttribute('content')).toBe('noindex, nofollow'), |
| 61 | + ); |
59 | 62 | }); |
60 | 63 |
|
61 | 64 | it('still shows a shared item that exists', async () => { |
|
0 commit comments