Skip to content

Update e2e test dependency updates & get them running on Mac #2083

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

18 changes: 10 additions & 8 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,14 +1,16 @@
language: node_js
node_js:
- "6"
before_install:
# virtual frame buffer for headless browsers
- export DISPLAY=:99.0
- sh -e /etc/init.d/xvfb start
- sleep 3 # give xvfb some time to start
before_script:
- make build
# FIXME:
# This needs to be enabled again when we eliminate PhantomJS for Firefox
# Even the unit tests require a browser
# - export DISPLAY=:99.0
# - sh -e /etc/init.d/xvfb start
# - sleep 3 # give xvfb some time to start
- make build
script:
- grunt test
- hack/verify-dist.sh
- grunt test-unit
# There is no server running in travis, therefore
# we cannot run the e2e tests.
# - grunt test-integration --browser=chrome
89 changes: 51 additions & 38 deletions Gruntfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,21 @@
var modRewrite = require('connect-modrewrite');
var serveStatic = require('serve-static');

var capitalize = (str) => {
return str.charAt(0).toUpperCase() + str.substr(1);
};

module.exports = function (grunt) {
var contextRoot = grunt.option('contextRoot') || "dev-console";
var isMac = /^darwin/.test(process.platform) || grunt.option('mac');

var specifiedUnitTestBrowsers = grunt.option('browsers') &&
grunt.option('browsers').split(',').map(capitalize);
// Travis & Jenkins expect Chrome
var defaultUnitTestBrowsers = isMac ? ['Firefox', 'Chrome'] : ['Chrome'];
var unitTestBrowsers = specifiedUnitTestBrowsers ?
specifiedUnitTestBrowsers :
defaultUnitTestBrowsers;
var integrationTestBrowser = grunt.option('browser') || 'chrome';

// Load grunt tasks automatically
require('load-grunt-tasks')(grunt, {
Expand Down Expand Up @@ -619,15 +630,7 @@ module.exports = function (grunt) {
// grunt test
// grunt test --browsers=Chrome
// grunt test --browsers=Chrome,Firefox,Safari (be sure karma-<browser_name>-launcher is installed)
browsers: grunt.option('browsers') ?
grunt.option('browsers').split(',') :
// if running locally on mac, we can test both FF & Chrome,
// in Travis, just FF
// ['Nightmare'] is a good alt for a current headless
// FIXME: fix this, PhantomJS is deprecated
isMac ?
['Firefox', 'Chrome'] :
['PhantomJS']
browsers: unitTestBrowsers
},
unit: {
singleRun: true,
Expand All @@ -641,24 +644,16 @@ module.exports = function (grunt) {
noColor: false,
args: {
suite: grunt.option('suite') || 'full',
baseUrl: grunt.option('baseUrl') || ("https://localhost:9000/" + contextRoot + "/")
baseUrl: grunt.option('baseUrl') || ("https://localhost:9000/" + contextRoot + "/"),
browser: integrationTestBrowser
}
},
default: {
options: {
configFile: "test/protractor.conf.js",
args: {
baseUrl: grunt.option('baseUrl') || ("https://localhost:9000/" + contextRoot + "/"),
browser: grunt.option('browser') || "firefox"
}
}
},
mac: {
options: {
configFile: "test/protractor-mac.conf.js",
args: {
baseUrl: grunt.option('baseUrl') || ("https://localhost:9000/" + contextRoot + "/"),
browser: grunt.option('browser') || "firefox"
browser: integrationTestBrowser
}
}
}
Expand Down Expand Up @@ -744,34 +739,52 @@ module.exports = function (grunt) {

grunt.loadNpmTasks('grunt-angular-templates');

// ex:
// grunt test-unit
// grunt test-unit --skipRebuild (to save time between test runs)
// karma must run prior to coverage since karma will generate the coverage results
grunt.registerTask('test-unit', [
'clean:server',
'concurrent:test',
'postcss',
'connect:test',
'karma'
// 'coverage' - add back if we want to enforce coverage percentages
]);

// test as an alias to unit. after updating protractor,
// will make test an alias for both unit & e2e
grunt.registerTask('test', ['test-unit']);
grunt.registerTask('test-unit',
grunt.option('skipRebuild') ?
[
'connect:test',
'karma'
] :
[
'clean:server',
'concurrent:test',
'postcss',
'connect:test',
'karma'
// 'coverage' - add back if we want to enforce coverage percentages
]
);

// ex:
// grunt test-integration
// grunt test-integration --baseUrl= (for build environments)
// grunt test-integration --skipRebuild (to save time between test runs)
// grunt test-integration --suite=login,create-project --skipRebuild (to run specific suites)
grunt.registerTask('test-integration',
// if a baseUrl is defined assume we dont want to run the local grunt server
grunt.option('baseUrl') ?
[isMac ? 'protractor:mac' : 'protractor:default'] :
( grunt.option('baseUrl') || grunt.option('skipRebuild') ) ?
[
'connect:test',
'protractor:default'
] :
[
'clean:server',
'development-build',
'postcss',
'connect:test',
'add-redirect-uri',
(isMac ? 'protractor:mac' : 'protractor:default'),
'protractor:default',
'clean:server'
]
);
);

// alias
grunt.registerTask('test-e2e', ['test-integration']);

grunt.registerTask('test', ['test-unit', 'test-integration']);

grunt.registerTask('build', [
'clean:dist',
Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,6 @@ build: install
# make test GRUNT_FLAGS='--gruntfile=~/special/Gruntfile.js'
test: build
hack/verify-dist.sh
hack/test-headless.sh test $(GRUNT_FLAGS)
hack/test-headless.sh test-unit $(GRUNT_FLAGS)
hack/test-headless.sh test-integration $(GRUNT_FLAGS)
.PHONY: test
11 changes: 7 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
"grunt-newer": "0.7.0",
"grunt-ng-annotate": "0.3.2",
"grunt-postcss": "^0.8.0",
"grunt-protractor-runner": "1.2.1",
"grunt-protractor-runner": "^5.0.0",
"grunt-replace": "1.0.1",
"grunt-svgmin": "4.0.0",
"grunt-usemin": "2.4.0",
Expand All @@ -42,7 +42,8 @@
"imagemin": "1.0.5",
"jasmine-beforeall": "0.1.1",
"jasmine-core": "^2.8.0",
"jasmine-spec-reporter": "1.1.2",
"jasmine-reporters": "^2.2.1",
"jasmine-spec-reporter": "4.2.1",
"jshint-stylish": "0.2.0",
"karma": "^1.7.1",
"karma-chrome-launcher": "^2.2.0",
Expand All @@ -57,7 +58,8 @@
"less": "2.6.1",
"load-grunt-tasks": "0.4.0",
"lodash": "3.10.1",
"protractor": "1.7.0",
"protractor": "^5.1.1",
"protractor-jasmine2-screenshot-reporter": "^0.4.1",
"protractor-screenshot-reporter": "^0.0.5",
"serve-static": "1.10.2",
"time-grunt": "0.3.2"
Expand All @@ -73,6 +75,7 @@
"serve": "grunt serve",
"start": "grunt serve",
"test-integration": "grunt test-integration",
"postinstall": "node test/upgrade-selenium.js && node_modules/protractor/bin/webdriver-manager update"
"postinstall": "node_modules/protractor/bin/webdriver-manager update",
"webdriver-status": "node_modules/protractor/bin/webdriver-manager status"
}
}
1 change: 1 addition & 0 deletions test/.jshintrc
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
"afterAll": false,
"angular": false,
"by": false,
"By": false,
"before": false,
"beforeAll": false,
"beforeEach": false,
Expand Down
77 changes: 0 additions & 77 deletions test/integration/e2e.js

This file was deleted.

5 changes: 5 additions & 0 deletions test/integration/environment.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
module.exports = {
baseUrl: 'https://localhost:9000/dev-console/',
loginUrl: 'https://127.0.0.1:8443/login',
isMac: /^darwin/.test(process.platform)
};
26 changes: 18 additions & 8 deletions test/integration/features/user_adds_imagestream_to_project.spec.js
Original file line number Diff line number Diff line change
@@ -1,22 +1,31 @@
'use strict';

const h = require('../helpers');
const common = require('../helpers/common');
const matchers = require('../helpers/matchers');
const projectHelpers = require('../helpers/project');
const CatalogPage = require('../page-objects/catalog').CatalogPage;

const CatalogPage = require('../page-objects/legacyCatalog').LegacyCatalogPage;
const CreateProjectPage = require('../page-objects/createProject').CreateProjectPage;
const ImageStreamsPage = require('../page-objects/imageStreams').ImageStreamsPage;

const centosImageStream = require('../fixtures/image-streams-centos7.json');

describe('User adds an image stream to a project', () => {

beforeAll(() => {
common.beforeAll();
});

beforeEach(() => {
h.commonSetup();
h.login();
projectHelpers.deleteAllProjects();
common.beforeEach();
});

afterEach(() => {
h.commonTeardown();
common.afterEach();
});

afterAll(() => {
common.afterAll();
});

describe('after creating a new project', () => {
Expand All @@ -31,10 +40,11 @@ describe('User adds an image stream to a project', () => {
catalogPage
.processImageStream(JSON.stringify(centosImageStream))
.then(() => {
// verify we have the nodejs image stream loaded
let imageStreamsPage = new ImageStreamsPage(project);
imageStreamsPage.visit();
expect(element(by.cssContainingText('td', 'nodejs')).isPresent()).toBe(true); // TODO: use fixture
// TODO: this is not a good test. The output logs will just say
// expected false to be true. Tests should be much more explicit.
matchers.expectElementToBeVisible(element(by.cssContainingText('td', 'nodejs')));
});
});
});
Expand Down
Loading