@@ -75,26 +75,61 @@ async function readSerializedData(): Promise<SerializedData | undefined> {
7575 * Opens the sample file, using the file picker when needed.
7676 */
7777async function openSampleFile ( ) : Promise < TextEditor > {
78- // Try the fast path first : the tab is already open.
78+ // Fast path: the tab is already open.
7979 try {
8080 return ( await new EditorView ( ) . openEditor ( SAMPLE_FILE_BASENAME ) ) as TextEditor ;
8181 } catch {
82- // Tab not open yet — ask VS Code to open the file and poll until the
83- // tab appears. On CI (xvfb) the workspace may still be initialising,
84- // so we re-issue openResources on every retry to be safe.
85- await waitForCondition (
82+ // Tab not open yet. Try the code CLI first; if that doesn't work
83+ // (common on Linux CI where the CLI can't reach the chromedriver-
84+ // managed VS Code instance), fall back to Quick Open via the
85+ // command palette.
86+ try {
87+ await VSBrowser . instance . openResources ( SAMPLE_FILE ) ;
88+ } catch {
89+ /* ignore – we'll fall through to Quick Open */
90+ }
91+
92+ let found = await waitForCondition (
8693 async ( ) => {
8794 try {
88- await VSBrowser . instance . openResources ( SAMPLE_FILE ) ;
8995 await new EditorView ( ) . openEditor ( SAMPLE_FILE_BASENAME ) ;
9096 return true ;
9197 } catch {
9298 return false ;
9399 }
94100 } ,
95- 30_000 ,
96- 1_000 ,
101+ 10_000 ,
102+ 500 ,
97103 ) ;
104+
105+ if ( ! found ) {
106+ // Quick Open fallback: open the command palette, clear the ">"
107+ // prefix so it becomes a file search, type the filename, and
108+ // confirm.
109+ await waitForCondition (
110+ async ( ) => {
111+ try {
112+ const prompt = await new Workbench ( ) . openCommandPrompt ( ) ;
113+ await prompt . setText ( SAMPLE_FILE_BASENAME ) ;
114+ await VSBrowser . instance . driver . sleep ( 1_000 ) ;
115+ await prompt . confirm ( ) ;
116+ await VSBrowser . instance . driver . sleep ( 500 ) ;
117+ await new EditorView ( ) . openEditor ( SAMPLE_FILE_BASENAME ) ;
118+ return true ;
119+ } catch {
120+ try {
121+ await VSBrowser . instance . driver . actions ( { bridge : true } ) . sendKeys ( Key . ESCAPE ) . perform ( ) ;
122+ } catch {
123+ /* ignore */
124+ }
125+ return false ;
126+ }
127+ } ,
128+ 20_000 ,
129+ 2_000 ,
130+ ) ;
131+ }
132+
98133 return ( await new EditorView ( ) . openEditor ( SAMPLE_FILE_BASENAME ) ) as TextEditor ;
99134 }
100135}
0 commit comments