Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import {
} from "@cursorless/vscode-common";
import assert from "assert";
import { window } from "vscode";
import { endToEndTestSetup, sleepWithBackoff } from "../endToEndTestSetup";
import { endToEndTestSetup } from "../endToEndTestSetup";

// Check that setSelection is able to focus the correct cell
suite("Cross-cell set selection", async function () {
Expand All @@ -19,10 +19,6 @@ async function runTest() {

await openNewNotebookEditor(['"hello"', '"world"']);

// FIXME: There seems to be some timing issue when you create a notebook
// editor
await sleepWithBackoff(1000);

await hatTokenMap.allocateHats();

await runCursorlessCommand({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,6 @@ async function runTest(
const { hatTokenMap } = (await getCursorlessApi()).testHelpers!;
const notebook = await openNewNotebookEditor(["hello"]);

// FIXME: There seems to be some timing issue when you create a notebook
// editor
await sleepWithBackoff(500);

await hatTokenMap.allocateHats();

assert.equal(notebook.cellCount, 1);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import {
getCursorlessApi,
openNewNotebookEditor,
runCursorlessCommand,
} from "@cursorless/vscode-common";
import assert from "assert";
import { window } from "vscode";
import { endToEndTestSetup, sleepWithBackoff } from "../endToEndTestSetup";
import { runCursorlessCommand } from "@cursorless/vscode-common";
import { endToEndTestSetup } from "../endToEndTestSetup";

// Check that setSelection is able to focus the correct cell
suite("Within cell set selection", async function () {
Expand All @@ -19,10 +19,6 @@ async function runTest() {

await openNewNotebookEditor(['"hello world"']);

// FIXME: There seems to be some timing issue when you create a notebook
// editor
await sleepWithBackoff(1000);

await hatTokenMap.allocateHats();

await runCursorlessCommand({
Expand All @@ -40,7 +36,7 @@ async function runTest() {
],
});

const editor = window.activeTextEditor; // eslint-disable-line no-restricted-properties
const editor = window.activeTextEditor;

if (editor == null) {
assert(false, "No editor was focused");
Expand Down
2 changes: 1 addition & 1 deletion packages/test-harness/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
"@types/glob": "^8.1.0",
"@types/mocha": "^10.0.9",
"@types/tail": "2.2.3",
"@vscode/test-electron": "^2.4.1",
"@vscode/test-electron": "^2.5.2",
"cross-spawn": "7.0.5",
"mocha": "^10.7.3"
},
Expand Down
22 changes: 22 additions & 0 deletions packages/vscode-common/src/testUtil/openNewEditor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -96,5 +96,27 @@ export async function openNewNotebookEditor(

await (await getParseTreeApi()).loadLanguage(language);

// FIXME: There seems to be some timing issue when you create a notebook
// editor
await waitForEditorToOpen();

return document;
}

function waitForEditorToOpen() {
return new Promise<void>((resolve, reject) => {
let count = 0;
const interval = setInterval(() => {
if (vscode.window.activeTextEditor != null) {
clearInterval(interval);
resolve();
} else {
count++;
if (count === 20) {
clearInterval(interval);
reject("Timed out waiting for editor to open");
}
}
}, 100);
});
}
Loading
Loading