diff --git a/.travis.yml b/.travis.yml index 70dd0b55974ac0b0c620b6447a5f931c951a3fde..0c8e1be05850d667d2ec5c7d9e3c834dc177b93f 100644 --- a/.travis.yml +++ b/.travis.yml @@ -52,3 +52,4 @@ before_script: # This simplifies initial set up and provides a very consistent build and test environment. - docker pull golang:1.4 script: ./node_modules/.bin/gulp check:create-cluster +after_script: ./node_modules/.bin/gulp coverage-codecov-upload diff --git a/build/conf.js b/build/conf.js index aa42b198c0daccf37af1b629a8d9aef54956b77d..3fc0b2cdbf0520c0557f0bf6572d962872014948 100644 --- a/build/conf.js +++ b/build/conf.js @@ -85,6 +85,7 @@ export default { backendTmpSrc: path.join(basePath, '.tmp/backend/src/github.com/kubernetes/dashboard'), bowerComponents: path.join(basePath, 'bower_components'), build: path.join(basePath, 'build'), + coverageReport: path.join(basePath, 'coverage/lcov'), deploySrc: path.join(basePath, 'src/app/deploy'), dist: path.join(basePath, 'dist'), distPublic: path.join(basePath, 'dist/public'), diff --git a/build/karma.conf.js b/build/karma.conf.js index 598e38478cdb76a9e00fc8de094578e946333fb2..65f824ffeb9521e45d2b545fea6d29c3e3e697e0 100644 --- a/build/karma.conf.js +++ b/build/karma.conf.js @@ -68,13 +68,22 @@ module.exports = function(config) { }, }, - reporters: ['progress'], + reporters: ['progress', 'coverage'], + + coverageReporter: { + dir: 'coverage/', + reporters: [ + {type: 'html', subdir: 'html'}, + {type: 'lcovonly', subdir: 'lcov'}, + ], + }, preprocessors: {}, // This field is filled with values later. plugins: [ 'karma-chrome-launcher', 'karma-jasmine', + 'karma-coverage', 'karma-ng-html2js-preprocessor', 'karma-sourcemap-loader', 'karma-browserify', @@ -87,6 +96,9 @@ module.exports = function(config) { // Make 'import ...' statements relative to the following paths. paths: [conf.paths.frontendSrc, conf.paths.frontendTest], transform: [ + // Browserify transform for the istanbul code coverage tool. Isparta istrumenter for ES6 + // code coverage. TODO(floreks): try to make import work instead of require + ['browserify-istanbul', {'instrumenter': require('isparta')}], // Transform ES6 code into ES5 so that browsers can digest it. ['babelify', {'presets': ['es2015']}], ], diff --git a/build/test.js b/build/test.js index 4a47b90676eb57c9ebb59080a9d00926c1f1fa89..2a6d214ae5016f63446530c773a4414049f1fb18 100644 --- a/build/test.js +++ b/build/test.js @@ -15,6 +15,7 @@ /** * @fileoverview Gulp tasks for unit and integration tests. */ +import codecov from 'gulp-codecov.io'; import gulp from 'gulp'; import gulpProtractor from 'gulp-protractor'; import karma from 'karma'; @@ -71,6 +72,16 @@ function runProtractorTests(doneFn) { */ gulp.task('test', ['frontend-test', 'backend-test']); +/** + * Execute gulp-codecov task and uploads generated + * coverage report to http://codecov.io. Should be used only + * by external CI tools, as gulp-codecov plugin is already designed to work + * with them. Does not work locally. + */ +gulp.task('coverage-codecov-upload', function() { + gulp.src(path.join(conf.paths.coverageReport, 'lcov.info')).pipe(codecov()); +}); + /** * Runs once all unit tests of the frontend application. */ diff --git a/package.json b/package.json index 10c885dcb3ac5ba2d25218bd4ba9fc413a30aad1..5910c7a3a084236fe2b3eb431771aadf397b4374 100644 --- a/package.json +++ b/package.json @@ -17,6 +17,8 @@ "browser-sync": "~2.10.0", "browser-sync-spa": "~1.0.2", "browserify": "~12.0.1", + "browserify-istanbul": "~0.2.1", + "gulp-codecov.io": "~1.0.1", "del": "~2.2.0", "eslint-plugin-angular": "~0.15.0", "google-closure-compiler": "~20151216.0.0", @@ -51,6 +53,7 @@ "gulp-useref": "~3.0.3", "gulp-util": "~3.0.6", "gulp-watch": "~4.3.5", + "isparta": "~4.0.0", "karma": "~0.13.9", "karma-browserify": "~4.4.0", "karma-chrome-launcher": "~0.2.0", diff --git a/src/app/frontend/chrome/chrome.html b/src/app/frontend/chrome/chrome.html index 303843d2fb7fd88bbb479a2ebedec630bd80c8a4..faf1a9f48ceec4841b1b35126015abeabcad8ae4 100644 --- a/src/app/frontend/chrome/chrome.html +++ b/src/app/frontend/chrome/chrome.html @@ -24,9 +24,6 @@ limitations under the License. kubernetes - - more_vert -
diff --git a/src/app/frontend/index_config.js b/src/app/frontend/index_config.js index be2080247c05a2c9c628a9940ed16d1b610f2d71..c202886db7e07ef286440c701b63b7f3624efd25 100644 --- a/src/app/frontend/index_config.js +++ b/src/app/frontend/index_config.js @@ -19,15 +19,11 @@ export default function config($mdThemingProvider) { // Create a color palette that uses Kubernetes colors. let kubernetesColorPaletteName = 'kubernetesColorPalette'; - let kubernetesAccentPaletteName = 'kubernetesAccentPallete'; let kubernetesColorPalette = $mdThemingProvider.extendPalette('blue', { '500': '326de6', }); // Use the palette as default one. $mdThemingProvider.definePalette(kubernetesColorPaletteName, kubernetesColorPalette); - $mdThemingProvider.definePalette(kubernetesAccentPaletteName, kubernetesColorPalette); - $mdThemingProvider.theme('default') - .primaryPalette(kubernetesColorPaletteName) - .accentPalette(kubernetesAccentPaletteName); + $mdThemingProvider.theme('default').primaryPalette(kubernetesColorPaletteName); } diff --git a/src/app/frontend/replicasetlist/replicasetcard.scss b/src/app/frontend/replicasetlist/replicasetcard.scss index a39270affba05b5c5980ab4a8d8e20d6e8a64f07..5277ef0f868d3a18c36fc235ca56ce429947387f 100644 --- a/src/app/frontend/replicasetlist/replicasetcard.scss +++ b/src/app/frontend/replicasetlist/replicasetcard.scss @@ -1,16 +1,16 @@ -// Copyright 2015 Google Inc. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +// Copyright 2015 Google Inc. All Rights Reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. @import '../../assets/styles/color_variables'; diff --git a/src/app/frontend/replicasetlist/replicasetlist.html b/src/app/frontend/replicasetlist/replicasetlist.html index 136a0fd4fa1f02505c7476ecb0611dfbca69a70d..7e4ac7cb7e402a3893f5959f0f834a8d6b08119c 100644 --- a/src/app/frontend/replicasetlist/replicasetlist.html +++ b/src/app/frontend/replicasetlist/replicasetlist.html @@ -14,6 +14,10 @@ See the License for the specific language governing permissions and limitations under the License. --> + + add + +
diff --git a/src/app/frontend/replicasetlist/replicasetlist.scss b/src/app/frontend/replicasetlist/replicasetlist.scss new file mode 100644 index 0000000000000000000000000000000000000000..741145cd5a441103b3f630ca2c4b72538fe7c8b2 --- /dev/null +++ b/src/app/frontend/replicasetlist/replicasetlist.scss @@ -0,0 +1,21 @@ +// Copyright 2015 Google Inc. All Rights Reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +.md-fab { + &.kd-replicaset-deploy { + position: absolute; + right: 5px; + top: 28px; + } +} diff --git a/src/app/frontend/replicasetlist/replicasetlist_controller.js b/src/app/frontend/replicasetlist/replicasetlist_controller.js index 5f52669348f5bf241feb693425a09a2eba7be1ce..fd44b7be25faa989464ebb2358c5184ee710290f 100644 --- a/src/app/frontend/replicasetlist/replicasetlist_controller.js +++ b/src/app/frontend/replicasetlist/replicasetlist_controller.js @@ -19,11 +19,21 @@ */ export default class ReplicaSetListController { /** + * @param {!ui.router.$state} $state * @param {!backendApi.ReplicaSetList} replicaSets * @ngInject */ - constructor(replicaSets) { + constructor($state, replicaSets) { /** @export {!Array} */ this.replicaSets = replicaSets.replicaSets; + + /** @private {!ui.router.$state} */ + this.state_ = $state; } + + /** + * TODO(floreks): Should be changed to state variable. Related issue #153. + * @export + */ + redirectToDeployPage() { this.state_.go('deploy'); } } diff --git a/src/test/frontend/replicasetdetail/updatereplicas_controller_test.js b/src/test/frontend/replicasetdetail/updatereplicas_controller_test.js index dfe9bd8e89355fc0494bc71ca51420c99541070c..2918f68d15ef981d3f3e0ae9378c0ff6cd976e80 100644 --- a/src/test/frontend/replicasetdetail/updatereplicas_controller_test.js +++ b/src/test/frontend/replicasetdetail/updatereplicas_controller_test.js @@ -82,4 +82,15 @@ describe('Replica Set Detail controller', () => { expect(log.error).toHaveBeenCalled(); expect(mdDialog.hide).toHaveBeenCalled(); }); + + it('should close the dialog on cancel', () => { + // given + spyOn(mdDialog, 'cancel'); + + // when + ctrl.cancel(); + + // then + expect(mdDialog.cancel).toHaveBeenCalled(); + }); }); diff --git a/src/test/frontend/replicasetlist/replicasetlist_controller_test.js b/src/test/frontend/replicasetlist/replicasetlist_controller_test.js new file mode 100644 index 0000000000000000000000000000000000000000..fcb6f1e6fb8ca5c6d0915ef543efdb93d31fe85e --- /dev/null +++ b/src/test/frontend/replicasetlist/replicasetlist_controller_test.js @@ -0,0 +1,45 @@ +// Copyright 2015 Google Inc. All Rights Reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +import ReplicaSetListController from 'replicasetlist/replicasetlist_controller'; +import replicaSetListModule from 'replicasetlist/replicasetlist_module'; + +describe('Replica set list controller', () => { + /** + * @type {!ReplicaSetListController} + */ + let ctrl; + /** @type {!ui.router.$state} */ + let state; + + beforeEach(() => { + angular.mock.module(replicaSetListModule.name); + + angular.mock.inject(($controller, $state) => { + state = $state; + ctrl = $controller(ReplicaSetListController, {replicaSets: {replicaSets: []}}); + }); + }); + + it('should change state to deploy view on plus button click', () => { + // given + spyOn(state, 'go'); + + // when + ctrl.redirectToDeployPage(); + + // then + expect(state.go).toHaveBeenCalledWith('deploy'); + }); +});