forked from openshift/origin-web-console
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcatalog.js
92 lines (89 loc) · 2.65 KB
/
catalog.js
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
'use strict';
const h = require('../helpers.js');
const Page = require('./page').Page;
const AddTemplateModal = require('./modals/addTemplateModal').AddTemplateModal;
class CatalogPage extends Page {
constructor(project, menu) {
super(project, menu);
}
getUrl() {
// TODO: ?tab=tab=fromFile, ?tab=fromCatalog, ?tab=deployImage
return 'project/' + this.project.name + '/create';
}
_findTabs() {
let tabs = element(by.css('.nav-tabs'));
h.waitForElem(tabs);
return tabs;
}
clickTile(heading) {
element(by.cssContainingText('.tile', heading)).click();
}
clickCategory(heading) {
return this.clickTile(heading);
}
findTileBy(heading, namespace) {
var tiles = element.all(by.cssContainingText(heading));
return namespace ?
tiles.all(by.cssContainingText(namespace)).first() :
tiles;
}
clickBrowseCatalog() {
return this._findTabs()
.element(by.cssContainingText('a', 'Browse Catalog'))
.click();
}
clickDeployImage() {
return this._findTabs()
.element(by.cssContainingText('a', 'Deploy Image'))
.click();
}
clickImport() {
return this._findTabs()
.element(by.cssContainingText('a', 'Import YAML / JSON'))
.click();
}
setImportValue(str) {
return browser.executeScript((value) => {
window.ace.edit('add-component-editor').setValue(value);
}, str);
}
getImportValue() {
return browser.executeScript(() => {
return window.ace.edit('add-component-editor').getValue();
});
}
submitTemplate() {
element(by.cssContainingText('.btn-primary','Create')).click();
return browser.sleep(500).then(() => {
return new AddTemplateModal(this.project);
});
}
submitImageStream() {
element(by.cssContainingText('.btn-primary','Create')).click();
}
processTemplate(templateStr) {
this.clickImport();
return this.setImportValue(templateStr).then(() => {
return this.submitTemplate().then((addTemplateModal) => {
// implicit nav therefore returns new CreateFromTemplatePage()
return addTemplateModal.process();
});
});
}
saveTemplate(templateStr) {
this.clickImport();
return this.setImportValue(templateStr).then(() => {
return this.submitTemplate().then((addTemplateModal) => {
// implicit nav therefore returns new CreateFromTemplatePage()
return addTemplateModal.save();
});
});
}
processImageStream(imageStreamStr) {
this.clickImport();
return this.setImportValue(imageStreamStr).then(() => {
return this.submitImageStream();
});
}
}
exports.CatalogPage = CatalogPage;