Skip to content

Commit

Permalink
fix(navigation) ionicHistory infinite loop when linking tabs #3932
Browse files Browse the repository at this point in the history
  • Loading branch information
Dan Bucholtz committed Apr 4, 2016
1 parent f54dbb9 commit efb9bdf
Show file tree
Hide file tree
Showing 5 changed files with 338 additions and 51 deletions.
7 changes: 6 additions & 1 deletion config/gulp-tasks/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,16 @@ var uuid = require('node-uuid');

var projectRoot = path.resolve(__dirname, '../..');

var karmaConf = require('../karma.conf.js');
var karmaSauceConf = require('../karma-sauce.conf.js');

module.exports = function(gulp, argv) {

var includeCodeCoverage = true;
if ( argv.skipCoverage ){
includeCodeCoverage = false;
}
var karmaConf = require('../karma.conf')(includeCodeCoverage);

/*
* Connect to Saucelabs
*/
Expand Down
95 changes: 50 additions & 45 deletions config/karma.conf.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
var buildConfig = require('./build.config.js');
var path = require('canonical-path');

module.exports = {
files: [
module.exports = function(includeCodeCoverage){
console.log("in the function");
var config = {};

config.files = [
// Include jQuery only for testing convience (lots of DOM checking for unit tests on directives)
'http://codeorigin.jquery.com/jquery-1.10.2.min.js',
'config/lib/js/angular/angular.js',
Expand All @@ -12,47 +15,49 @@ module.exports = {
'config/lib/js/angular-ui/angular-ui-router.js',
'config/lib/testutil.js'
]
.concat(buildConfig.ionicFiles)
.concat(buildConfig.angularIonicFiles)
.concat('test/unit/**/*.js'),

exclude: [
'js/ext/angular/test/dom-trace.js'
],
preprocessors: {
'js/**/*.js': 'coverage'
},
frameworks: ['jasmine'],
reporters: ['progress', 'coverage'],
port: 9876,
colors: true,
// possible values: 'OFF', 'ERROR', 'WARN', 'INFO', 'DEBUG'
logLevel: 'INFO',
autoWatch: true,
captureTimeout: 60000,
singleRun: false,
mochaReporter: {
.concat(buildConfig.ionicFiles)
.concat(buildConfig.angularIonicFiles)
.concat('test/unit/**/*.js');

config.exclude = ['js/ext/angular/test/dom-trace.js'];

config.frameworks = ['jasmine'];

config.reporters = ['progress'];

config.port = 9876;
config.colors = true;
config.logLevel = 'INFO';
config.autoWatch = true;
config.captureTimeout = 60000;
config.singleRun = false;
config.mochaReporter = {
output: 'full'
},
coverageReporter: {
reporters: [{
type: 'text'
}, {
type: 'text-summary'
}, {
type: 'cobertura',
file: 'coverage.xml'
}, {
type: 'lcov'
}]
},
// Start these browsers, currently available:
// - Chrome
// - ChromeCanary
// - Firefox
// - Opera (has to be installed with `npm install karma-opera-launcher`)
// - Safari (only Mac; has to be installed with `npm install karma-safari-launcher`)
// - PhantomJS
// - IE (only Windows; has to be installed with `npm install karma-ie-launcher`)
browsers: ['Chrome']
};
};

config.browsers = ['Chrome'];

if ( includeCodeCoverage ){
config.preprocessors = {'js/**/*.js': 'coverage'};
config.reporters.push('coverage');
config.coverageReporter = {
reporters: [
{
type: 'text'
},
{
type: 'text-summary'
},
{
type: 'cobertura',
file: 'coverage.xml'
},
{
type: 'lcov'
}
]
};
}

return config;
}
3 changes: 2 additions & 1 deletion js/angular/service/history.js
Original file line number Diff line number Diff line change
Expand Up @@ -325,6 +325,7 @@ function($rootScope, $state, $location, $window, $timeout, $ionicViewSwitcher, $
direction = DIRECTION_FORWARD;

} else if (currentView.historyId !== hist.historyId) {
// DB: this is a new view in a different tab
direction = DIRECTION_ENTER;

tmp = getHistoryById(currentView.historyId);
Expand Down Expand Up @@ -354,7 +355,7 @@ function($rootScope, $state, $location, $window, $timeout, $ionicViewSwitcher, $
viewId: viewId,
index: hist.stack.length,
historyId: hist.historyId,
backViewId: (currentView && currentView.viewId ? currentView.viewId : null),
backViewId: (currentView && currentView.viewId && (currentView.historyId === hist.historyId || currentView.historyId === hist.parentHistoryId) ? currentView.viewId : null),
forwardViewId: null,
stateId: currentStateId,
stateName: this.currentStateName(),
Expand Down
Loading

0 comments on commit efb9bdf

Please sign in to comment.