Skip to content

Commit 92813f9

Browse files
committed
Use conditional wait before EditorView.getAction to stabilize test
Signed-off-by: Aurélien Pupier <[email protected]>
1 parent fbf45c2 commit 92813f9

File tree

2 files changed

+25
-3
lines changed

2 files changed

+25
-3
lines changed

src/ui-test/tests/deploy.kubernetes.run.test.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ import {
2424
} from 'vscode-extension-tester';
2525
import { killTerminal, waitUntilTerminalHasText } from '../utils';
2626
import { CAMEL_ROUTE_YAML_WITH_SPACE } from '../variables';
27+
import waitUntil from 'async-wait-until';
2728

2829
/**
2930
* Note: OC login needs to be done before executing this test for deployment into OpenShift
@@ -50,6 +51,13 @@ describe('Camel standalone file deployment using Camel JBang Kubernetes Run', fu
5051
});
5152

5253
it('Deploy integration to OpenShift or Kubernetes (Minikube)', async function () {
54+
await waitUntil(async() => {
55+
try {
56+
return await editorView.getAction('Deploy Integration with Apache Camel Kubernetes Run') !== undefined;
57+
} catch {
58+
return false;
59+
}
60+
});
5361
const action = (await editorView.getAction('Deploy Integration with Apache Camel Kubernetes Run')) as EditorAction;
5462
await action.click();
5563
await waitUntilTerminalHasText(action.getDriver(), ['Hello Camel from'], 10_000, 900_000);

src/ui-test/tests/editor.actions.test.ts

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,10 +34,11 @@ import {
3434
isCamelVersionProductized,
3535
} from '../utils';
3636
import { CAMEL_RUN_DEBUG_FOLDER_ACTION_LABEL, CAMEL_RUN_DEBUG_WORKSPACE_ACTION_LABEL, CAMEL_RUN_FOLDER_ACTION_LABEL, CAMEL_RUN_WORKSPACE_ACTION_LABEL, TOP_ROUTE_1 } from '../variables';
37+
import waitUntil from 'async-wait-until';
3738

3839
describe('Camel file editor test', function () {
3940

40-
describe('Camel Actions', function () {
41+
describe.only('Camel Actions', function () {
4142
this.timeout(300000);
4243

4344
let driver: WebDriver;
@@ -67,7 +68,7 @@ describe('Camel file editor test', function () {
6768
if (process.platform === "darwin"){
6869
this.skip();
6970
}
70-
await driver.sleep(500);
71+
await actionAvailable(editorView, "Run or Debug...");
7172
const action = (await editorView.getAction("Run or Debug...")) as EditorActionDropdown;
7273
const menu = await action.open();
7374
expect(await menu.hasItem(CAMEL_RUN_ACTION_LABEL)).true;
@@ -80,7 +81,7 @@ describe('Camel file editor test', function () {
8081
if (process.platform === "darwin"){
8182
this.skip();
8283
}
83-
await driver.sleep(500);
84+
await actionAvailable(editorView, "Run or Debug...");
8485
const action = (await editorView.getAction("Run or Debug...")) as EditorActionDropdown;
8586
const menu = await action.open();
8687
expect(await menu.hasItem(CAMEL_RUN_DEBUG_ACTION_LABEL)).true;
@@ -100,6 +101,7 @@ describe('Camel file editor test', function () {
100101
if (process.platform === "darwin") {
101102
this.skip();
102103
}
104+
await actionAvailable(editorView, "Run or Debug...");
103105
const action = (await editorView.getAction("Run or Debug...")) as EditorActionDropdown;
104106
const menu = await action.open();
105107
await menu.select(runActionLabels.label);
@@ -122,6 +124,7 @@ describe('Camel file editor test', function () {
122124
if (process.platform === "darwin"){
123125
this.skip();
124126
}
127+
await actionAvailable(editorView, "Run or Debug...");
125128
const action = (await editorView.getAction("Run or Debug...")) as EditorActionDropdown;
126129
const menu = await action.open();
127130
await menu.select(debugActionLabels.label);
@@ -135,3 +138,14 @@ describe('Camel file editor test', function () {
135138
});
136139
});
137140
});
141+
142+
async function actionAvailable(editorView: EditorView, actionLabel: string) {
143+
await waitUntil(async() => {
144+
try {
145+
return await editorView.getAction(actionLabel) !== undefined;
146+
} catch {
147+
return false;
148+
}
149+
});
150+
}
151+

0 commit comments

Comments
 (0)