(document: vscode.Uri, command: string)
| 270 | } |
| 271 | |
| 272 | export async function waitForCodeLenses(document: vscode.Uri, command: string) { |
| 273 | // First make sure the editor has focus |
| 274 | const selection = new vscode.Range(new vscode.Position(0, 0), new vscode.Position(0, 0)); |
| 275 | let editor = vscode.window.visibleTextEditors.find((e) => arePathsSame(e.document.uri.fsPath, document.fsPath)); |
| 276 | if (editor) { |
| 277 | await vscode.window |
| 278 | .showTextDocument(editor.document, { selection, viewColumn: editor.viewColumn }) |
| 279 | .then((e) => { |
| 280 | e.revealRange(selection, vscode.TextEditorRevealType.InCenter); |
| 281 | }); |
| 282 | } |
| 283 | |
| 284 | let codeLenses: vscode.CodeLens[] = []; |
| 285 | // Wait for the code lens to appear |
| 286 | await waitForCondition( |
| 287 | async () => { |
| 288 | const textDocument = await vscode.workspace.openTextDocument(document); |
| 289 | await vscode.window.showTextDocument(textDocument, undefined, false); |
| 290 | codeLenses = (await vscode.commands.executeCommand( |
| 291 | 'vscode.executeCodeLensProvider', |
| 292 | document |
| 293 | )) as vscode.CodeLens[]; |
| 294 | return ( |
| 295 | codeLenses && |
| 296 | codeLenses.length > 0 && |
| 297 | codeLenses.find((c) => c.command?.command === command) != undefined |
| 298 | ); |
| 299 | }, |
| 300 | defaultNotebookTestTimeout, |
| 301 | `Code lens with command ${command} not found` |
| 302 | ); |
| 303 | |
| 304 | logger.ci(`Found code lenses with command ${command}`); |
| 305 | return codeLenses; |
| 306 | } |
| 307 | |
| 308 | export async function verifySelectedControllerIsRemoteForRemoteTests(notebook?: vscode.NotebookDocument) { |
| 309 | if (!IS_REMOTE_NATIVE_TEST() || !isWeb()) { |
no test coverage detected