forked from openshift/origin-web-console
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathuser_adds_template_to_project.spec.js
80 lines (74 loc) · 3.81 KB
/
user_adds_template_to_project.spec.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
'use strict';
const h = require('../helpers');
const projectHelpers = require('../helpers/project');
const OverviewPage = require('../page-objects/overview').OverviewPage;
const CreateProjectPage = require('../page-objects/createProject').CreateProjectPage;
const DeploymentsPage = require('../page-objects/deployments').DeploymentsPage;
const ServicesPage = require('../page-objects/services').ServicesPage;
const RoutesPage = require('../page-objects/routes').RoutesPage;
const nodeMongoTemplate = require('../fixtures/nodejs-mongodb');
describe('User adds a template to a project', () => {
beforeEach(() => {
h.commonSetup();
h.login();
projectHelpers.deleteAllProjects();
});
afterEach(() => {
h.commonTeardown();
});
describe('after creating a new project', () => {
describe('using the "Import YAML/JSON" tab', () => {
it('should process and create the objects in the template', () => {
let project = projectHelpers.projectDetails();
let createProjectPage = new CreateProjectPage(project);
createProjectPage.visit();
createProjectPage.createProject();
let overviewPage = new OverviewPage(project);
overviewPage.visit();
let catalogPage = overviewPage.clickAddToProject(); // implicit redirect to catalog page
catalogPage
.processTemplate(JSON.stringify(nodeMongoTemplate))
.then((createFromTemplatePage) => {
createFromTemplatePage.clickCreate(); // implicit redirect to overview page
// verify we have the 2 deployments in the template
let deploymentsPage = new DeploymentsPage(project);
deploymentsPage.visit();
expect(element(by.cssContainingText('td', 'mongodb')).isPresent()).toBe(true); // TODO: use fixture
expect(element(by.cssContainingText('td', 'nodejs-mongodb-example')).isPresent()).toBe(true); // TODO: use fixture
// verify we have the two services in the template
let servicesPage = new ServicesPage(project);
servicesPage.visit();
expect(element(by.cssContainingText('td', 'mongodb')).isPresent()).toBe(true); // TODO: use fixture
expect(element(by.cssContainingText('td', 'nodejs-mongodb-example')).isPresent()).toBe(true); // TODO: use fixture
// verify we have one route for the mongo app
let routesPage = new RoutesPage(project);
routesPage.visit();
expect(element(by.cssContainingText('td', 'nodejs-mongodb-example')).isPresent()).toBe(true); // TODO: use fixture
});
});
it('should save the template in the project catalog', () => {
// TODO: same flow as the above test, but use:
// catalogPage.saveTemplate(tpl)
// & assert that the template was added to the catalog in this project
let project = projectHelpers.projectDetails();
let createProjectPage = new CreateProjectPage(project);
createProjectPage.visit();
createProjectPage.createProject();
let overviewPage = new OverviewPage(project);
overviewPage.visit();
let catalogPage = overviewPage.clickAddToProject(); // implicit redirect to catalog page
catalogPage
.saveTemplate(JSON.stringify(nodeMongoTemplate))
.then((overview2) => {
let cat2 = overview2.clickAddToProject(); // implicit redirect to catalog page
// once the template processes, we just have to return
// to the catalog and verify the tile exists
cat2.visit();
cat2.clickCategory('JavaScript'); // TODO: pass in the tile name from the template fixture
cat2.findTileBy('Node.js + MongoDB (Ephemeral)', project.name); // TODO: pass in...
expect(element).toBeTruthy();
});
});
});
});
});