Skip to content

Commit d652687

Browse files
committed
Add conditional wait for editor action in editor.actions.tests to
stabilize test Signed-off-by: Aurélien Pupier <[email protected]>
1 parent add39c3 commit d652687

File tree

4 files changed

+18
-19
lines changed

4 files changed

+18
-19
lines changed

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ import { ActivityBar, EditorActionDropdown, EditorView, SideBarView, VSBrowser,
2020
import { CAMEL_ROUTE_YAML_WITH_SPACE, CAMEL_RUN_ACTION_LABEL, CAMEL_RUN_DEBUG_ACTION_LABEL, CAMEL_RUN_DEBUG_FOLDER_ACTION_LABEL, CAMEL_RUN_DEBUG_WORKSPACE_ACTION_LABEL, CAMEL_RUN_FOLDER_ACTION_LABEL, CAMEL_RUN_WORKSPACE_ACTION_LABEL } from "../variables";
2121
import { expect } from "chai";
2222
import { notificationCenterContains, waitUntilNotificationShows } from "../utils";
23+
import { actionAvailable } from './helper/Awaiters';
2324

2425
describe('Check actions requirements to run/debug', function () {
2526
this.timeout(90000);
@@ -76,6 +77,7 @@ describe('Check actions requirements to run/debug', function () {
7677
});
7778

7879
async function clickButtonAndVerifyNotification(actionLabel: string) {
80+
await actionAvailable(editorView, "Run or Debug...");
7981
const action = (await editorView.getAction("Run or Debug...")) as EditorActionDropdown;
8082
const menu = await action.open();
8183
await menu.select(actionLabel);

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

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ import {
2525
import { killTerminal, waitUntilTerminalHasText } from '../utils';
2626
import { CAMEL_ROUTE_YAML_WITH_SPACE } from '../variables';
2727
import waitUntil from 'async-wait-until';
28+
import { actionAvailable } from './helper/Awaiters';
2829

2930
/**
3031
* Note: OC login needs to be done before executing this test for deployment into OpenShift
@@ -52,13 +53,7 @@ describe('Camel standalone file deployment using Camel JBang Kubernetes Run', fu
5253

5354
it('Deploy integration to OpenShift or Kubernetes (Minikube)', async function () {
5455
await VSBrowser.instance.driver.sleep(500);
55-
await waitUntil(async() => {
56-
try {
57-
return await editorView.getAction('Deploy Integration with Apache Camel Kubernetes Run') !== undefined;
58-
} catch {
59-
return false;
60-
}
61-
});
56+
await actionAvailable(editorView, 'Deploy Integration with Apache Camel Kubernetes Run');
6257
const action = (await editorView.getAction('Deploy Integration with Apache Camel Kubernetes Run')) as EditorAction;
6358
await action.click();
6459
await waitUntilTerminalHasText(action.getDriver(), ['Hello Camel from'], 10_000, 900_000);

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

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ 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';
37+
import { actionAvailable } from './helper/Awaiters';
3838

3939
describe('Camel file editor test', function () {
4040

@@ -138,14 +138,3 @@ describe('Camel file editor test', function () {
138138
});
139139
});
140140
});
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-
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
import waitUntil from 'async-wait-until';
2+
import { EditorView } from 'vscode-extension-tester';
3+
4+
5+
export async function actionAvailable(editorView: EditorView, actionLabel: string) {
6+
await waitUntil(async () => {
7+
try {
8+
return await editorView.getAction(actionLabel) !== undefined;
9+
} catch {
10+
return false;
11+
}
12+
});
13+
}

0 commit comments

Comments
 (0)