File tree Expand file tree Collapse file tree 6 files changed +207
-174
lines changed
cursorless-vscode-e2e/src/suite
vscode-common/src/testUtil Expand file tree Collapse file tree 6 files changed +207
-174
lines changed Original file line number Diff line number Diff line change 55} from "@cursorless/vscode-common" ;
66import assert from "assert" ;
77import { window } from "vscode" ;
8- import { endToEndTestSetup , sleepWithBackoff } from "../endToEndTestSetup" ;
8+ import { endToEndTestSetup } from "../endToEndTestSetup" ;
99
1010// Check that setSelection is able to focus the correct cell
1111suite ( "Cross-cell set selection" , async function ( ) {
@@ -19,10 +19,6 @@ async function runTest() {
1919
2020 await openNewNotebookEditor ( [ '"hello"' , '"world"' ] ) ;
2121
22- // FIXME: There seems to be some timing issue when you create a notebook
23- // editor
24- await sleepWithBackoff ( 1000 ) ;
25-
2622 await hatTokenMap . allocateHats ( ) ;
2723
2824 await runCursorlessCommand ( {
Original file line number Diff line number Diff line change @@ -28,10 +28,6 @@ async function runTest(
2828 const { hatTokenMap } = ( await getCursorlessApi ( ) ) . testHelpers ! ;
2929 const notebook = await openNewNotebookEditor ( [ "hello" ] ) ;
3030
31- // FIXME: There seems to be some timing issue when you create a notebook
32- // editor
33- await sleepWithBackoff ( 500 ) ;
34-
3531 await hatTokenMap . allocateHats ( ) ;
3632
3733 assert . equal ( notebook . cellCount , 1 ) ;
Original file line number Diff line number Diff line change 11import {
22 getCursorlessApi ,
33 openNewNotebookEditor ,
4+ runCursorlessCommand ,
45} from "@cursorless/vscode-common" ;
56import assert from "assert" ;
67import { window } from "vscode" ;
7- import { endToEndTestSetup , sleepWithBackoff } from "../endToEndTestSetup" ;
8- import { runCursorlessCommand } from "@cursorless/vscode-common" ;
8+ import { endToEndTestSetup } from "../endToEndTestSetup" ;
99
1010// Check that setSelection is able to focus the correct cell
1111suite ( "Within cell set selection" , async function ( ) {
@@ -19,10 +19,6 @@ async function runTest() {
1919
2020 await openNewNotebookEditor ( [ '"hello world"' ] ) ;
2121
22- // FIXME: There seems to be some timing issue when you create a notebook
23- // editor
24- await sleepWithBackoff ( 1000 ) ;
25-
2622 await hatTokenMap . allocateHats ( ) ;
2723
2824 await runCursorlessCommand ( {
@@ -40,7 +36,7 @@ async function runTest() {
4036 ] ,
4137 } ) ;
4238
43- const editor = window . activeTextEditor ; // eslint-disable-line no-restricted-properties
39+ const editor = window . activeTextEditor ;
4440
4541 if ( editor == null ) {
4642 assert ( false , "No editor was focused" ) ;
Original file line number Diff line number Diff line change 3939 "@types/glob" : " ^8.1.0" ,
4040 "@types/mocha" : " ^10.0.9" ,
4141 "@types/tail" : " 2.2.3" ,
42- "@vscode/test-electron" : " ^2.4.1 " ,
42+ "@vscode/test-electron" : " ^2.5.2 " ,
4343 "cross-spawn" : " 7.0.5" ,
4444 "mocha" : " ^10.7.3"
4545 },
Original file line number Diff line number Diff line change @@ -96,5 +96,27 @@ export async function openNewNotebookEditor(
9696
9797 await ( await getParseTreeApi ( ) ) . loadLanguage ( language ) ;
9898
99+ // FIXME: There seems to be some timing issue when you create a notebook
100+ // editor
101+ await waitForEditorToOpen ( ) ;
102+
99103 return document ;
100104}
105+
106+ function waitForEditorToOpen ( ) {
107+ return new Promise < void > ( ( resolve , reject ) => {
108+ let count = 0 ;
109+ const interval = setInterval ( ( ) => {
110+ if ( vscode . window . activeTextEditor != null ) {
111+ clearInterval ( interval ) ;
112+ resolve ( ) ;
113+ } else {
114+ count ++ ;
115+ if ( count === 20 ) {
116+ clearInterval ( interval ) ;
117+ reject ( "Timed out waiting for editor to open" ) ;
118+ }
119+ }
120+ } , 100 ) ;
121+ } ) ;
122+ }
You can’t perform that action at this time.
0 commit comments