@@ -14,7 +14,6 @@ import { createRoot } from "react-dom/client";
1414import { afterEach , beforeEach , describe , expect , it , vi } from "vite-plus/test" ;
1515
1616const state = vi . hoisted ( ( ) => ( {
17- transitions : new Set < ( event : { data : { closing : boolean } } ) => void > ( ) ,
1817 scopes : new Set < string > ( ) ,
1918 baseDirectory : "" ,
2019 projects : [ ] as string [ ] ,
@@ -75,10 +74,6 @@ vi.mock("react-native", () => ({
7574vi . mock ( "@react-navigation/native" , ( ) => ( {
7675 useNavigation : ( ) => ( {
7776 dispatch : state . dispatch ,
78- addListener : ( _name : string , listener : ( event : { data : { closing : boolean } } ) => void ) => {
79- state . transitions . add ( listener ) ;
80- return ( ) => state . transitions . delete ( listener ) ;
81- } ,
8277 getState : ( ) =>
8378 state . navigationState ?? {
8479 index : 4 ,
@@ -93,7 +88,6 @@ vi.mock("@react-navigation/native", () => ({
9388 } ) ,
9489 CommonActions : { reset : ( input : unknown ) => input } ,
9590 StackActions : {
96- popToTop : ( ) => ( { type : "POP_TO_TOP" } ) ,
9791 push : ( name : string , params : unknown ) => ( { type : "PUSH" , payload : { name, params } } ) ,
9892 } ,
9993} ) ) ;
@@ -335,9 +329,7 @@ function mountProjectFlow(
335329 state . navigationState = current ;
336330 state . dispatch . mockImplementation ( ( action ) =>
337331 apply (
338- action . type === "PUSH" ||
339- action . type === "POP_TO_TOP" ||
340- action . type === "SELECT_WORKSPACE_DETAIL"
332+ action . type === "PUSH" || action . type === "SELECT_WORKSPACE_DETAIL"
341333 ? action
342334 : CommonActions . reset ( action ) ,
343335 ) ,
@@ -503,7 +495,6 @@ describe("add project source environment", () => {
503495
504496describe ( "local project navigation" , ( ) => {
505497 function setup ( ) {
506- state . transitions . clear ( ) ;
507498 state . navigationState = undefined ;
508499 state . scopes = new Set ( [ AuthOrchestrationOperateScope ] ) ;
509500 state . baseDirectory = "/tmp/t3-mobile-audit-fixture" ;
@@ -664,21 +655,6 @@ describe("local project navigation", () => {
664655 }
665656 } ) ;
666657
667- it ( "does not replace a destination opened while the chooser is closing" , async ( ) => {
668- const { created, projected, submit } = setup ( ) ;
669- const navigation = mountProjectFlow ( false , false , true ) ;
670- const submission = submit ( ) ;
671- created . resolve ( AsyncResult . success ( undefined ) ) ;
672- projected . resolve ( { environmentId : "environment" , id : "project" } ) ;
673- await submission ;
674- expect ( navigation . getState ( ) . routes . map ( ( route ) => route . name ) ) . toEqual ( [ "Home" ] ) ;
675- navigation . push ( "PullRequest" ) ;
676- const selected = navigation . getState ( ) ;
677- for ( const listener of state . transitions ) listener ( { data : { closing : true } } ) ;
678- expect ( navigation . getState ( ) ) . toBe ( selected ) ;
679- expect ( state . transitions . size ) . toBe ( 0 ) ;
680- } ) ;
681-
682658 it . each ( [
683659 { origin : "Thread" , withDraft : true , withChooser : true } ,
684660 { origin : "NewTaskProject" , withDraft : false , withChooser : true } ,
@@ -696,10 +672,7 @@ describe("local project navigation", () => {
696672 expect ( navigation . getState ( ) ) . toBe ( before ) ;
697673 projected . resolve ( { environmentId : "environment" , id : "project" } ) ;
698674 await submission ;
699- if ( ! withDraft ) {
700- expect ( navigation . getState ( ) . routes . map ( ( route ) => route . name ) ) . toEqual ( [ "Home" ] ) ;
701- for ( const listener of state . transitions ) listener ( { data : { closing : true } } ) ;
702- }
675+ expect ( state . dispatch ) . toHaveBeenCalledTimes ( 1 ) ;
703676 expect ( navigation . getState ( ) . routes . map ( ( route ) => route . name ) ) . toEqual ( [ "Home" , "Thread" ] ) ;
704677 expect ( navigation . getState ( ) . routes [ 1 ] ?. params ) . toEqual ( {
705678 draft : {
0 commit comments