@@ -2,7 +2,9 @@ import { afterEach, beforeEach, describe, expect, it, vi } from "vite-plus/test"
22
33import { scopeProjectRef } from "@t3tools/client-runtime/environment" ;
44import {
5+ DEFAULT_BROWSER_PROFILE_ID ,
56 EnvironmentId ,
7+ INCOGNITO_BROWSER_PROFILE_ID ,
68 type PreviewSessionSnapshot ,
79 ProjectId ,
810 ThreadId ,
@@ -157,11 +159,18 @@ const threadRef = {
157159
158160let settledAt = 0 ;
159161
160- function settle ( url : string , title : string , tabId = "tab_a" , ref = threadRef ) : void {
162+ function settle (
163+ url : string ,
164+ title : string ,
165+ tabId = "tab_a" ,
166+ ref = threadRef ,
167+ profileId ?: string ,
168+ ) : void {
161169 settledAt += 1 ;
162170 const snapshot : PreviewSessionSnapshot = {
163171 threadId : ref . threadId ,
164172 tabId,
173+ ...( profileId === undefined ? { } : { profileId } ) ,
165174 navStatus : { _tag : "Success" , url, title } ,
166175 canGoBack : false ,
167176 canGoForward : false ,
@@ -179,20 +188,83 @@ function resetStores(): () => void {
179188describe ( "useBrowserHistoryStore" , ( ) => {
180189 beforeEach ( resetStores ) ;
181190
191+ it . each ( [ false , true ] ) (
192+ "excludes incognito visits from saved history with project already registered: %s" ,
193+ async ( registered ) => {
194+ if ( registered ) useBrowserHistoryStore . getState ( ) . registerThreadProject ( threadRef , "proj-a" ) ;
195+ recordVisitForThread (
196+ threadRef ,
197+ "https://private.example/unique" ,
198+ INCOGNITO_BROWSER_PROFILE_ID ,
199+ 1 ,
200+ ) ;
201+ expect ( useBrowserHistoryStore . getState ( ) . pendingVisitsByThreadKey ) . toEqual ( { } ) ;
202+ useBrowserHistoryStore . getState ( ) . registerThreadProject ( threadRef , "proj-a" ) ;
203+ for ( const [ index , profileId ] of [ undefined , DEFAULT_BROWSER_PROFILE_ID , "work" ] . entries ( ) ) {
204+ recordVisitForThread ( threadRef , `https://public.example/${ index } ` , profileId , index + 2 ) ;
205+ }
206+ expect (
207+ useBrowserHistoryStore . getState ( ) . byProjectKey [ "proj-a" ] ?. map ( ( entry ) => entry . url ) ,
208+ ) . toEqual ( [
209+ "https://public.example/2" ,
210+ "https://public.example/1" ,
211+ "https://public.example/0" ,
212+ ] ) ;
213+ const { storage, name } = useBrowserHistoryStore . persist . getOptions ( ) ;
214+ const saved = JSON . stringify ( await storage ! . getItem ( name ! ) ) ;
215+ expect ( saved ) . not . toContain ( "private.example" ) ;
216+ expect ( saved ) . toContain ( "public.example" ) ;
217+ await useBrowserHistoryStore . persist . rehydrate ( ) ;
218+ expect (
219+ useBrowserHistoryStore . getState ( ) . byProjectKey [ "proj-a" ] ?. map ( ( entry ) => entry . url ) ,
220+ ) . toEqual ( [
221+ "https://public.example/2" ,
222+ "https://public.example/1" ,
223+ "https://public.example/0" ,
224+ ] ) ;
225+ } ,
226+ ) ;
227+
228+ it . each ( [ false , true ] ) (
229+ "excludes incognito titles from regular history with page settled before visit: %s" ,
230+ async ( settledBeforeVisit ) => {
231+ useBrowserHistoryStore . getState ( ) . registerThreadProject ( threadRef , "proj-a" ) ;
232+ if ( ! settledBeforeVisit ) {
233+ recordVisitForThread ( threadRef , "http://a.test/" , undefined , 1 ) ;
234+ settle ( "http://a.test/" , "Public page" ) ;
235+ }
236+ settle (
237+ "http://a.test/" ,
238+ "Private page" ,
239+ "private-tab" ,
240+ threadRef ,
241+ INCOGNITO_BROWSER_PROFILE_ID ,
242+ ) ;
243+ if ( settledBeforeVisit ) recordVisitForThread ( threadRef , "http://a.test/" , undefined , 1 ) ;
244+ expect ( useBrowserHistoryStore . getState ( ) . byProjectKey [ "proj-a" ] ?. [ 0 ] ?. title ) . toBe (
245+ settledBeforeVisit ? undefined : "Public page" ,
246+ ) ;
247+ const { storage, name } = useBrowserHistoryStore . persist . getOptions ( ) ;
248+ expect ( JSON . stringify ( await storage ! . getItem ( name ! ) ) ) . not . toContain ( "Private page" ) ;
249+ settle ( "http://a.test/" , "Work page" , "work-tab" , threadRef , "work" ) ;
250+ expect ( JSON . stringify ( await storage ! . getItem ( name ! ) ) ) . toContain ( "Work page" ) ;
251+ } ,
252+ ) ;
253+
182254 it ( "titles only pages already in history when they settle" , ( ) => {
183255 useBrowserHistoryStore . getState ( ) . registerThreadProject ( threadRef , "proj-a" ) ;
184256 settle ( "http://a.test/" , "Should not create" ) ;
185257 expect ( useBrowserHistoryStore . getState ( ) . byProjectKey ) . toEqual ( { } ) ;
186- recordVisitForThread ( threadRef , "http://a.test/#/settings" , 1 ) ;
258+ recordVisitForThread ( threadRef , "http://a.test/#/settings" , undefined , 1 ) ;
187259 settle ( "http://a.test/#/settings" , "My App" ) ;
188260 expect ( useBrowserHistoryStore . getState ( ) . byProjectKey [ "proj-a" ] ?. [ 0 ] ?. title ) . toBe ( "My App" ) ;
189261 } ) ;
190262
191263 it ( "titles a visit recorded after its page already settled" , ( ) => {
192264 useBrowserHistoryStore . getState ( ) . registerThreadProject ( threadRef , "proj-a" ) ;
193- recordVisitForThread ( threadRef , "http://other.test/" , 1 ) ;
265+ recordVisitForThread ( threadRef , "http://other.test/" , undefined , 1 ) ;
194266 settle ( "http://a.test/" , "My App" ) ;
195- recordVisitForThread ( threadRef , "http://a.test/" , 2 ) ;
267+ recordVisitForThread ( threadRef , "http://a.test/" , undefined , 2 ) ;
196268 expect ( useBrowserHistoryStore . getState ( ) . byProjectKey [ "proj-a" ] ?. [ 0 ] ) . toMatchObject ( {
197269 url : "http://a.test/" ,
198270 title : "My App" ,
@@ -201,7 +273,7 @@ describe("useBrowserHistoryStore", () => {
201273
202274 it ( "keeps the newest title when another tab shows the same url" , ( ) => {
203275 useBrowserHistoryStore . getState ( ) . registerThreadProject ( threadRef , "proj-a" ) ;
204- recordVisitForThread ( threadRef , "http://a.test/" , 1 ) ;
276+ recordVisitForThread ( threadRef , "http://a.test/" , undefined , 1 ) ;
205277 settle ( "http://a.test/" , "Old" , "tab_a" ) ;
206278 settle ( "http://a.test/" , "Old" , "tab_b" ) ;
207279 settle ( "http://a.test/" , "New" , "tab_a" ) ;
@@ -213,7 +285,7 @@ describe("useBrowserHistoryStore", () => {
213285 const store = useBrowserHistoryStore . getState ( ) ;
214286 store . registerThreadProject ( threadRef , "proj-a" ) ;
215287 store . registerThreadProject ( otherThreadRef , "proj-a" ) ;
216- recordVisitForThread ( threadRef , "http://a.test/" , 1 ) ;
288+ recordVisitForThread ( threadRef , "http://a.test/" , undefined , 1 ) ;
217289 settle ( "http://a.test/" , "Old" , "tab_a" , threadRef ) ;
218290 settle ( "http://a.test/" , "New" , "tab_a" , otherThreadRef ) ;
219291 settle ( "http://b.test/" , "Unrelated" , "tab_b" , threadRef ) ;
@@ -229,10 +301,10 @@ describe("useBrowserHistoryStore", () => {
229301 const store = useBrowserHistoryStore . getState ( ) ;
230302 store . registerThreadProject ( threadRef , "proj-a" ) ;
231303 store . registerThreadProject ( otherThreadRef , "proj-a" ) ;
232- recordVisitForThread ( threadRef , "http://a.test/" , 1 ) ;
304+ recordVisitForThread ( threadRef , "http://a.test/" , undefined , 1 ) ;
233305 settle ( "http://a.test/" , "Old" , "tab_a" , threadRef ) ;
234306 settle ( "http://a.test/" , "New" , "tab_a" , otherThreadRef ) ;
235- recordVisitForThread ( threadRef , "http://b.test/" , 2 ) ;
307+ recordVisitForThread ( threadRef , "http://b.test/" , undefined , 2 ) ;
236308 expect (
237309 useBrowserHistoryStore
238310 . getState ( )
@@ -245,7 +317,7 @@ describe("useBrowserHistoryStore", () => {
245317 const store = useBrowserHistoryStore . getState ( ) ;
246318 store . registerThreadProject ( threadRef , "proj-a" ) ;
247319 store . registerThreadProject ( otherThreadRef , "proj-a" ) ;
248- recordVisitForThread ( threadRef , "http://a.test/" , 1 ) ;
320+ recordVisitForThread ( threadRef , "http://a.test/" , undefined , 1 ) ;
249321 settle ( "http://a.test/" , "Old" , "tab_a" , threadRef ) ;
250322 settle ( "http://a.test/" , "New" , "tab_a" , otherThreadRef ) ;
251323 // A resize or a list reconcile replaces the session without a new page load.
@@ -258,24 +330,24 @@ describe("useBrowserHistoryStore", () => {
258330 const store = useBrowserHistoryStore . getState ( ) ;
259331 store . registerThreadProject ( threadRef , "proj-a" ) ;
260332 store . registerThreadProject ( otherThreadRef , "proj-a" ) ;
261- recordVisitForThread ( threadRef , "http://a.test/" , 1 ) ;
333+ recordVisitForThread ( threadRef , "http://a.test/" , undefined , 1 ) ;
262334 settle ( "http://a.test/" , "Old" , "tab_a" , threadRef ) ;
263335 settle ( "http://a.test/" , "New" , "tab_a" , otherThreadRef ) ;
264- recordVisitForThread ( threadRef , "http://a.test/" , 2 ) ;
336+ recordVisitForThread ( threadRef , "http://a.test/" , undefined , 2 ) ;
265337 expect ( useBrowserHistoryStore . getState ( ) . byProjectKey [ "proj-a" ] ?. [ 0 ] ?. title ) . toBe ( "New" ) ;
266338 } ) ;
267339
268340 it ( "sets a title against a settled url that differs from the stored one only by a trailing slash" , ( ) => {
269341 useBrowserHistoryStore . getState ( ) . registerThreadProject ( threadRef , "proj-a" ) ;
270- recordVisitForThread ( threadRef , "http://a.test/community" , 1 ) ;
342+ recordVisitForThread ( threadRef , "http://a.test/community" , undefined , 1 ) ;
271343 settle ( "http://a.test/community/" , "Community" ) ;
272344 expect ( useBrowserHistoryStore . getState ( ) . byProjectKey [ "proj-a" ] ?. [ 0 ] ) . toMatchObject ( {
273345 url : "http://a.test/community" ,
274346 title : "Community" ,
275347 } ) ;
276348
277349 useBrowserHistoryStore . setState ( { byProjectKey : { } } ) ;
278- recordVisitForThread ( threadRef , "http://a.test/community/" , 1 ) ;
350+ recordVisitForThread ( threadRef , "http://a.test/community/" , undefined , 1 ) ;
279351 settle ( "http://a.test/community" , "Community" ) ;
280352 expect ( useBrowserHistoryStore . getState ( ) . byProjectKey [ "proj-a" ] ?. [ 0 ] ) . toMatchObject ( {
281353 url : "http://a.test/community/" ,
@@ -285,7 +357,7 @@ describe("useBrowserHistoryStore", () => {
285357
286358 it ( "matches a requested localhost URL to the resolved environment host" , ( ) => {
287359 useBrowserHistoryStore . getState ( ) . registerThreadProject ( threadRef , "proj-a" ) ;
288- recordVisitForThread ( threadRef , "http://localhost:5173/app" , 1 ) ;
360+ recordVisitForThread ( threadRef , "http://localhost:5173/app" , undefined , 1 ) ;
289361 readPreparedConnection . mockReturnValue ( { httpBaseUrl : "http://192.168.64.2:3773" } ) ;
290362 settle ( "http://192.168.64.2:5173/app" , "Local App" ) ;
291363 expect ( useBrowserHistoryStore . getState ( ) . byProjectKey [ "proj-a" ] ?. [ 0 ] ?. title ) . toBe ( "Local App" ) ;
@@ -294,16 +366,16 @@ describe("useBrowserHistoryStore", () => {
294366 it ( "deduplicates loopback aliases and the resolved environment host" , ( ) => {
295367 readPreparedConnection . mockReturnValue ( { httpBaseUrl : "http://192.168.64.2:3773" } ) ;
296368 useBrowserHistoryStore . getState ( ) . registerThreadProject ( threadRef , "proj-a" ) ;
297- recordVisitForThread ( threadRef , "http://localhost:5173/app" , 1 ) ;
298- recordVisitForThread ( threadRef , "http://127.0.0.1:5173/app" , 2 ) ;
299- recordVisitForThread ( threadRef , "http://192.168.64.2:5173/app" , 3 ) ;
369+ recordVisitForThread ( threadRef , "http://localhost:5173/app" , undefined , 1 ) ;
370+ recordVisitForThread ( threadRef , "http://127.0.0.1:5173/app" , undefined , 2 ) ;
371+ recordVisitForThread ( threadRef , "http://192.168.64.2:5173/app" , undefined , 3 ) ;
300372 expect ( useBrowserHistoryStore . getState ( ) . byProjectKey [ "proj-a" ] ) . toEqual ( [
301373 { url : "http://localhost:5173/app" , lastVisitedAt : 3 } ,
302374 ] ) ;
303375
304376 useBrowserHistoryStore . setState ( { byProjectKey : { } } ) ;
305- recordVisitForThread ( threadRef , "http://192.168.64.2:5173/app" , 4 ) ;
306- recordVisitForThread ( threadRef , "http://localhost:5173/app" , 5 ) ;
377+ recordVisitForThread ( threadRef , "http://192.168.64.2:5173/app" , undefined , 4 ) ;
378+ recordVisitForThread ( threadRef , "http://localhost:5173/app" , undefined , 5 ) ;
307379 expect ( useBrowserHistoryStore . getState ( ) . byProjectKey [ "proj-a" ] ) . toEqual ( [
308380 { url : "http://localhost:5173/app" , lastVisitedAt : 5 } ,
309381 ] ) ;
@@ -325,7 +397,7 @@ describe("thread project resolution", () => {
325397 entities . projects = [ repoProject ] ;
326398 entities . shellProjectId = "project-1" ;
327399
328- recordVisitForThread ( threadRef , "http://localhost:5173/" , 1 ) ;
400+ recordVisitForThread ( threadRef , "http://localhost:5173/" , undefined , 1 ) ;
329401 settle ( "http://localhost:5173/" , "Dev App" ) ;
330402
331403 expect ( useBrowserHistoryStore . getState ( ) . byProjectKey ) . toEqual ( {
@@ -343,7 +415,7 @@ describe("thread project resolution", () => {
343415 threadId : threadRef . threadId ,
344416 } ) ;
345417
346- recordVisitForThread ( threadRef , "http://localhost:5173/" , 1 ) ;
418+ recordVisitForThread ( threadRef , "http://localhost:5173/" , undefined , 1 ) ;
347419
348420 expect ( useBrowserHistoryStore . getState ( ) . byProjectKey ) . toEqual ( {
349421 "env-1:/repo" : [ { url : "http://localhost:5173/" , lastVisitedAt : 1 } ] ,
@@ -362,7 +434,7 @@ describe("thread project resolution", () => {
362434 } ;
363435 } ) ;
364436
365- recordVisitForThread ( threadRef , "http://localhost:5173/" , 1 ) ;
437+ recordVisitForThread ( threadRef , "http://localhost:5173/" , undefined , 1 ) ;
366438 expect ( useBrowserHistoryStore . getState ( ) . projectKeyByThreadKey ) . toEqual ( { } ) ;
367439
368440 settingsHydration . finish ( ) ;
@@ -374,10 +446,10 @@ describe("thread project resolution", () => {
374446 } ) ;
375447
376448 it ( "lands visits queued before the thread's project loaded with the next visit" , ( ) => {
377- recordVisitForThread ( threadRef , "http://a.test/" , 1 ) ;
449+ recordVisitForThread ( threadRef , "http://a.test/" , undefined , 1 ) ;
378450 entities . projects = [ repoProject ] ;
379451 entities . shellProjectId = "project-1" ;
380- recordVisitForThread ( threadRef , "http://b.test/" , 2 ) ;
452+ recordVisitForThread ( threadRef , "http://b.test/" , undefined , 2 ) ;
381453
382454 expect (
383455 useBrowserHistoryStore . getState ( ) . byProjectKey [ "env-1:/repo" ] ?. map ( ( entry ) => entry . url ) ,
@@ -389,8 +461,8 @@ describe("pendingVisitsByThreadKey", () => {
389461 beforeEach ( resetStores ) ;
390462
391463 it ( "queues a visit recorded before registration and drains it in order on registration" , ( ) => {
392- recordVisitForThread ( threadRef , "http://a.test/" , 1 ) ;
393- recordVisitForThread ( threadRef , "http://b.test/" , 2 ) ;
464+ recordVisitForThread ( threadRef , "http://a.test/" , undefined , 1 ) ;
465+ recordVisitForThread ( threadRef , "http://b.test/" , undefined , 2 ) ;
394466 expect ( useBrowserHistoryStore . getState ( ) . byProjectKey ) . toEqual ( { } ) ;
395467 useBrowserHistoryStore . getState ( ) . registerThreadProject ( threadRef , "proj-a" ) ;
396468 expect ( useBrowserHistoryStore . getState ( ) . byProjectKey [ "proj-a" ] ?. map ( ( e ) => e . url ) ) . toEqual ( [
@@ -408,8 +480,8 @@ describe("pendingVisitsByThreadKey", () => {
408480 threadId : ThreadId . make ( "thread-2" ) ,
409481 } ;
410482 useBrowserHistoryStore . getState ( ) . registerThreadProject ( otherThreadRef , "proj-a" ) ;
411- recordVisitForThread ( otherThreadRef , "http://newer.test/" , 2000 ) ;
412- recordVisitForThread ( threadRef , "http://older.test/" , 1000 ) ;
483+ recordVisitForThread ( otherThreadRef , "http://newer.test/" , undefined , 2000 ) ;
484+ recordVisitForThread ( threadRef , "http://older.test/" , undefined , 1000 ) ;
413485 useBrowserHistoryStore . getState ( ) . registerThreadProject ( threadRef , "proj-a" ) ;
414486
415487 const entries = useBrowserHistoryStore . getState ( ) . byProjectKey [ "proj-a" ] ;
@@ -422,7 +494,7 @@ describe("titles before registration", () => {
422494 beforeEach ( resetStores ) ;
423495
424496 it ( "applies a settled page's title once the matching visit drains" , ( ) => {
425- recordVisitForThread ( threadRef , "http://a.test/" , 1 ) ;
497+ recordVisitForThread ( threadRef , "http://a.test/" , undefined , 1 ) ;
426498 settle ( "http://a.test/" , "My App" ) ;
427499 expect ( useBrowserHistoryStore . getState ( ) . byProjectKey ) . toEqual ( { } ) ;
428500
@@ -434,10 +506,10 @@ describe("titles before registration", () => {
434506
435507 it ( "keeps another thread's title when a queued visit to the same url drains" , ( ) => {
436508 const otherThreadRef = { ...threadRef , threadId : ThreadId . make ( "thread-2" ) } ;
437- recordVisitForThread ( threadRef , "http://a.test/" , 1 ) ;
509+ recordVisitForThread ( threadRef , "http://a.test/" , undefined , 1 ) ;
438510 settle ( "http://a.test/" , "Old" , "tab_a" , threadRef ) ;
439511 useBrowserHistoryStore . getState ( ) . registerThreadProject ( otherThreadRef , "proj-a" ) ;
440- recordVisitForThread ( otherThreadRef , "http://a.test/" , 2 ) ;
512+ recordVisitForThread ( otherThreadRef , "http://a.test/" , undefined , 2 ) ;
441513 settle ( "http://a.test/" , "New" , "tab_a" , otherThreadRef ) ;
442514
443515 useBrowserHistoryStore . getState ( ) . registerThreadProject ( threadRef , "proj-a" ) ;
0 commit comments