From 6e48963e66823f9604e6eb3ff781bf5e92f176c7 Mon Sep 17 00:00:00 2001 From: Adam Date: Fri, 23 Oct 2026 00:38:34 +0000 Subject: [PATCH] test(share): wait for the not-found title and robots meta effect The not-found heading commits before the passive effect that sets document.title and the robots meta, so asserting right after findByRole failed about 1 run in 12-15. Wait for both. Test-only; the component is correct. --- src/test/pages/SharedPage.test.tsx | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/test/pages/SharedPage.test.tsx b/src/test/pages/SharedPage.test.tsx index adc24ff3d..8f9306138 100644 --- a/src/test/pages/SharedPage.test.tsx +++ b/src/test/pages/SharedPage.test.tsx @@ -1,5 +1,5 @@ import { beforeEach, describe, expect, it, vi } from 'vitest'; -import { render, screen } from '@testing-library/react'; +import { render, screen, waitFor } from '@testing-library/react'; import { MemoryRouter, Route, Routes } from 'react-router-dom'; import { AuthContext, type AuthContextValue } from '@/lib/supabase/auth-context'; import SharedPage from '@/pages/SharedPage'; @@ -54,8 +54,11 @@ describe('a missing share link', () => { expect(screen.queryByRole('heading', { name: 'Shared Content' })).not.toBeInTheDocument(); expect(screen.getByText('This shared content is no longer available')).toBeInTheDocument(); expect(screen.getByRole('link', { name: 'Back to home' })).toHaveAttribute('href', '/'); - expect(document.title).toBe('Shared link not found · DebateLab'); - expect(document.head.querySelector('meta[name="robots"]')?.getAttribute('content')).toBe('noindex, nofollow'); + // The heading commits before the passive effect that sets the title and robots meta runs. + await waitFor(() => expect(document.title).toBe('Shared link not found · DebateLab')); + await waitFor(() => + expect(document.head.querySelector('meta[name="robots"]')?.getAttribute('content')).toBe('noindex, nofollow'), + ); }); it('still shows a shared item that exists', async () => {