Skip to content

Commit 135de8b

Browse files
committed
Use workaround for ActivityBar in 2 places for UI tests
Signed-off-by: Aurélien Pupier <[email protected]>
1 parent 6c9d729 commit 135de8b

File tree

3 files changed

+21
-11
lines changed

3 files changed

+21
-11
lines changed

src/ui-test/tests/debugger.test.ts

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,8 @@ import {
4545
DEFAULT_MESSAGE,
4646
isCamelVersionProductized,
4747
isVersionNewer,
48-
DEBUG_ITEM_OPERATOR
48+
DEBUG_ITEM_OPERATOR,
49+
waitUntilViewOpened
4950
} from '../utils';
5051
import waitUntil from 'async-wait-until';
5152

@@ -68,15 +69,7 @@ describe('Camel Debugger tests', function () {
6869
await VSBrowser.instance.openResources(path.resolve('src', 'ui-test', 'resources'));
6970
console.log('src/ui-test/resources opened');
7071

71-
// workaround: using waitUntil as sometimes the ActivityBar is not ready and then the View is redrawn causing staleElement error
72-
await waitUntil(async() => {
73-
try {
74-
return await (await new ActivityBar().getViewControl('Explorer'))?.openView() !== undefined;
75-
} catch {
76-
return false;
77-
}
78-
}, 10000, 1000);
79-
72+
waitUntilViewOpened('Explorer');
8073
console.log('Explorer view opened');
8174

8275
const section = await new SideBarView().getContent().getSection('resources');

src/ui-test/tests/pause.test.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ import {
3535
disconnectDebugger,
3636
killTerminal,
3737
isCamelVersionProductized,
38+
waitUntilViewOpened,
3839
} from "../utils";
3940
import { assert } from "chai";
4041

@@ -51,7 +52,7 @@ describe("Support pause of Camel debugger", function () {
5152
}
5253
driver = VSBrowser.instance.driver;
5354
await VSBrowser.instance.openResources(RESOURCES_DIR);
54-
await (await new ActivityBar().getViewControl('Explorer'))?.openView();
55+
waitUntilViewOpened('Explorer');
5556
});
5657

5758
afterEach(async function () {

src/ui-test/utils.ts

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ import * as path from 'path';
4343
import * as fs from 'fs-extra';
4444
import { ENABLING_CAMEL_DEBUGGER } from './variables';
4545
import { storageFolder } from "./uitest_runner";
46+
import waitUntil from 'async-wait-until';
4647

4748
// the changes in debug side bar view were presented for new VS Code versions
4849
export const DEBUG_ITEM_OPERATOR = ' =';
@@ -638,3 +639,18 @@ async function getTerminalText() : Promise<string> {
638639
return await terminal.getText();
639640
}
640641

642+
/**
643+
* workaround to await (await new ActivityBar().getViewControl(viewName))?.openView()
644+
* using waitUntil as sometimes the ActivityBar is not ready and then the View is redrawn causing staleElement error
645+
* @param viewName
646+
*/
647+
export async function waitUntilViewOpened(viewName :string) {
648+
await waitUntil(async () => {
649+
try {
650+
return await (await new ActivityBar().getViewControl(viewName))?.openView() !== undefined;
651+
} catch {
652+
return false;
653+
}
654+
}, 10000, 1000);
655+
}
656+

0 commit comments

Comments
 (0)