-
Notifications
You must be signed in to change notification settings - Fork 60
Expand file tree
/
Copy pathdevfileRegistries.ts
More file actions
140 lines (128 loc) · 7.4 KB
/
devfileRegistries.ts
File metadata and controls
140 lines (128 loc) · 7.4 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
/*-----------------------------------------------------------------------------------------------
* Copyright (c) Red Hat, Inc. All rights reserved.
* Licensed under the MIT License. See LICENSE file in the project root for license information.
*-----------------------------------------------------------------------------------------------*/
import { expect } from 'chai';
import { ActivityBar, CustomTreeSection, EditorView, InputBox, SideBarView, ViewSection, VSBrowser, WebDriver } from 'vscode-extension-tester';
import { OdoPreference } from '../../../src/odo/odoPreference';
import { notificationExists } from '../common/conditions';
import { VIEWS } from '../common/constants';
import { RegistryWebViewEditor } from '../common/ui/webview/registryWebViewEditor';
export function testDevfileRegistries() {
describe('Devfile Registries', () => {
let view: SideBarView;
let registrySection: ViewSection;
let driver: WebDriver;
before(async function context() {
this.timeout(10_000);
driver = VSBrowser.instance.driver;
view = await (await new ActivityBar().getViewControl(VIEWS.openshift)).openView();
await new Promise(res => setTimeout(res, 5_000));
registrySection = await view.getContent().getSection(VIEWS.compRegistries);
});
it('registry actions are available', async function test() {
this.timeout(5_000);
expect(await Promise.all((await registrySection.getActions()).map(async item => await item.getLabel()))).to.has.members(['Add Registry', 'Open Registry View', 'Refresh Components Types View']);
});
it('default Devfile registry is present', async function test() {
this.timeout(5_000);
await registrySection.expand();
const registry = await registrySection.findItem(VIEWS.devFileRegistry);
expect(registry).not.undefined;
expect(await registry.getText()).to.equal(OdoPreference.DEFAULT_DEVFILE_REGISTRY_NAME);
});
it('add new Devfile registry', async function test() {
this.timeout(20_000);
const addAction = await registrySection.getAction('Add Registry');
await addAction.click();
const input = await InputBox.create();
// insert registry name into input box
await input.setText('stageRegistry');
await input.confirm();
// insert staging devfile registry url
await input.setText('https://registry.stage.devfile.io');
await input.confirm();
// pick unsecured registry
await input.selectQuickPick('No');
await new Promise((res) => { setTimeout(res, 5_000); });
// check registry exists
await registrySection.expand();
let stageRegistry = await (registrySection as CustomTreeSection).findItem('stageRegistry');
//If statement for greater timeout in cases where loading takes more time than expected
if(stageRegistry === undefined) {
await new Promise((res) => { setTimeout(res, 10_000); });
stageRegistry = await (registrySection as CustomTreeSection).findItem('stageRegistry');
}
expect(stageRegistry).not.undefined;
});
it('edit existing Devfile registry', async function test() {
this.timeout(20_000);
await registrySection.expand();
const stageRegistry = await (registrySection as CustomTreeSection).findItem('stageRegistry');
const menu = await stageRegistry.openContextMenu();
await (await menu.getItem('Edit')).select();
const input = await InputBox.create();
// insert registry name into input box
await input.setText('editedRegistry');
await input.confirm();
// insert staging devfile registry url
await input.setText('https://registry.stage.devfile.io');
await input.confirm();
// pick unsecured registry
await input.selectQuickPick('No');
await new Promise((res) => { setTimeout(res, 5_000); });
// check registry exists
await registrySection.expand();
let editedRegistry = await (registrySection as CustomTreeSection).findItem('editedRegistry');
//If statement for greater timeout in cases where loading takes more time than expected
if(editedRegistry === undefined) {
await new Promise((res) => { setTimeout(res, 10_000); });
editedRegistry = await (registrySection as CustomTreeSection).findItem('editedRegistry');
}
expect(editedRegistry).not.undefined;
});
it('remove Devfile registry', async function test() {
this.timeout(10_000);
await registrySection.expand();
let stageRegistry = await registrySection.findItem('editedRegistry');
const menu = await stageRegistry.openContextMenu();
await (await menu.getItem('Remove')).select();
// find and confirm notification about registry deletion
const notification = await notificationExists('Remove registry \'editedRegistry\'?', driver);
await notification.takeAction('Yes');
await new Promise((res) => { setTimeout(res, 2_000); });
stageRegistry = await registrySection.findItem('editedRegistry');
expect(stageRegistry).is.undefined;
});
it('open Devfile registry view from Section action', async function test() {
this.timeout(10_000);
await (await registrySection.getAction('Open Registry View')).click();
// open editor tab by title
const editorView = new EditorView();
const editor = await editorView.openEditor('Devfile Registry');
expect(await editor.getTitle()).to.include('Devfile Registry');
});
it('open Devfile registry view from item\'s context menu and verify the content of the registry', async function test() {
this.timeout(10_000);
await new EditorView().closeAllEditors();
const devfileRegistry = await registrySection.findItem(OdoPreference.DEFAULT_DEVFILE_REGISTRY_NAME);
await devfileRegistry.select();
const menu = await devfileRegistry.openContextMenu();
await (await menu.getItem('Open in Editor')).select();
await new Promise((res) => { setTimeout(res, 3_000); });
// check opened editor tab by title
const editorView = new EditorView();
const editor = await editorView.openEditor('Devfile Registry - DefaultDevfileRegistry');
expect(await editor.getTitle()).to.include('Devfile Registry - DefaultDevfileRegistry');
// initialize web view editor
const webView = new RegistryWebViewEditor('Devfile Registry - DefaultDevfileRegistry');
await webView.initializeEditor();
// Expect these components to be available on the first page
expect(await webView.getRegistryStackNames()).to.include.members(['Quarkus Java', 'Django', 'Go Runtime', 'Maven Java', 'Node.js Runtime', 'Open Liberty Gradle', 'Open Liberty Maven', 'Python', 'Vert.x Java']);
});
after(async function context() {
this.timeout(10_000);
await new EditorView().closeAllEditors();
});
});
}