@@ -30,62 +30,28 @@ describe("resolveAddProjectEnvironment", () => {
3030} ) ;
3131
3232describe ( "isMissingCloneParentBrowseFailure" , ( ) => {
33- const missing = new FilesystemBrowseError ( {
34- partialPath : "/ghq/example.test/acme/" ,
35- failure : "read_directory_failed" ,
36- pathMissing : true ,
37- } ) ;
38-
39- it ( "treats an unreadable clone parent as a folder the clone will create" , ( ) => {
40- expect ( isMissingCloneParentBrowseFailure ( { cloning : true , failure : missing } ) ) . toBe ( true ) ;
33+ it ( "treats only a missing folder as one the clone will create" , ( ) => {
34+ const missing = new FilesystemBrowseError ( {
35+ partialPath : "/ghq/example.test/acme/" ,
36+ failure : "read_directory_failed" ,
37+ pathMissing : true ,
38+ } ) ;
4139 // The RPC client hands over the decoded wire error, not the server's instance.
4240 const decoded = decodeBrowseError ( encodeBrowseError ( missing ) ) ;
4341 expect ( isMissingCloneParentBrowseFailure ( { cloning : true , failure : decoded } ) ) . toBe ( true ) ;
44- } ) ;
45-
46- it ( "keeps reporting the folder outside a clone and other browse failures" , ( ) => {
4742 expect ( isMissingCloneParentBrowseFailure ( { cloning : false , failure : missing } ) ) . toBe ( false ) ;
48- // A file in the way (ENOTDIR) or an I/O error is a real problem cloning would not fix.
49- const unreadable = new FilesystemBrowseError ( {
43+ const fileInTheWay = new FilesystemBrowseError ( {
5044 partialPath : "/repos/file.txt/" ,
5145 failure : "read_directory_failed" ,
5246 } ) ;
53- expect ( isMissingCloneParentBrowseFailure ( { cloning : true , failure : unreadable } ) ) . toBe ( false ) ;
54- expect (
55- isMissingCloneParentBrowseFailure ( {
56- cloning : true ,
57- failure : decodeBrowseError ( encodeBrowseError ( unreadable ) ) ,
58- } ) ,
59- ) . toBe ( false ) ;
60- expect (
61- isMissingCloneParentBrowseFailure ( {
62- cloning : true ,
63- failure : new FilesystemBrowseError ( {
64- partialPath : "C:\\repo" ,
65- failure : "windows_path_unsupported" ,
66- } ) ,
67- } ) ,
68- ) . toBe ( false ) ;
69- expect (
70- isMissingCloneParentBrowseFailure ( { cloning : true , failure : new Error ( "offline" ) } ) ,
71- ) . toBe ( false ) ;
47+ expect ( isMissingCloneParentBrowseFailure ( { cloning : true , failure : fileInTheWay } ) ) . toBe ( false ) ;
7248 } ) ;
7349} ) ;
7450
7551describe ( "createDestinationPathOwner" , ( ) => {
76- function owner ( ) {
77- const committed : string [ ] = [ ] ;
78- return { committed, paths : createDestinationPathOwner ( ( path ) => committed . push ( path ) ) } ;
79- }
80-
81- it ( "fills an untouched destination with a suggestion" , ( ) => {
82- const { committed, paths } = owner ( ) ;
83- paths . suggest ( "/ghq/github.com/acme/repo" ) ;
84- expect ( committed ) . toEqual ( [ "/ghq/github.com/acme/repo" ] ) ;
85- } ) ;
86-
8752 it ( "keeps a folder picked before a late suggestion" , async ( ) => {
88- const { committed, paths } = owner ( ) ;
53+ const committed : string [ ] = [ ] ;
54+ const paths = createDestinationPathOwner ( ( path ) => committed . push ( path ) ) ;
8955 const preload = Promise . withResolvers < void > ( ) ;
9056 const navigation = paths . navigate ( "/work/repo" , ( ) => preload . promise ) ;
9157
@@ -96,34 +62,19 @@ describe("createDestinationPathOwner", () => {
9662 expect ( committed ) . toEqual ( [ "/work/repo" ] ) ;
9763 } ) ;
9864
99- it ( "keeps a destination typed back to the flat default" , ( ) => {
100- const { committed, paths } = owner ( ) ;
101- paths . edit ( "~/repo" ) ;
102- paths . suggest ( "/ghq/github.com/acme/repo" ) ;
103- expect ( committed ) . toEqual ( [ "~/repo" ] ) ;
104- } ) ;
105-
106- it ( "marks typed and picked destinations as explicit so they skip a pending suggestion" , async ( ) => {
65+ it ( "lets suggestions fill the field until the user types, and again after a reset" , ( ) => {
10766 const commits : Array < [ string , boolean ] > = [ ] ;
10867 const paths = createDestinationPathOwner ( ( path , explicit ) => commits . push ( [ path , explicit ] ) ) ;
10968 paths . suggest ( "/ghq/github.com/acme/repo" ) ;
11069 paths . edit ( "~/typed" ) ;
111- await paths . navigate ( "/work/repo" , async ( ) => { } ) ;
11270 paths . suggest ( "/ghq/github.com/acme/late" ) ;
11371 paths . reset ( "~/repo" ) ;
72+ paths . suggest ( "/ghq/github.com/acme/next" ) ;
11473 expect ( commits ) . toEqual ( [
11574 [ "/ghq/github.com/acme/repo" , false ] ,
11675 [ "~/typed" , true ] ,
117- [ "/work/repo" , true ] ,
11876 [ "~/repo" , false ] ,
77+ [ "/ghq/github.com/acme/next" , false ] ,
11978 ] ) ;
12079 } ) ;
121-
122- it ( "lets a new environment's default take suggestions again" , ( ) => {
123- const { committed, paths } = owner ( ) ;
124- paths . edit ( "/work/repo" ) ;
125- paths . reset ( "~/repo" ) ;
126- paths . suggest ( "/ghq/github.com/acme/repo" ) ;
127- expect ( committed ) . toEqual ( [ "/work/repo" , "~/repo" , "/ghq/github.com/acme/repo" ] ) ;
128- } ) ;
12980} ) ;
0 commit comments