11import { describe , expect , it } from "vite-plus/test" ;
22
33import type { WorkspaceState } from "../../state/workspaceModel" ;
4- import {
5- shouldShowWorkspaceConnectionStatus ,
6- workspaceConnectionStatusLabel ,
7- workspaceConnectionStatusPresentation ,
8- } from "./workspace-connection-status" ;
4+ import { workspaceConnectionStatusPresentation } from "./workspace-connection-status" ;
95
106function workspaceState ( overrides : Partial < WorkspaceState > = { } ) : WorkspaceState {
117 return {
@@ -27,14 +23,16 @@ function workspaceState(overrides: Partial<WorkspaceState> = {}): WorkspaceState
2723
2824describe ( "workspace connection status" , ( ) => {
2925 it ( "stays hidden while a ready environment is connected" , ( ) => {
30- expect ( shouldShowWorkspaceConnectionStatus ( workspaceState ( ) ) ) . toBe ( false ) ;
26+ expect ( workspaceConnectionStatusPresentation ( workspaceState ( ) ) ) . toBeNull ( ) ;
3127 } ) ;
3228
3329 it ( "surfaces offline snapshots" , ( ) => {
3430 const state = workspaceState ( { networkStatus : "offline" , hasReadyEnvironment : false } ) ;
3531
36- expect ( shouldShowWorkspaceConnectionStatus ( state ) ) . toBe ( true ) ;
37- expect ( workspaceConnectionStatusLabel ( state ) ) . toBe ( "You are offline" ) ;
32+ expect ( workspaceConnectionStatusPresentation ( state ) ) . toEqual ( {
33+ label : "You are offline" ,
34+ showsProgress : false ,
35+ } ) ;
3836 } ) ;
3937
4038 it ( "names the environment while reconnecting" , ( ) => {
@@ -54,8 +52,10 @@ describe("workspace connection status", () => {
5452 ] ,
5553 } ) ;
5654
57- expect ( shouldShowWorkspaceConnectionStatus ( state ) ) . toBe ( true ) ;
58- expect ( workspaceConnectionStatusLabel ( state ) ) . toBe ( "Reconnecting to Julius’s Mac mini" ) ;
55+ expect ( workspaceConnectionStatusPresentation ( state ) ) . toEqual ( {
56+ label : "Reconnecting to Julius’s Mac mini" ,
57+ showsProgress : true ,
58+ } ) ;
5959 } ) ;
6060
6161 it ( "surfaces connection errors before the generic disconnected fallback" , ( ) => {
@@ -65,15 +65,19 @@ describe("workspace connection status", () => {
6565 hasReadyEnvironment : false ,
6666 } ) ;
6767
68- expect ( shouldShowWorkspaceConnectionStatus ( state ) ) . toBe ( true ) ;
69- expect ( workspaceConnectionStatusLabel ( state ) ) . toBe ( "Could not reach Julius’s Mac mini" ) ;
68+ expect ( workspaceConnectionStatusPresentation ( state ) ) . toEqual ( {
69+ label : "Could not reach Julius’s Mac mini" ,
70+ showsProgress : false ,
71+ } ) ;
7072 } ) ;
7173
7274 it ( "shows shell catch-up while cached threads remain visible" , ( ) => {
7375 const state = workspaceState ( { hasPendingShellSnapshot : true } ) ;
7476
75- expect ( shouldShowWorkspaceConnectionStatus ( state ) ) . toBe ( true ) ;
76- expect ( workspaceConnectionStatusLabel ( state ) ) . toBe ( "Syncing threads..." ) ;
77+ expect ( workspaceConnectionStatusPresentation ( state ) ) . toEqual ( {
78+ label : "Syncing threads..." ,
79+ showsProgress : true ,
80+ } ) ;
7781 } ) ;
7882
7983 it ( "distinguishes initial shell loading from cached catch-up" , ( ) => {
@@ -82,39 +86,9 @@ describe("workspace connection status", () => {
8286 hasPendingShellSnapshot : true ,
8387 } ) ;
8488
85- expect ( shouldShowWorkspaceConnectionStatus ( state ) ) . toBe ( true ) ;
86- expect ( workspaceConnectionStatusLabel ( state ) ) . toBe ( "Loading threads..." ) ;
87- } ) ;
88-
89- it ( "presents nothing while connected" , ( ) => {
90- expect ( workspaceConnectionStatusPresentation ( workspaceState ( ) ) ) . toBeNull ( ) ;
91- } ) ;
92-
93- it ( "presents progress while reconnecting but not while offline" , ( ) => {
94- const reconnecting = workspaceState ( {
95- hasConnectingEnvironment : true ,
96- hasReadyEnvironment : false ,
97- connectingEnvironments : [
98- {
99- environmentId : "environment-1" as never ,
100- environmentLabel : "Julius’s Mac mini" ,
101- displayUrl : "" ,
102- isRelayManaged : false ,
103- connectionState : "reconnecting" ,
104- connectionError : null ,
105- connectionErrorTraceId : null ,
106- } ,
107- ] ,
108- } ) ;
109- expect ( workspaceConnectionStatusPresentation ( reconnecting ) ) . toEqual ( {
110- label : "Reconnecting to Julius’s Mac mini" ,
89+ expect ( workspaceConnectionStatusPresentation ( state ) ) . toEqual ( {
90+ label : "Loading threads..." ,
11191 showsProgress : true ,
11292 } ) ;
113-
114- const offline = workspaceState ( { networkStatus : "offline" , hasReadyEnvironment : false } ) ;
115- expect ( workspaceConnectionStatusPresentation ( offline ) ) . toEqual ( {
116- label : "You are offline" ,
117- showsProgress : false ,
118- } ) ;
11993 } ) ;
12094} ) ;
0 commit comments