4
4
5
5
import * as Persistence from '../../models/persistence/persistence.js' ;
6
6
import * as Workspace from '../../models/workspace/workspace.js' ;
7
- import { createTestFilesystem } from '../../testing/AiAssistanceHelpers.js' ;
7
+ import { createTestFilesystem , setupAutomaticFileSystem } from '../../testing/AiAssistanceHelpers.js' ;
8
8
import { dispatchKeyDownEvent , renderElementIntoDOM } from '../../testing/DOMHelpers.js' ;
9
9
import { describeWithEnvironment } from '../../testing/EnvironmentHelpers.js' ;
10
10
import { createViewFunctionStub , type ViewFunctionStub } from '../../testing/ViewFunctionHelpers.js' ;
@@ -13,11 +13,18 @@ import * as UI from '../../ui/legacy/legacy.js';
13
13
import * as AiAssistance from './ai_assistance.js' ;
14
14
15
15
describeWithEnvironment ( 'SelectWorkspaceDialog' , ( ) => {
16
+ const root = '/path/to/my-automatic-file-system' ;
17
+
18
+ beforeEach ( ( ) => {
19
+ setupAutomaticFileSystem ( ) ;
20
+ } ) ;
21
+
16
22
afterEach ( ( ) => {
17
23
const workspace = Workspace . Workspace . WorkspaceImpl . instance ( ) ;
18
24
for ( const project of workspace . projects ( ) ) {
19
25
workspace . removeProject ( project ) ;
20
26
}
27
+ Persistence . AutomaticFileSystemManager . AutomaticFileSystemManager . removeInstance ( ) ;
21
28
} ) ;
22
29
23
30
function createComponent ( ) : {
@@ -87,7 +94,7 @@ describeWithEnvironment('SelectWorkspaceDialog', () => {
87
94
sinon . spy ( Persistence . IsolatedFileSystemManager . IsolatedFileSystemManager . instance ( ) , 'addFileSystem' ) ;
88
95
const { view} = createComponent ( ) ;
89
96
assert . strictEqual ( view . callCount , 1 ) ;
90
- assert . lengthOf ( view . input . projects , 2 ) ;
97
+ assert . lengthOf ( view . input . folders , 2 ) ;
91
98
assert . strictEqual ( view . input . selectedIndex , 0 ) ;
92
99
93
100
view . input . onAddFolderButtonClick ( ) ;
@@ -96,8 +103,8 @@ describeWithEnvironment('SelectWorkspaceDialog', () => {
96
103
createTestFilesystem ( 'file://test3' ) ;
97
104
const input = await view . nextInput ;
98
105
assert . strictEqual ( view . callCount , 2 ) ;
99
- assert . lengthOf ( input . projects , 3 ) ;
100
- assert . strictEqual ( input . projects [ 2 ] . name , 'test3' ) ;
106
+ assert . lengthOf ( input . folders , 3 ) ;
107
+ assert . strictEqual ( input . folders [ 2 ] . name , 'test3' ) ;
101
108
assert . strictEqual ( input . selectedIndex , 2 ) ;
102
109
} ) ;
103
110
@@ -109,15 +116,32 @@ describeWithEnvironment('SelectWorkspaceDialog', () => {
109
116
view . input . onProjectSelected ( 1 ) ;
110
117
let input = await view . nextInput ;
111
118
assert . strictEqual ( view . callCount , 2 ) ;
112
- assert . lengthOf ( input . projects , 2 ) ;
119
+ assert . lengthOf ( input . folders , 2 ) ;
113
120
assert . strictEqual ( input . selectedIndex , 1 ) ;
114
121
115
122
input . onAddFolderButtonClick ( ) ;
116
123
assert . isTrue ( addProjectSpy . calledOnce ) ;
117
124
118
125
Workspace . Workspace . WorkspaceImpl . instance ( ) . removeProject ( project ) ;
119
126
input = await view . nextInput ;
120
- assert . lengthOf ( input . projects , 1 ) ;
127
+ assert . lengthOf ( input . folders , 1 ) ;
121
128
assert . strictEqual ( input . selectedIndex , 0 ) ;
122
129
} ) ;
130
+
131
+ it ( 'allows selecting an automatic workspace' , async ( ) => {
132
+ setupAutomaticFileSystem ( { hasFileSystem : true } ) ;
133
+ const { view, onProjectSelected, hideDialogSpy} = createComponent ( ) ;
134
+
135
+ assert . strictEqual ( view . callCount , 1 ) ;
136
+ assert . lengthOf ( view . input . folders , 3 ) ;
137
+ assert . strictEqual ( view . input . selectedIndex , 0 ) ;
138
+ assert . strictEqual ( view . input . folders [ 0 ] . name , 'my-automatic-file-system' ) ;
139
+
140
+ view . input . onSelectButtonClick ( ) ;
141
+ await new Promise ( resolve => setTimeout ( resolve , 0 ) ) ;
142
+ const { project : automaticFileSystemProject } = createTestFilesystem ( `file://${ root } ` ) ;
143
+
144
+ assert . isTrue ( onProjectSelected . calledOnceWith ( automaticFileSystemProject ) ) ;
145
+ assert . isTrue ( hideDialogSpy . calledOnce ) ;
146
+ } ) ;
123
147
} ) ;
0 commit comments