@@ -101,38 +101,55 @@ describe("resolveDraftProjectSelection", () => {
101101describe ( "newTaskDestination" , ( ) => {
102102 const request = { draft : { requestId : "request" } } ;
103103
104- it . each ( [ undefined , false ] ) ( "opens the picker when the preference is %s " , ( useLastProject ) => {
104+ it ( "opens the picker when the preference is disabled " , ( ) => {
105105 const projects = [ makeProject ( "first" ) , makeProject ( "current" , "other-environment" ) ] ;
106106 expect (
107- newTaskDestination ( useLastProject , projects , projects [ 1 ] , "request" , {
107+ newTaskDestination ( false , projects , projects [ 1 ] , "request" , {
108108 environmentId : "environment" ,
109109 projectId : "first" ,
110110 } ) ,
111111 ) . toEqual ( request ) ;
112112 } ) ;
113113
114- it ( "uses the current thread or draft project when enabled" , ( ) => {
115- const projects = [ makeProject ( "first" ) , makeProject ( "current" , "other-environment" ) ] ;
114+ it . each ( [ undefined , true ] ) (
115+ "uses the current project when the preference is %s" ,
116+ ( useLastProject ) => {
117+ const projects = [ makeProject ( "first" ) , makeProject ( "current" , "other-environment" ) ] ;
118+ expect (
119+ newTaskDestination ( useLastProject , projects , projects [ 1 ] , "request" , {
120+ environmentId : "environment" ,
121+ projectId : "first" ,
122+ } ) ,
123+ ) . toEqual ( {
124+ draft : { requestId : "request" , environmentId : "other-environment" , projectId : "current" } ,
125+ } ) ;
126+ } ,
127+ ) ;
128+
129+ it . each ( [ undefined , true ] ) (
130+ "remembers the last project from Home when the preference is %s" ,
131+ ( useLastProject ) => {
132+ const projects = [ makeProject ( "same-id" ) , makeProject ( "same-id" , "other-environment" ) ] ;
133+ expect (
134+ newTaskDestination ( useLastProject , projects , undefined , "request" , {
135+ environmentId : "other-environment" ,
136+ projectId : "same-id" ,
137+ } ) ,
138+ ) . toEqual ( {
139+ draft : { requestId : "request" , environmentId : "other-environment" , projectId : "same-id" } ,
140+ } ) ;
141+ } ,
142+ ) ;
143+
144+ it ( "opens the picker by default when no last project exists" , ( ) => {
116145 expect (
117- newTaskDestination ( true , projects , projects [ 1 ] , "request" , {
118- environmentId : "environment" ,
119- projectId : "first" ,
120- } ) ,
121- ) . toEqual ( {
122- draft : { requestId : "request" , environmentId : "other-environment" , projectId : "current" } ,
123- } ) ;
124- } ) ;
125-
126- it ( "remembers the last project from Home without relying on project order" , ( ) => {
127- const projects = [ makeProject ( "same-id" ) , makeProject ( "same-id" , "other-environment" ) ] ;
128- expect (
129- newTaskDestination ( true , projects , undefined , "request" , {
130- environmentId : "other-environment" ,
131- projectId : "same-id" ,
132- } ) ,
133- ) . toEqual ( {
134- draft : { requestId : "request" , environmentId : "other-environment" , projectId : "same-id" } ,
135- } ) ;
146+ newTaskDestination (
147+ undefined ,
148+ [ makeProject ( "first" ) , makeProject ( "second" ) ] ,
149+ undefined ,
150+ "request" ,
151+ ) ,
152+ ) . toEqual ( request ) ;
136153 } ) ;
137154
138155 it ( "uses the remembered project when the current project is stale" , ( ) => {
0 commit comments