@@ -3,6 +3,7 @@ import { EnvironmentId, type ServerConfig } from "@t3tools/contracts";
33import * as Option from "effect/Option" ;
44import { AsyncResult , Atom , AtomRegistry } from "effect/reactivity" ;
55
6+ import type { ConnectionCatalogEntry } from "../connection/catalog.ts" ;
67import { AVAILABLE_CONNECTION_STATE , PrimaryConnectionTarget } from "../connection/model.ts" ;
78import {
89 createEnvironmentPresentationAtoms ,
@@ -88,3 +89,49 @@ describe("environment summary subscriptions", () => {
8889 }
8990 } ) ;
9091} ) ;
92+
93+ describe ( "presentations with providers" , ( ) => {
94+ it ( "leaves out disabled connections until they are re-enabled" , ( ) => {
95+ const h = harness ( ) ;
96+ const atom = h . full . presentationsWithProvidersAtom ;
97+ const withSecond = ( enabled : boolean ) : EnvironmentCatalogState => ( {
98+ isReady : true ,
99+ entries : new Map ( [
100+ [ FIRST , entry ( FIRST ) ] ,
101+ [ SECOND , { ...entry ( SECOND ) , enabled } ] ,
102+ ] ) ,
103+ } ) ;
104+ const stop = h . registry . subscribe ( atom , ( ) => { } ) ;
105+ try {
106+ h . registry . set ( h . configs ( SECOND ) , config ( false , "/second" ) ) ;
107+ h . registry . set ( h . catalog , withSecond ( false ) ) ;
108+ expect ( [ ...h . registry . get ( atom ) . keys ( ) ] ) . toEqual ( [ FIRST ] ) ;
109+ expect ( h . registry . get ( h . full . presentationsAtom ) . has ( SECOND ) ) . toBe ( true ) ;
110+ h . registry . set ( h . catalog , withSecond ( true ) ) ;
111+ expect ( [ ...h . registry . get ( atom ) . keys ( ) ] ) . toEqual ( [ FIRST , SECOND ] ) ;
112+ expect ( h . registry . get ( atom ) . get ( SECOND ) ?. serverConfig ?. cwd ) . toBe ( "/second" ) ;
113+ } finally {
114+ stop ( ) ;
115+ h . registry . dispose ( ) ;
116+ }
117+ } ) ;
118+
119+ it ( "leaves out unsupported environments" , ( ) => {
120+ const h = harness ( ) ;
121+ const atom = h . full . presentationsWithProvidersAtom ;
122+ const stop = h . registry . subscribe ( atom , ( ) => { } ) ;
123+ try {
124+ h . registry . set ( h . catalog , {
125+ isReady : true ,
126+ entries : new Map < EnvironmentId , ConnectionCatalogEntry > ( [
127+ [ FIRST , entry ( FIRST ) ] ,
128+ [ SECOND , { ...entry ( SECOND ) , unsupportedReason : "Server is too old." } ] ,
129+ ] ) ,
130+ } ) ;
131+ expect ( [ ...h . registry . get ( atom ) . keys ( ) ] ) . toEqual ( [ FIRST ] ) ;
132+ } finally {
133+ stop ( ) ;
134+ h . registry . dispose ( ) ;
135+ }
136+ } ) ;
137+ } ) ;
0 commit comments