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 5
5
} from "@cursorless/vscode-common" ;
6
6
import assert from "assert" ;
7
7
import { window } from "vscode" ;
8
- import { endToEndTestSetup , sleepWithBackoff } from "../endToEndTestSetup" ;
8
+ import { endToEndTestSetup } from "../endToEndTestSetup" ;
9
9
10
10
// Check that setSelection is able to focus the correct cell
11
11
suite ( "Cross-cell set selection" , async function ( ) {
@@ -19,10 +19,6 @@ async function runTest() {
19
19
20
20
await openNewNotebookEditor ( [ '"hello"' , '"world"' ] ) ;
21
21
22
- // FIXME: There seems to be some timing issue when you create a notebook
23
- // editor
24
- await sleepWithBackoff ( 1000 ) ;
25
-
26
22
await hatTokenMap . allocateHats ( ) ;
27
23
28
24
await runCursorlessCommand ( {
Original file line number Diff line number Diff line change @@ -28,10 +28,6 @@ async function runTest(
28
28
const { hatTokenMap } = ( await getCursorlessApi ( ) ) . testHelpers ! ;
29
29
const notebook = await openNewNotebookEditor ( [ "hello" ] ) ;
30
30
31
- // FIXME: There seems to be some timing issue when you create a notebook
32
- // editor
33
- await sleepWithBackoff ( 500 ) ;
34
-
35
31
await hatTokenMap . allocateHats ( ) ;
36
32
37
33
assert . equal ( notebook . cellCount , 1 ) ;
Original file line number Diff line number Diff line change 1
1
import {
2
2
getCursorlessApi ,
3
3
openNewNotebookEditor ,
4
+ runCursorlessCommand ,
4
5
} from "@cursorless/vscode-common" ;
5
6
import assert from "assert" ;
6
7
import { window } from "vscode" ;
7
- import { endToEndTestSetup , sleepWithBackoff } from "../endToEndTestSetup" ;
8
- import { runCursorlessCommand } from "@cursorless/vscode-common" ;
8
+ import { endToEndTestSetup } from "../endToEndTestSetup" ;
9
9
10
10
// Check that setSelection is able to focus the correct cell
11
11
suite ( "Within cell set selection" , async function ( ) {
@@ -19,10 +19,6 @@ async function runTest() {
19
19
20
20
await openNewNotebookEditor ( [ '"hello world"' ] ) ;
21
21
22
- // FIXME: There seems to be some timing issue when you create a notebook
23
- // editor
24
- await sleepWithBackoff ( 1000 ) ;
25
-
26
22
await hatTokenMap . allocateHats ( ) ;
27
23
28
24
await runCursorlessCommand ( {
@@ -40,7 +36,7 @@ async function runTest() {
40
36
] ,
41
37
} ) ;
42
38
43
- const editor = window . activeTextEditor ; // eslint-disable-line no-restricted-properties
39
+ const editor = window . activeTextEditor ;
44
40
45
41
if ( editor == null ) {
46
42
assert ( false , "No editor was focused" ) ;
Original file line number Diff line number Diff line change 39
39
"@types/glob" : " ^8.1.0" ,
40
40
"@types/mocha" : " ^10.0.9" ,
41
41
"@types/tail" : " 2.2.3" ,
42
- "@vscode/test-electron" : " ^2.4.1 " ,
42
+ "@vscode/test-electron" : " ^2.5.2 " ,
43
43
"cross-spawn" : " 7.0.5" ,
44
44
"mocha" : " ^10.7.3"
45
45
},
Original file line number Diff line number Diff line change @@ -96,5 +96,27 @@ export async function openNewNotebookEditor(
96
96
97
97
await ( await getParseTreeApi ( ) ) . loadLanguage ( language ) ;
98
98
99
+ // FIXME: There seems to be some timing issue when you create a notebook
100
+ // editor
101
+ await waitForEditorToOpen ( ) ;
102
+
99
103
return document ;
100
104
}
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