Skip to content
This repository has been archived by the owner on Oct 30, 2018. It is now read-only.

today's functional test fixes #617

Merged
merged 10 commits into from
Oct 11, 2012
9 changes: 8 additions & 1 deletion lib/app/autoload/action-context.common.js
Original file line number Diff line number Diff line change
Expand Up @@ -278,18 +278,25 @@ YUI.add('mojito-action-context', function(Y, NAME) {

var controller = opts.controller,
command = opts.command,
actionFunction = command.action,
actionFunction,
perf = Y.mojito.perf.timeline('mojito', 'ac:init', 'set up AC object', command),
error,
staticAppConfig = YUI.Env.mojito.DataProcess.retrieve('static-app-config') || {},
my;

my = this;

// It's possible to setup a route that calls "foo.", which means that
// the default action in the instance should be used instead.
if (!command.action) {
command.action = command.instance.action || 'index';
}

this.action = command.action;
this.type = command.instance.type;
this.context = command.context;
this.dispatcher = opts.dispatcher;
actionFunction = this.action;

// These should not be on the ac object
this.command = command;
Expand Down
26 changes: 16 additions & 10 deletions lib/app/autoload/dispatch.common.js
Original file line number Diff line number Diff line change
Expand Up @@ -88,18 +88,24 @@ YUI.add('mojito-dispatcher', function(Y, NAME) {

// Note that creation of an ActionContext current causes
// immediate invocation of the dispatch() call.
ac = new Y.mojito.ActionContext({
command: command,
controller: controller,
dispatcher: my, // NOTE passing dispatcher.
adapter: adapter,
store: store
});

try {
ac = new Y.mojito.ActionContext({
command: command,
controller: controller,
dispatcher: my, // NOTE passing dispatcher.
adapter: adapter,
store: store
});
} catch (e) {
Y.log('Error from dispatch on instance \'' +
(instance.id || '@' + instance.type) +
'\':', 'error', NAME);
Y.log(e.message, 'error', NAME);
Y.log(e.stack, 'error', NAME);
adapter.error(e);
}
perf.done(); // closing the 'ac:ctor' timeline

});

}

};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,6 @@ YUI.add('CM_Layout', function(Y, NAME) {

}, '0.0.1', {requires: [
'mojito',
'mojito-config-done',
'mojito-composite-done',
'mojito-config-addon',
'mojito-composite-addon',
'mojito-params-addon']});
Original file line number Diff line number Diff line change
Expand Up @@ -374,4 +374,5 @@ YUI.add('RESTLib', function(Y, NAME) {
'mojito',
'mojito-models-addon',
'mojito-http-addon',
'mojito-params-addon',
'RESTLibModel']});
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ YUI.add('CoverageModel', function(Y, NAME) {
* @class Model
* @constructor
*/
Y.mojito.models.default = {
Y.mojito.models[NAME] = {

init: function(mojitSpec) {
this.spec = mojitSpec;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ YUI.add('Flickr', function(Y, NAME) {
* @return {}
*/
index: function(ac) {
ac.models.get('flickrModel').getFlickrImages('mojito', function(images) {
ac.models.get('FlickrModel').getFlickrImages('mojito', function(images) {
ac.done({images: images});
});
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
/*
* Copyright (c) 2011 Yahoo! Inc. All rights reserved.
*/
YUI.add('FlickrModel', function(Y) {
YUI.add('FlickrModel', function(Y, NAME) {

/**
* The FlickrModel module.
*
* @module FlickrModel
*/

Y.mojito.models.flickrModel = {
Y.mojito.models[NAME] = {

/**
* Method that will be invoked by the mojit controller to obtain data.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ YUI.add('FlickrDetail', function(Y, NAME) {
return;
}

ac.models.get('flickrModel').getFlickrDetail(image, function(details) {
ac.models.get('FlickrDetailModelFlickr').getFlickrDetail(image, function(details) {
if (!details) {
ac.done({ type: 'error', message: ac.intl.lang('ERROR_NO_DETAILS') }, { name:'message' });
return;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/*
* Copyright (c) 2011 Yahoo! Inc. All rights reserved.
*/
YUI.add('FlickrDetailModelFlickr', function(Y) {
YUI.add('FlickrDetailModelFlickr', function(Y, NAME) {

/**
* The FlickrDetailModelFlickr module.
Expand All @@ -15,7 +15,7 @@ YUI.add('FlickrDetailModelFlickr', function(Y) {
* @class FlickrDetailModelFlickr
* @constructor
*/
Y.mojito.models.flickr = {
Y.mojito.models[NAME] = {

/**
* Method that will be invoked by the mojit controller to obtain data.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ YUI.add('PagedFlickr', function(Y, NAME) {
// parameter is base-0.
start = (page-1) * PAGESIZE;

ac.models.get('flickrModel').getFlickrImages('mojito', start, PAGESIZE, function(images) {
ac.models.get('PagedFlickrModel').getFlickrImages('mojito', start, PAGESIZE, function(images) {

var dateString = ac.intl.formatDate(new Date());
var data = {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
/*
* Copyright (c) 2011 Yahoo! Inc. All rights reserved.
*/
YUI.add('PagedFlickrModel', function(Y) {
YUI.add('PagedFlickrModel', function(Y, NAME) {

Y.mojito.models.flickrModel = {
Y.mojito.models[NAME] = {

getFlickrImages: function(queryString, start, count, callback) {
var APP_KEY = '84921e87fb8f2fc338c3ff9bf51a412e';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ YUI.add('PagedFlickr2', function(Y, NAME) {
// parameter is base-0.
start = (page-1) * PAGESIZE;

ac.models.get('flickrModel').getFlickrImages('mojito', start, PAGESIZE, function(images) {
ac.models.get('PagedFlickr2Model').getFlickrImages('mojito', start, PAGESIZE, function(images) {
var dateString = ac.intl.formatDate(new Date());
Y.log("config1 from controller----"+JSON.stringify(ac.config.get('config1')));
var data = {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
/*
* Copyright (c) 2011 Yahoo! Inc. All rights reserved.
*/
YUI.add('PagedFlickr2Model', function(Y) {
YUI.add('PagedFlickr2Model', function(Y, NAME) {

Y.mojito.models.flickrModel = {
Y.mojito.models[NAME] = {

getFlickrImages: function(queryString, start, count, callback) {
var APP_KEY = '84921e87fb8f2fc338c3ff9bf51a412e';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ YUI.add('PagedFlickr5', function(Y, NAME) {
// parameter is base-0.
start = (page-1) * PAGESIZE;

ac.models.get('flickrModel').getFlickrImages('mojito', start, PAGESIZE, function(images) {
ac.models.get('PagedFlickr5Model').getFlickrImages('mojito', start, PAGESIZE, function(images) {

var dateString = ac.intl.formatDate(new Date());
var data = {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/*
* Copyright (c) 2011 Yahoo! Inc. All rights reserved.
*/
YUI.add('PagedFlickr5Model', function(Y) {
YUI.add('PagedFlickr5Model', function(Y, NAME) {

/**
* The PagedFlickr5Model module.
Expand All @@ -15,7 +15,7 @@ YUI.add('PagedFlickr5Model', function(Y) {
* @class PagedFlickr5Model
* @constructor
*/
Y.mojito.models.flickr = {
Y.mojito.models[NAME] = {

/**
* Method that will be invoked by the mojit controller to obtain data.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ YUI.add('i18nMojit', function(Y, NAME) {
* to the Mojito API.
*/
index: function(ac) {
ac.models.get('i18nTest').getFlickrImages('mojito', function(images) {
ac.models.get('i18nMojitModel').getFlickrImages('mojito', function(images) {
var dateString = ac.intl.formatDate(new Date());
var tempStr = ac.intl.lang("TITLE");
console.log("*********************TITLE: " + tempStr);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ YUI.add('i18nMojitModel', function(Y, NAME) {
* @class Model
* @constructor
*/
Y.mojito.models.i18nTest = {
Y.mojito.models[NAME] = {

init: function(mojitSpec) {
this.spec = mojitSpec;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ YUI.add('i18n_Mojit', function(Y, NAME) {
},

index: function(ac) {
ac.models.get('i18nTest').getFlickrImages('mojito', function(images) {
ac.models.get('i18n_MojitModel').getFlickrImages('mojito', function(images) {
var dateString = ac.intl.formatDate(new Date());
var tempStr = ac.intl.lang("TITLE");
console.log("*********************TITLE: " + tempStr);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
YUI.add('i18n_MojitModel', function(Y, NAME) {


Y.mojito.models.i18nTest = {
Y.mojito.models[NAME] = {

init: function(mojitSpec) {
this.spec = mojitSpec;
Expand Down
27 changes: 13 additions & 14 deletions tests/func/routing/testbasicroutingneg1.js
Original file line number Diff line number Diff line change
@@ -1,21 +1,20 @@
/*
* This is a basic func test for a Routing application.
*/
YUI({
useConsoleOutput: true,
useBrowserConsole: true,
logInclude: { TestRunner: true }
}).use('node', 'node-event-simulate', 'test', function (Y) {
YUI({
useConsoleOutput: true,
useBrowserConsole: true,
logInclude: { TestRunner: true }
}).use('node', 'node-event-simulate', 'test', function (Y) {

var suite = new Y.Test.Suite("Routing: BasicRoutingNeg3");
var suite = new Y.Test.Suite("Routing: BasicRoutingNeg1");

suite.add(new Y.Test.Case({
"test BasicRoutingNeg3": function(){
Y.Assert.areEqual("Error: 404", Y.one('h1').get("innerHTML"));
Y.Assert.areEqual("Error details are not available.", Y.one('p').get("innerHTML"));
}
}));
suite.add(new Y.Test.Case({
"test BasicRoutingNeg1": function(){
Y.Assert.areEqual("Error: 404", Y.one('h1').get("innerHTML"));
Y.Assert.areEqual("Error details are not available.", Y.one('p').get("innerHTML"));
}
}));

Y.Test.Runner.add(suite);
});

});
25 changes: 12 additions & 13 deletions tests/func/routing/testbasicroutingneg2.js
Original file line number Diff line number Diff line change
@@ -1,20 +1,19 @@
/*
* This is a basic func test for a Routing application.
*/
YUI({
useConsoleOutput: true,
useBrowserConsole: true,
logInclude: { TestRunner: true }
}).use('node', 'node-event-simulate', 'test', function (Y) {
YUI({
useConsoleOutput: true,
useBrowserConsole: true,
logInclude: { TestRunner: true }
}).use('node', 'node-event-simulate', 'test', function (Y) {

var suite = new Y.Test.Suite("Routing: BasicRoutingNeg3");
var suite = new Y.Test.Suite("Routing: BasicRoutingNeg2");

suite.add(new Y.Test.Case({
"test BasicRoutingNeg3": function(){
Y.Assert.areEqual("Cannot GET /complete/invalid/path", Y.one('pre').get('innerHTML'));
}
}));
suite.add(new Y.Test.Case({
"test BasicRoutingNeg2": function(){
Y.Assert.areEqual("Cannot GET /complete/invalid/path", Y.one('pre').get('innerHTML'));
}
}));

Y.Test.Runner.add(suite);
});

});
27 changes: 13 additions & 14 deletions tests/func/routing/testbasicroutingneg3.js
Original file line number Diff line number Diff line change
@@ -1,21 +1,20 @@
/*
* This is a basic func test for a Routing application.
*/
YUI({
useConsoleOutput: true,
useBrowserConsole: true,
logInclude: { TestRunner: true }
}).use('node', 'node-event-simulate', 'test', function (Y) {
YUI({
useConsoleOutput: true,
useBrowserConsole: true,
logInclude: { TestRunner: true }
}).use('node', 'node-event-simulate', 'test', function (Y) {

var suite = new Y.Test.Suite("Routing: BasicRoutingNeg3");
var suite = new Y.Test.Suite("Routing: BasicRoutingNeg3");

suite.add(new Y.Test.Case({
"test BasicRoutingNeg3": function(){
Y.Assert.areEqual("Click to execute the action 'route-2' for the mojit 'nothing'", Y.one('#mylink').get('innerHTML'));
Y.Assert.areEqual("/route-2/nothing", Y.one('#mylink').getAttribute("href"));
}
}));
suite.add(new Y.Test.Case({
"test BasicRoutingNeg3": function(){
Y.Assert.areEqual("Click to execute the action 'route-2' for the mojit 'nothing'", Y.one('#mylink').get('innerHTML'));
Y.Assert.areEqual("/route-2/nothing", Y.one('#mylink').getAttribute("href"));
}
}));

Y.Test.Runner.add(suite);
});

});
6 changes: 3 additions & 3 deletions tests/func/serveronly/serveronlytest_descriptor.json
Original file line number Diff line number Diff line change
Expand Up @@ -466,21 +466,21 @@
"page" : "$$config.baseUrl$$/inst0"
}
},
"multiaction2" : {
"bz5300267-multiaction2" : {
"group" : "smoke,restlib,serveronly",
"params" : {
"test" : "testMultiActions2.js",
"page" : "$$config.baseUrl$$/inst1"
}
},
"multiaction3" : {
"bz5300267-multiaction3" : {
"group" : "smoke,restlib,serveronly",
"params" : {
"test" : "testMultiActions3.js",
"page" : "$$config.baseUrl$$/inst01"
}
},
"multiaction4" : {
"bz5300267-multiaction4" : {
"group" : "smoke,restlib,serveronly",
"params" : {
"test" : "testMultiActions4.js",
Expand Down
4 changes: 2 additions & 2 deletions tests/func/serveronly/testMultiActions1.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@ YUI({
logInclude: { TestRunner: true }
}).use('node', 'node-event-simulate', 'test', 'console', function (Y) {

var suite = new Y.Test.Suite("ServerOnly: multiaction");
var suite = new Y.Test.Suite("ServerOnly: multiaction1");

suite.add(new Y.Test.Case({
"test multiaction": function(){
"test multiaction1": function(){
Y.Assert.areEqual('Index', Y.all('h3').item(0).get('innerHTML'));
Y.Assert.areEqual('hello from index', Y.all('h3').item(1).get('innerHTML'));
}
Expand Down
4 changes: 2 additions & 2 deletions tests/func/serveronly/testMultiActions2.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@ YUI({
logInclude: { TestRunner: true }
}).use('node', 'node-event-simulate', 'test', 'console', function (Y) {

var suite = new Y.Test.Suite("ServerOnly: bz5300267");
var suite = new Y.Test.Suite("ServerOnly: bz5300267 multiaction2");

suite.add(new Y.Test.Case({
"test bz5300267": function(){
"test bz5300267 multiaction2": function(){
Y.Assert.areEqual('Inst1', Y.all('h3').item(0).get('innerHTML'));
Y.Assert.areEqual('hello from inst1', Y.all('h3').item(1).get('innerHTML'));
}
Expand Down
Loading