-
Notifications
You must be signed in to change notification settings - Fork 231
Create from URL e2e tests #1195
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
'use strict'; | ||
|
||
var h = require('../helpers'); | ||
var projectHelpers = require('../helpers/project'); | ||
var OverviewPage = require('../page-objects/overview').OverviewPage; | ||
var CreateProjectPage = require('../page-objects/createProject').CreateProjectPage; | ||
var ImageStreamsPage = require('../page-objects/imageStreams').ImageStreamsPage; | ||
var centosImageStream = require('../fixtures/image-streams-centos7.json'); | ||
|
||
describe('User adds an image stream to a project', function() { | ||
|
||
beforeEach(function() { | ||
h.commonSetup(); | ||
h.login(); | ||
projectHelpers.deleteAllProjects(); | ||
}); | ||
|
||
afterEach(function() { | ||
h.commonTeardown(); | ||
}); | ||
|
||
describe('after creating a new project', function() { | ||
describe('using the "Import YAML/JSON" tab', function() { | ||
it('should process and create the images in the image stream', function() { | ||
var project = projectHelpers.projectDetails(); | ||
var createProjectPage = new CreateProjectPage(project); | ||
createProjectPage.visit(); | ||
createProjectPage.createProject(); | ||
var overviewPage = new OverviewPage(project); | ||
overviewPage.visit(); | ||
var catalogPage = overviewPage.clickAddToProject(); // implicit redirect to catalog page | ||
catalogPage | ||
.processImageStream(JSON.stringify(centosImageStream)) | ||
.then(function() { | ||
// verify we have the nodejs image stream loaded | ||
var imageStreamsPage = new ImageStreamsPage(project); | ||
imageStreamsPage.visit(); | ||
expect(element(by.cssContainingText('td', 'nodejs')).isPresent()).toBe(true); // TODO: use fixture | ||
}); | ||
}); | ||
}); | ||
}); | ||
}); |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,5 @@ | ||
'use strict'; | ||
|
||
require('jasmine-beforeall'); | ||
var h = require('../helpers'); | ||
var projectHelpers = require('../helpers/project'); | ||
var OverviewPage = require('../page-objects/overview').OverviewPage; | ||
|
@@ -9,9 +8,6 @@ var DeploymentsPage = require('../page-objects/deployments').DeploymentsPage; | |
var ServicesPage = require('../page-objects/services').ServicesPage; | ||
var RoutesPage = require('../page-objects/routes').RoutesPage; | ||
var nodeMongoTemplate = require('../fixtures/nodejs-mongodb'); | ||
//var logger = require('../helpers/logger'); | ||
// TODO: use this to alter whitelist in the tests to support the create from url flow | ||
// var env = require('../helpers/env'); | ||
|
||
describe('User adds a template to a project', function() { | ||
|
||
|
@@ -42,24 +38,42 @@ describe('User adds a template to a project', function() { | |
// verify we have the 2 deployments in the template | ||
var deploymentsPage = new DeploymentsPage(project); | ||
deploymentsPage.visit(); | ||
expect(element(by.cssContainingText('td', 'mongodb')).isPresent()).toBe(true); | ||
expect(element(by.cssContainingText('td', 'nodejs-mongodb-example')).isPresent()).toBe(true); | ||
expect(element(by.cssContainingText('td', 'mongodb')).isPresent()).toBe(true); // TODO: use fixture | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. TODO's should be obvious what is needed for someone coming else looking at this later. Also fixture isn't doesn't seem like the right word here, shouldn't it be a helper. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. That comment means to eventually use the fixture (json) and pluck out the names, rather than hard-coding Is on my list to add some table helpers as well. |
||
expect(element(by.cssContainingText('td', 'nodejs-mongodb-example')).isPresent()).toBe(true); // TODO: use fixture | ||
// verify we have the two services in the template | ||
var servicesPage = new ServicesPage(project); | ||
servicesPage.visit(); | ||
expect(element(by.cssContainingText('td', 'mongodb')).isPresent()).toBe(true); | ||
expect(element(by.cssContainingText('td', 'nodejs-mongodb-example')).isPresent()).toBe(true); | ||
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 | ||
var routesPage = new RoutesPage(project); | ||
routesPage.visit(); | ||
expect(element(by.cssContainingText('td', 'nodejs-mongodb-example')).isPresent()).toBe(true); | ||
expect(element(by.cssContainingText('td', 'nodejs-mongodb-example')).isPresent()).toBe(true); // TODO: use fixture | ||
}); | ||
}); | ||
|
||
xit('should save the template in the project catalog', function() { | ||
it('should save the template in the project catalog', function() { | ||
// TODO: same flow as the above test, but use: | ||
// catalogPage.saveTemplate(tpl) | ||
// & assert that the template was added to the catalog in this project | ||
var project = projectHelpers.projectDetails(); | ||
var createProjectPage = new CreateProjectPage(project); | ||
createProjectPage.visit(); | ||
createProjectPage.createProject(); | ||
var overviewPage = new OverviewPage(project); | ||
overviewPage.visit(); | ||
var catalogPage = overviewPage.clickAddToProject(); // implicit redirect to catalog page | ||
catalogPage | ||
.saveTemplate(JSON.stringify(nodeMongoTemplate)) | ||
.then((overview2) => { | ||
var 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(); | ||
}); | ||
}); | ||
}); | ||
}); | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,203 @@ | ||
'use strict'; | ||
|
||
require('jasmine-beforeall'); | ||
|
||
const h = require('../helpers'); | ||
const addExtension = require('../helpers/extensions').addExtension; | ||
const resetExtensions = require('../helpers/extensions').resetExtensions; | ||
const matchersHelpers = require('../helpers/matchers'); | ||
const projectHelpers = require('../helpers/project'); | ||
const inputsHelpers = require('../helpers/inputs'); | ||
const CreateFromURLPage = require('../page-objects/createFromURL').CreateFromURLPage; | ||
const CreateProjectPage = require('../page-objects/createProject').CreateProjectPage; | ||
const CatalogPage = require('../page-objects/catalog').CatalogPage; | ||
const nodeMongoTemplate = require('../fixtures/nodejs-mongodb'); | ||
const centosImageStream = require('../fixtures/image-streams-centos7.json'); | ||
|
||
describe('authenticated e2e-user', function() { | ||
|
||
let project = projectHelpers.projectDetails(); | ||
let namespaceForFixtures = "template-dumpster"; | ||
|
||
let setupEnv = function() { | ||
// add namespace to create whitelist for template and image stream | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
addExtension(` | ||
(function() { | ||
// Update whilelist: | ||
window.OPENSHIFT_CONSTANTS.CREATE_FROM_URL_WHITELIST = ['openshift', '${namespaceForFixtures}']; | ||
})(); | ||
`); | ||
let fixturesProject = {name: namespaceForFixtures}; | ||
let createProjectPage = new CreateProjectPage(fixturesProject); | ||
createProjectPage.visit(); | ||
createProjectPage.createProject(); | ||
let catalogPage = new CatalogPage(fixturesProject); | ||
// - add an image stream to that namespace | ||
catalogPage.visit(); | ||
catalogPage.processImageStream(JSON.stringify(centosImageStream)); | ||
// - add a template to that namespace | ||
catalogPage.visit(); | ||
catalogPage.saveTemplate(JSON.stringify(nodeMongoTemplate)); | ||
}; | ||
|
||
beforeAll(function() { | ||
h.commonSetup(); | ||
h.login(); | ||
projectHelpers.deleteAllProjects(); | ||
setupEnv(); | ||
}); | ||
|
||
afterAll(function() { | ||
projectHelpers.deleteAllProjects(); | ||
resetExtensions(); | ||
h.afterAllTeardown(); | ||
}); | ||
|
||
describe('create from URL', function() { | ||
|
||
describe('using an image stream and image stream tag supplied as query string params', function() { | ||
|
||
let name = 'nodejs-edited'; | ||
let sourceURI = 'https://github.com/openshift/nodejs-ex.git-edited'; | ||
let sourceRef = 'master-edited'; | ||
let contextDir = '/-edited'; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We can update the let qs = `?imageStream=nodejs&imageTag=4&name=${name}&sourceURI=${sourceURI}&sourceRef=${sourceRef}&contextDir=${contextDir}&namespace=${namespaceForFixtures}`;
let uri = `project/${project.name}create/fromimage${qs}`; There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Done. |
||
let qs = `?imageStream=nodejs&imageTag=4&name=${name}&sourceURI=${sourceURI}&sourceRef=${sourceRef}&contextDir=${contextDir}&namespace=${namespaceForFixtures}`; | ||
let uri = `project/${project.name}create/fromimage${qs}`; | ||
let heading = 'Node.js 4'; | ||
let words = project.name.split(' '); | ||
let timestamp = words[words.length - 1]; | ||
|
||
it('should display details about the the image', function() { | ||
let createFromURLPage = new CreateFromURLPage(); | ||
createFromURLPage.visit(qs); | ||
matchersHelpers.expectHeading(heading); | ||
}); | ||
|
||
it('should load the image stream in to a newly created project', function(){ | ||
let createFromURLPage = new CreateFromURLPage(); | ||
createFromURLPage.visit(qs); | ||
createFromURLPage.clickCreateNewProjectTab(); | ||
projectHelpers.createProject(project, 'project/' + project['name'] + 'create/fromimage' + qs); | ||
matchersHelpers.expectHeading(heading); | ||
projectHelpers.deleteProject(project); | ||
}); | ||
|
||
it('should load the image stream in to an existing project and verify the query string params are loaded in to the corresponding form fields', function(){ | ||
let createFromURLPage = new CreateFromURLPage(); | ||
projectHelpers.visitCreatePage(); | ||
projectHelpers.createProject(project); | ||
createFromURLPage.visit(qs); | ||
createFromURLPage.selectExistingProject(timestamp, uri); | ||
matchersHelpers.expectHeading(heading); | ||
let nameInput = element(by.model('name')); | ||
expect(nameInput.getAttribute('value')).toEqual(name); | ||
let sourceURIInput = element(by.model('buildConfig.sourceUrl')); | ||
expect(sourceURIInput.getAttribute('value')).toEqual(sourceURI); | ||
createFromURLPage.clickShowAdvanced(); | ||
let sourceRefInput = element(by.model('buildConfig.gitRef')); | ||
expect(sourceRefInput.getAttribute('value')).toEqual(sourceRef); | ||
let contextDirInput = element(by.model('buildConfig.contextDir')); | ||
expect(contextDirInput.getAttribute('value')).toEqual(contextDir); | ||
projectHelpers.deleteProject(project); | ||
}); | ||
|
||
}); | ||
|
||
describe('using a template supplied as a query string param', function() { | ||
|
||
let sourceURL = "https://github.com/openshift/nodejs-ex.git-edited"; | ||
let qs = '?template=nodejs-mongodb-example&templateParamsMap=%7B"SOURCE_REPOSITORY_URL":"' + sourceURL + '"%7D' + '&namespace=' + namespaceForFixtures; | ||
let uri = 'project/' + project.name + 'create/fromtemplate' + qs; | ||
let heading = 'Node.js + MongoDB (Ephemeral)'; | ||
let words = project.name.split(' '); | ||
let timestamp = words[words.length - 1]; | ||
|
||
it('should display details about the template', function() { | ||
let createFromURLPage = new CreateFromURLPage(); | ||
createFromURLPage.visit(qs); | ||
matchersHelpers.expectHeading(heading); | ||
}); | ||
|
||
it('should load the template in to a newly created project', function() { | ||
let createFromURLPage = new CreateFromURLPage(); | ||
createFromURLPage.visit(qs); | ||
createFromURLPage.clickCreateNewProjectTab(); | ||
projectHelpers.createProject(project, 'project/' + project['name'] + 'create/fromtemplate' + qs); | ||
matchersHelpers.expectHeading(heading); | ||
projectHelpers.deleteProject(project); | ||
}); | ||
|
||
it('should load the template in an existing project and verify the query string param sourceURL is loaded in to a corresponding form field', function(){ | ||
let createFromURLPage = new CreateFromURLPage(); | ||
projectHelpers.visitCreatePage(); | ||
projectHelpers.createProject(project); | ||
createFromURLPage.visit(qs); | ||
createFromURLPage.selectExistingProject(timestamp, uri); | ||
matchersHelpers.expectHeading(heading); | ||
inputsHelpers | ||
.findValueInInputs(element.all(by.model('parameter.value')), sourceURL) | ||
.then(function(found) { | ||
expect(found).toEqual(sourceURL); | ||
projectHelpers.deleteProject(project); | ||
}); | ||
}); | ||
|
||
}); | ||
|
||
describe('using a namespace that is not in the whitelist', function() { | ||
it('should display an error about the namespace', function() { | ||
let createFromURLPage = new CreateFromURLPage(); | ||
createFromURLPage.visit('?namespace=not-whitelisted'); | ||
matchersHelpers.expectAlert('Resources from the namespace "not-whitelisted" are not permitted.'); | ||
}); | ||
}); | ||
|
||
describe('using an unavailable image stream supplied as a query string param', function() { | ||
it('should display an error about the image stream', function() { | ||
let createFromURLPage = new CreateFromURLPage(); | ||
createFromURLPage.visit('?imageStream=unavailable-imageStream'); | ||
matchersHelpers.expectAlert('The requested image stream "unavailable-imageStream" could not be loaded.'); | ||
}); | ||
}); | ||
|
||
describe('using an unavailable image tag supplied as a query string param', function() { | ||
it('should display an error about the image tag', function() { | ||
let createFromURLPage = new CreateFromURLPage(); | ||
createFromURLPage.visit('?imageStream=nodejs&imageTag=unavailable-imageTag' + '&namespace=' + namespaceForFixtures); | ||
matchersHelpers.expectAlert('The requested image stream tag "unavailable-imageTag" could not be loaded.'); | ||
}); | ||
}); | ||
|
||
describe('using an unavailable template supplied as a query string param', function() { | ||
it('should display an error about the template', function() { | ||
let createFromURLPage = new CreateFromURLPage(); | ||
createFromURLPage.visit('?template=unavailable-template'); | ||
matchersHelpers.expectAlert('The requested template "unavailable-template" could not be loaded.'); | ||
}); | ||
}); | ||
|
||
describe('without using an image stream or a template', function() { | ||
it('should display an error about needing a resource', function() { | ||
let createFromURLPage = new CreateFromURLPage(); | ||
createFromURLPage.visit(''); | ||
matchersHelpers.expectAlert('An image stream or template is required.'); | ||
}); | ||
}); | ||
describe('using both an image stream and a template', function() { | ||
it('should display an error about combining resources', function() { | ||
let createFromURLPage = new CreateFromURLPage(); | ||
createFromURLPage.visit('?imageStream=nodejs&template=nodejs-mongodb-example' + '&namespace=' + namespaceForFixtures); | ||
matchersHelpers.expectAlert('Image streams and templates cannot be combined.'); | ||
}); | ||
}); | ||
describe('using an invalid app name as a query string param', function() { | ||
it('should display an error about the app name', function() { | ||
let createFromURLPage = new CreateFromURLPage(); | ||
createFromURLPage.visit('?name=InvalidAppName&imageStream=nodejs' + '&namespace=' + namespaceForFixtures); | ||
matchersHelpers.expectAlert('The app name "InvalidAppName" is not valid. An app name is an alphanumeric (a-z, and 0-9) string with a maximum length of 24 characters, where the first character is a letter (a-z), and the \'-\' character is allowed anywhere except the first or last character.'); | ||
}); | ||
}); | ||
|
||
}); | ||
|
||
}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd kind of like to be able to get rid of this comment and have something in code like:
But we can prob add that helper later as I bet we would want a few table helpers.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added a TODO so we're consistent with user_adds_template_to_project.spec.js
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nice