11import { expect , test } from "@playwright/test" ;
2- import { HOST_EMAIL , signIn } from "./helpers" ;
2+ import { DONOR_EMAIL , HOST_EMAIL , signIn } from "./helpers" ;
33
4- test ( "homepage hydrates without chat date mismatches " , async ( {
4+ test ( "homepage renders static content before deferred chat demo hydrates " , async ( {
55 browser,
66 page,
77} ) => {
@@ -42,9 +42,6 @@ test("homepage hydrates without chat date mismatches", async ({
4242 const serverDayLabels = await serverPage
4343 . getByTestId ( "chat-day-label" )
4444 . allTextContents ( ) ;
45- const serverTimestamps = await serverPage
46- . getByTestId ( "chat-message-timestamp" )
47- . allTextContents ( ) ;
4845 await serverContext . close ( ) ;
4946
5047 await page . waitForLoadState ( "networkidle" ) ;
@@ -59,9 +56,9 @@ test("homepage hydrates without chat date mismatches", async ({
5956 . getByTestId ( "chat-message-timestamp" )
6057 . allTextContents ( ) ;
6158
62- expect ( serverDayLabels ) . toEqual ( [ "Thu, May 1" , "Fri, May 2" ] ) ;
59+ expect ( serverDayLabels ) . toEqual ( [ ] ) ;
6360 expect ( hydratedDayLabels ) . toEqual ( [ "Yesterday" , "Today" ] ) ;
64- expect ( hydratedTimestamps ) . toEqual ( serverTimestamps ) ;
61+ expect ( hydratedTimestamps ) . toHaveLength ( 2 ) ;
6562 expect (
6663 pageErrors . some ( ( message ) => message . includes ( "Minified React error #418" ) )
6764 ) . toBeFalsy ( ) ;
@@ -152,6 +149,7 @@ test("homepage account button stays hidden while signed-in profile state loads",
152149
153150 await expect ( profileAccountButton ) . toHaveAttribute ( "href" , "/profile" ) ;
154151 await expect ( profileAccountButton ) . toHaveCSS ( "opacity" , "1" ) ;
152+ await expect ( page . getByTestId ( "locale-picker-select" ) ) . toHaveCount ( 0 ) ;
155153} ) ;
156154
157155test ( "homepage account button links guests to sign in" , async ( { page } ) => {
@@ -162,4 +160,40 @@ test("homepage account button links guests to sign in", async ({ page }) => {
162160 "/sign-in"
163161 ) ;
164162 await expect ( page . getByTestId ( "account-button-profile" ) ) . toHaveCount ( 0 ) ;
163+ await expect ( page . getByTestId ( "locale-picker-select" ) ) . toBeVisible ( ) ;
164+ } ) ;
165+
166+ test ( "homepage unread chat dot appears after scoped unread check" , async ( {
167+ page,
168+ } ) => {
169+ await page . route ( / \/ r e s t \/ v 1 \/ c h a t _ t h r e a d s (?: \? | $ ) / , async ( route ) => {
170+ if ( route . request ( ) . method ( ) !== "GET" ) {
171+ await route . continue ( ) ;
172+ return ;
173+ }
174+
175+ await route . fulfill ( {
176+ status : 200 ,
177+ contentType : "application/json" ,
178+ body : JSON . stringify ( [ { id : "33333333-3333-4333-8333-333333333333" } ] ) ,
179+ } ) ;
180+ } ) ;
181+ await page . route (
182+ / \/ r e s t \/ v 1 \/ r p c \/ u n r e a d _ c h a t _ t h r e a d _ i d s (?: \? | $ ) / ,
183+ async ( route ) => {
184+ await route . fulfill ( {
185+ status : 200 ,
186+ contentType : "application/json" ,
187+ body : JSON . stringify ( [
188+ { thread_id : "33333333-3333-4333-8333-333333333333" } ,
189+ ] ) ,
190+ } ) ;
191+ }
192+ ) ;
193+
194+ await signIn ( page , { email : DONOR_EMAIL , redirectTo : "/" } ) ;
195+
196+ await expect ( page . getByTestId ( "tab-unread-dot" ) . first ( ) ) . toBeVisible ( {
197+ timeout : 15_000 ,
198+ } ) ;
165199} ) ;
0 commit comments