Skip to content

Commit a876c15

Browse files
authored
test: update e2e test wait condition to wait for definitions (#1448)
Rather than waiting a set 25 seconds for ngcc to finish, this updates the tests to instead wait for definitions to be available in the template. This change was intended to be in #1367 but accidentally was reverted before merging
1 parent 656afa6 commit a876c15

File tree

1 file changed

+17
-1
lines changed

1 file changed

+17
-1
lines changed

integration/e2e/helper.ts

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,5 +13,21 @@ function sleep(ms: number) {
1313

1414
export async function activate(uri: vscode.Uri) {
1515
await vscode.window.showTextDocument(uri);
16-
await sleep(20 * 1000); // Wait for server activation, including ngcc run
16+
await waitForDefinitionsToBeAvailable(20);
1717
}
18+
19+
async function waitForDefinitionsToBeAvailable(maxSeconds: number) {
20+
let tries = 0
21+
while (tries < maxSeconds) {
22+
const position = new vscode.Position(4, 25);
23+
// For a complete list of standard commands, see
24+
// https://code.visualstudio.com/api/references/commands
25+
const definitions = await vscode.commands.executeCommand<vscode.LocationLink[]>(
26+
DEFINITION_COMMAND, APP_COMPONENT_URI, position);
27+
if (definitions && definitions.length > 0) {
28+
return;
29+
}
30+
tries++;
31+
await sleep(1000);
32+
}
33+
}

0 commit comments

Comments
 (0)