@@ -2,7 +2,7 @@ import { EnvironmentId } from "@t3tools/contracts";
22import type { RelayClientEnvironmentRecord } from "@t3tools/contracts/relay" ;
33import { describe , expect , it } from "vite-plus/test" ;
44import type { ConnectedEnvironmentSummary } from "../../state/remote-runtime-types" ;
5- import { splitEnvironmentSections } from "./environmentSections" ;
5+ import { relayManagedEnvironmentIds , splitEnvironmentSections } from "./environmentSections" ;
66
77function connectedEnvironment (
88 input : Omit < Partial < ConnectedEnvironmentSummary > , "environmentId" > & {
@@ -34,6 +34,17 @@ function cloudEnvironment(environmentId: string): RelayClientEnvironmentRecord {
3434 } ;
3535}
3636
37+ describe ( "relayManagedEnvironmentIds" , ( ) => {
38+ it ( "leaves out a backend that was saved directly" , ( ) => {
39+ const ids = relayManagedEnvironmentIds ( [
40+ connectedEnvironment ( { environmentId : "environment-local" , isRelayManaged : false } ) ,
41+ connectedEnvironment ( { environmentId : "environment-cloud" , isRelayManaged : true } ) ,
42+ ] ) ;
43+
44+ expect ( [ ...ids ] ) . toEqual ( [ EnvironmentId . make ( "environment-cloud" ) ] ) ;
45+ } ) ;
46+ } ) ;
47+
3748describe ( "mobile environment settings sections" , ( ) => {
3849 it ( "keeps saved relay-managed connections under T3 Connect" , ( ) => {
3950 const local = connectedEnvironment ( {
@@ -111,6 +122,24 @@ describe("mobile environment settings sections", () => {
111122 expect ( sections . availableCloudEnvironments ) . toEqual ( [ ] ) ;
112123 } ) ;
113124
125+ it ( "still offers a cloud environment saved directly as a local backend" , ( ) => {
126+ const local = connectedEnvironment ( {
127+ environmentId : "environment-cloud" ,
128+ isRelayManaged : false ,
129+ } ) ;
130+
131+ const sections = splitEnvironmentSections ( {
132+ connectedEnvironments : [ local ] ,
133+ cloudEnvironments : [ cloudEnvironment ( "environment-cloud" ) ] ,
134+ } ) ;
135+
136+ expect ( sections . localEnvironments ) . toEqual ( [ local ] ) ;
137+ expect ( sections . connectedCloudEnvironments ) . toEqual ( [ ] ) ;
138+ expect (
139+ sections . availableCloudEnvironments . map ( ( environment ) => environment . environmentId ) ,
140+ ) . toEqual ( [ EnvironmentId . make ( "environment-cloud" ) ] ) ;
141+ } ) ;
142+
114143 it ( "keeps failed relay environments in the local connection row" , ( ) => {
115144 const cloud = connectedEnvironment ( {
116145 environmentId : "environment-cloud" ,
0 commit comments