Skip to content

Commit 4aa33e6

Browse files
Lukas Grossmannvrubezhny
authored andcommitted
Adding first part of add cluster test
Signed-off-by: Lukas Grossmann <lgrossma@redhat.com>
1 parent dd6a27a commit 4aa33e6

File tree

3 files changed

+91
-12
lines changed

3 files changed

+91
-12
lines changed
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
/*-----------------------------------------------------------------------------------------------
2+
* Copyright (c) Red Hat, Inc. All rights reserved.
3+
* Licensed under the MIT License. See LICENSE file in the project root for license information.
4+
*-----------------------------------------------------------------------------------------------*/
5+
import { By, WebElement, WebView } from 'vscode-extension-tester';
6+
import { WebViewForm } from './WebViewForm';
7+
8+
//TODO: Add support for create from git page and from local codebase page
9+
10+
/**
11+
* @author Lukas Grossmann <lgrossma@redhat.com>
12+
* Class represents WebView of Create Component form
13+
*/
14+
15+
export class AddClusterWebView extends WebViewForm {
16+
17+
public constructor() {
18+
super('Add OpenShift Cluster');
19+
}
20+
21+
public async addLocalCluster(): Promise<void> {
22+
await this.enterWebView(async (webView) => {
23+
const button = await this.getCreateRefreshClusterButton(webView);
24+
await button.click();
25+
});
26+
}
27+
28+
public async addDevSandbox(): Promise<void> {
29+
await this.enterWebView(async (webView) => {
30+
const button = await this.getStartYourOpenshiftExperienceButton(webView);
31+
await button.click();
32+
})
33+
}
34+
35+
private async getCreateRefreshClusterButton(webView: WebView): Promise<WebElement> {
36+
return await webView.findWebElement(By.xpath('//span[contains(text(),"Create/Refresh cluster")]'));
37+
}
38+
39+
private async getStartYourOpenshiftExperienceButton(webView: WebView): Promise<WebElement> {
40+
return await webView.findElement(By.xpath('//span[contains(text(),"Start your OpenShift experience")]'));
41+
}
42+
}

test/ui/public-ui-test.ts

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -3,25 +3,27 @@
33
* Licensed under the MIT License. See LICENSE file in the project root for license information.
44
*-----------------------------------------------------------------------------------------------*/
55

6-
import { checkAboutCommand } from './suite/command-about';
7-
import path = require('path');
8-
import { testCreateComponent } from './suite/createComponent';
9-
import { testDevfileRegistries } from './suite/devfileRegistries';
6+
//import { checkAboutCommand } from './suite/command-about';
7+
//import path = require('path');
8+
//import { testCreateComponent } from './suite/createComponent';
9+
//import { testDevfileRegistries } from './suite/devfileRegistries';
1010
import { checkExtension } from './suite/extension';
11-
import { checkFocusOnCommands } from './suite/focusOn';
11+
//import { checkFocusOnCommands } from './suite/focusOn';
1212
import { checkOpenshiftView } from './suite/openshift';
13-
import { testCreateServerlessFunction } from './suite/serverlessFunction';
13+
//import { testCreateServerlessFunction } from './suite/serverlessFunction';
14+
import { testAddCluster } from './suite/addCluster';
1415

1516
require('source-map-support').install();
1617

1718
describe('Extension public-facing UI tests', function() {
18-
const contextFolder = path.join(__dirname, 'context');
19+
//const contextFolder = path.join(__dirname, 'context');
1920

2021
checkExtension();
2122
checkOpenshiftView();
22-
checkAboutCommand();
23-
testDevfileRegistries();
24-
checkFocusOnCommands();
25-
testCreateComponent(contextFolder);
26-
testCreateServerlessFunction(contextFolder);
23+
testAddCluster();
24+
//checkAboutCommand();
25+
//testDevfileRegistries();
26+
//checkFocusOnCommands();
27+
//testCreateComponent(contextFolder);
28+
//testCreateServerlessFunction(contextFolder);
2729
});

test/ui/suite/addCluster.ts

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
/*-----------------------------------------------------------------------------------------------
2+
* Copyright (c) Red Hat, Inc. All rights reserved.
3+
* Licensed under the MIT License. See LICENSE file in the project root for license information.
4+
*-----------------------------------------------------------------------------------------------*/
5+
import { ActivityBar, EditorView, SideBarView } from 'vscode-extension-tester';
6+
import { VIEWS } from '../common/constants';
7+
import { collapse } from '../common/overdrives';
8+
import { AddClusterWebView } from '../common/ui/webview/addClusterWebView';
9+
10+
export function testAddCluster() {
11+
describe('Add Cluster', function () {
12+
13+
let view: SideBarView;
14+
15+
before(async function context() {
16+
await new EditorView().closeAllEditors();
17+
view = await (await new ActivityBar().getViewControl(VIEWS.openshift)).openView();
18+
for (const item of [VIEWS.components, VIEWS.compRegistries, VIEWS.serverlessFunctions, VIEWS.debugSessions]) {
19+
await collapse(await view.getContent().getSection(item))
20+
}
21+
});
22+
23+
it('Page with options is shown', async function test() {
24+
this.timeout(15_000);
25+
await new Promise((res) => {setTimeout(res, 6_000)});
26+
const section = await view.getContent().getSection(VIEWS.appExplorer);
27+
const buttons = await (await section.findWelcomeContent()).getButtons();
28+
await buttons[2].click();
29+
30+
const addClusterView = new AddClusterWebView();
31+
await addClusterView.initializeEditor();
32+
await addClusterView.addLocalCluster();
33+
})
34+
})
35+
}

0 commit comments

Comments
 (0)