Skip to content

Commit 4869596

Browse files
committed
Fix cluster-dependent UI test suite
With a running `crc` cluster, run `npm run cluster-ui-test` in order to run the cluster-dependent UI test suite. - renamed `smoke-test` to `cluster-ui-test` and removed some of the tests that overlap between the suites - Most of this work is also done in #2803, so I just copied it from over there - Temporarily addresses #2780, we will need to rewrite it once the new create component workflow is in place Fixes #2777 Signed-off-by: David Thompson <davthomp@redhat.com>
1 parent 0548b63 commit 4869596

File tree

5 files changed

+57
-46
lines changed

5 files changed

+57
-46
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@
6969
"update-deps": "ncu --upgrade --loglevel verbose --packageFile package.json && npm update",
7070
"coverage:upload": "codecov -f coverage/coverage-final.json",
7171
"build": "npm run clean && npm run lint && npm run compile && npm run bundle-tools",
72-
"smoke-test": "extest setup-and-run out/test/ui/smoke-test.js -o test/ui/settings.json -m test/ui/.mocharc.js -e ./test-resources/extensions -c max -i",
72+
"cluster-ui-test": "extest setup-and-run out/test/ui/cluster-ui-test.js -o test/ui/settings.json -m test/ui/.mocharc.js -e ./test-resources/extensions -c max -i",
7373
"public-ui-test": "extest setup-and-run out/test/ui/public-ui-test.js -o test/ui/settings.json -m test/ui/.mocharc.js -e ./test-resources/extensions -c max -i"
7474
},
7575
"dependencies": {

test/ui/Jenkinsfile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,9 @@ node('rhel8') {
2121
}
2222
}
2323
}
24-
stage('UI smoke test') {
24+
stage('cluster-dependent UI tests') {
2525
wrap([$class: 'Xvnc']) {
26-
sh "npm run smoke-test"
26+
sh "npm run cluster-ui-test"
2727
junit 'report.xml'
2828
}
2929
}
Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,28 +3,27 @@
33
* Licensed under the MIT License. See LICENSE file in the project root for license information.
44
*-----------------------------------------------------------------------------------------------*/
55

6-
import * as path from 'path';
76
import * as fs from 'fs-extra';
7+
import * as path from 'path';
8+
import { createComponentTest } from './suite/component';
89
import { checkExtension } from './suite/extension';
910
import { checkOpenshiftView } from './suite/openshift';
10-
import { createComponentTest } from './suite/component';
11-
import { checkAboutCommand } from './suite/command-about';
1211

13-
describe('Extension smoke test', () => {
12+
describe('Extension cluster-dependant UI tests', function () {
1413
const kubeConfig = path.join(process.env[(process.platform === 'win32') ? 'USERPROFILE' : 'HOME'], '.kube', 'config');
1514
const kubeBackup = `${kubeConfig}.backup`;
1615
const contextFolder = path.join(__dirname, 'context');
1716

1817
// test with an empty kube config, make a backup, wipe the context folder
19-
before(async () => {
18+
before(async function () {
2019
if (fs.existsSync(kubeConfig)) {
2120
await fs.move(kubeConfig, kubeBackup, { overwrite: true });
2221
}
2322
await fs.emptyDir(contextFolder);
2423
});
2524

2625
// restore the kube config backup after test
27-
after(async () => {
26+
after(async function () {
2827
if (fs.existsSync(kubeBackup)) {
2928
await fs.move(kubeBackup, kubeConfig, { overwrite: true });
3029
}
@@ -33,5 +32,4 @@ describe('Extension smoke test', () => {
3332
checkExtension();
3433
checkOpenshiftView();
3534
createComponentTest(contextFolder);
36-
checkAboutCommand();
3735
});

test/ui/common/constants.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,13 +34,14 @@ export const INPUTS = {
3434
export const MENUS = {
3535
newProject: 'New Project',
3636
delete: 'Delete',
37-
push: 'Push',
37+
bindService: 'Bind Service',
38+
startDev: 'Start Dev',
3839
};
3940

4041
export const COMPONENTS = {
41-
nodejsDevfile: 'nodejs (devfile)',
42+
nodejsDevfile: 'nodejs/DefaultDevfileRegistry',
4243
devfileComponent: (name: string) => `${name} (devfile)`,
43-
pushSuccess: 'Changes successfully pushed',
44+
devStarted: 'Ctrl+c',
4445
};
4546

4647
export const NOTIFICATIONS = {

test/ui/suite/component.ts

Lines changed: 45 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -4,35 +4,40 @@
44
*-----------------------------------------------------------------------------------------------*/
55

66
import { expect } from 'chai';
7-
import { ActivityBar, InputBox, SideBarView, TreeItem, ViewSection, VSBrowser, WelcomeContentButton, Workbench } from 'vscode-extension-tester';
8-
import { itemExists, notificationExists, terminalHasText, waitForInputProgress, waitForInputUpdate } from '../common/conditions';
9-
import { VIEWS, MENUS, BUTTONS, INPUTS, COMPONENTS, NOTIFICATIONS } from '../common/constants';
7+
import { ActivityBar, EditorView, InputBox, SideBarView, TerminalView, TreeItem, ViewSection, VSBrowser, WelcomeContentButton, Workbench } from 'vscode-extension-tester';
8+
import { itemExists, notificationExists, terminalHasText, waitForInputUpdate } from '../common/conditions';
9+
import { BUTTONS, COMPONENTS, INPUTS, MENUS, NOTIFICATIONS, VIEWS } from '../common/constants';
1010

1111
export function createComponentTest(contextFolder: string) {
12-
describe('Component creation', () => {
13-
const cluster = process.env.CLUSTER_URL || 'https://api.ocp2.adapters-crs.ccitredhat.com:6443';
14-
const clusterName = (/https?:\/\/(.*)/.exec(cluster))[1];
12+
describe('Component creation', function() {
13+
const cluster = process.env.CLUSTER_URL || 'https://api.crc.testing:6443';
14+
const clusterName = cluster;
1515
const user = process.env.CLUSTER_USER || 'developer';
1616
const password = process.env.CLUSTER_PASSWORD || 'developer';
1717
let view: SideBarView;
1818
let explorer: ViewSection;
1919
let components: ViewSection;
20+
let editorView: EditorView;
2021

2122
const projectName = `project${Math.floor(Math.random() * 100)}`
22-
const appName = `app${Math.floor(Math.random() * 100)}`;
2323
const compName = `comp${Math.floor(Math.random() * 100)}`;
2424

25-
before(async () => {
25+
before(async function () {
2626
view = await (await new ActivityBar().getViewControl(VIEWS.openshift)).openView();
2727
explorer = await view.getContent().getSection(VIEWS.appExplorer);
2828
components = await view.getContent().getSection(VIEWS.components);
2929
});
3030

31-
beforeEach(async () => {
31+
beforeEach(async function() {
3232
const center = await new Workbench().openNotificationsCenter();
3333
await center.clearAllNotifications();
3434
});
3535

36+
afterEach(async function() {
37+
editorView = new EditorView();
38+
await editorView.closeAllEditors();
39+
});
40+
3641
after(async function() {
3742
this.timeout(60000);
3843
const projectItem = await explorer.findItem(projectName);
@@ -46,7 +51,7 @@ export function createComponentTest(contextFolder: string) {
4651
});
4752

4853
it('Login with credentials', async function() {
49-
this.timeout(30000);
54+
this.timeout(30_000);
5055
await explorer.expand();
5156
const content = await explorer.findWelcomeContent();
5257
// eslint-disable-next-line no-console, @typescript-eslint/restrict-template-expressions
@@ -118,54 +123,61 @@ export function createComponentTest(contextFolder: string) {
118123
});
119124

120125
it('Create a new component from scratch', async function() {
121-
this.timeout(60000);
122-
const newComponent = (await (await components.findWelcomeContent()).getButtons())[0];
126+
this.timeout(120_000);
127+
const newComponent = (await (await components.findWelcomeContent()).getButtons())[1];
123128
await newComponent.click();
124129

125-
// provide application name
130+
// wait for input quick pick to appear
126131
const input = await InputBox.create();
127-
const appMessage = await input.getMessage();
128-
await input.setText(appName);
129-
await input.confirm();
130132

131133
// select to add new context folder
132-
await waitForInputUpdate(input, appMessage);
133134
await input.selectQuickPick(INPUTS.newFolderQuickPick);
134135

135136
// select the context folder
136137
await input.setText(contextFolder);
137138
await input.confirm();
138139

139-
// provide component name
140-
await waitForInputUpdate(input, '');
141-
await input.setText(compName);
142-
await input.confirm();
143-
144140
// select nodejs devfile template
145-
await waitForInputProgress(input, true);
146-
await waitForInputProgress(input, false, 20000);
147141
await new Promise(res => setTimeout(res, 500));
148142
await input.setText(COMPONENTS.nodejsDevfile);
149143
await input.confirm();
150144

151145
// select yes for starter project
152146
await new Promise(res => setTimeout(res, 500));
153147
await input.selectQuickPick(INPUTS.yes);
148+
149+
// provide component name
150+
await new Promise(res => setTimeout(res, 500));
151+
await input.setText(compName);
152+
await input.confirm();
153+
154154
await new Promise(res => setTimeout(res, 5000));
155155
const project = await itemExists(projectName, explorer) as TreeItem;
156156
await project.expand();
157157

158-
const app = await itemExists(appName, explorer) as TreeItem;
159-
await app.expand();
160-
await itemExists(COMPONENTS.devfileComponent(compName), explorer);
158+
await itemExists(compName, components, 30_000);
161159
});
162160

163-
it('Push the component', async function() {
164-
this.timeout(150000);
165-
const component = await itemExists(COMPONENTS.devfileComponent(compName), explorer);
161+
it('Start the component in dev mode', async function() {
162+
this.timeout(180000);
163+
const component = await itemExists(compName, components, 30_000);
164+
166165
const menu = await component.openContextMenu();
167-
await menu.select(MENUS.push);
168-
await terminalHasText(COMPONENTS.pushSuccess, 120000);
166+
await menu.select(MENUS.startDev);
167+
await terminalHasText(COMPONENTS.devStarted, 60_000);
168+
169+
const term = new TerminalView();
170+
await term.killTerminal();
171+
172+
// wait for component to stop running.
173+
// the component name changes to
174+
// `component-name (stopping)`
175+
// while `odo dev` is stopping
176+
// then it returns to
177+
// `component-name`
178+
// when `odo dev` has stopped
179+
await itemExists(compName, components, 60_000);
169180
});
181+
170182
});
171-
}
183+
}

0 commit comments

Comments
 (0)