Skip to content

Commit

Permalink
IF-929: SubformRows error
Browse files Browse the repository at this point in the history
  • Loading branch information
spastai committed May 27, 2015
1 parent a2447d2 commit 1363f4c
Show file tree
Hide file tree
Showing 18 changed files with 187 additions and 79 deletions.
1 change: 1 addition & 0 deletions .meteor/.finished-upgraders
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,4 @@
notices-for-0.9.0
notices-for-0.9.1
0.9.4-platform-file
notices-for-facebook-graph-api-2
4 changes: 1 addition & 3 deletions .meteor/packages
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,8 @@
# but you can also edit it by hand.

meteor-platform
autopublish
insecure
spastai:form-frame
coffeescript
iron:router
mike:mocha

iron:router
2 changes: 1 addition & 1 deletion .meteor/release
Original file line number Diff line number Diff line change
@@ -1 +1 @@
METEOR@0.9.3
METEOR@1.1.0.2
132 changes: 70 additions & 62 deletions .meteor/versions
Original file line number Diff line number Diff line change
@@ -1,64 +1,72 @@
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
iron:[email protected]
iron:[email protected]
iron:[email protected]
iron:[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
mike:[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
iron:[email protected]
iron:[email protected]
iron:[email protected]
iron:[email protected]
iron:[email protected]
iron:[email protected]
iron:[email protected]
iron:[email protected]
[email protected]_2
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
mike:[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
practicalmeteor:[email protected]_3
practicalmeteor:[email protected]_3
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
sanjo:[email protected]
sanjo:[email protected]_4
sanjo:[email protected]
[email protected]
[email protected]
[email protected]
spastai:[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
velocity:[email protected]
velocity:[email protected]
velocity:[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
velocity:[email protected]_1
velocity:[email protected]
velocity:[email protected]
velocity:[email protected]_7
velocity:[email protected]
[email protected]
[email protected]
7 changes: 6 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,13 @@ forms-frame

Testing
-------------
1. UI tests
meteor add mike:mocha
run meteor and check mocha dot
2. Execute
meteor test-packages

3. To test cucumber (user testing)
meteor add xolvio:cucumber

Create fields
-------------
Expand Down
13 changes: 12 additions & 1 deletion packages/spastai:form-frame/fieldSubformRows.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
Template.fieldSubformrows.created = function() {
self = this;
this.data.dep = new Deps.Dependency;
this.data.setResult && this.data.setResult(this.data.value);
this.data.getResult = function() {
return self.data.result;
}
}

// Adding Id's to the rows
Expand All @@ -11,6 +15,13 @@ Template.fieldSubformrows.helpers({
item._id = new Mongo.ObjectID();
});
return this.result;

/*
_(this.result).map(function(item){
// create copy array of items to keep result var unaffected
_({_id:new Mongo.ObjectID()}).extend(item);
});
*/
},

cell: function() {
Expand All @@ -24,7 +35,7 @@ Template.fieldSubformrows.helpers({
Template.fieldSubformrows.events({
'click .addRow': function (event, template) {
var values = getFormValues(this.form, template);
//d("Subform values:", values);
//console.log({m:"Adding Subform values: "+JSON.stringify(values), v:values, f:this.form});
if(!this.result) this.result = [];
this.result.push(values)
this.setResult && this.setResult(this.result);
Expand Down
11 changes: 6 additions & 5 deletions packages/spastai:form-frame/helpers.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,14 @@ getFormValues = (form, template) ->
console.log s:"Fetching values from DOM and form variable:", v:_.map form, (item)->
_.omit(item, 'dep')
###
#console.log({m:"Get form values start "+ JSON.stringify(result)});
for f of form
id = form[f].field
element = template.find("#" + id)
result[id] = if form[f].getResult
form[f].getResult()
if form[f].getResult
result[id] = form[f].getResult()
else
$(element).val()

#console.dir(result);
result[id] = $(element).val()
#console.log({m:"Getting form field #{id}=#{result[id]} "+JSON.stringify(result)})
#console.log({m:"Get form values result "+JSON.stringify(result), r:result});
result
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
10 changes: 10 additions & 0 deletions tests/cucumber/features/formsFrame.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
Feature: Form provides ability to input data
As a editor
I want to enter data into form
So that I can save this data

@dev
Scenario: Open blank Form, keep unchanged, save
Given I see the blank form
When I press "save"
Then I see default values
28 changes: 28 additions & 0 deletions tests/cucumber/features/sample.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
Feature: One-liner description of this feature

As a [role]
I want [feature]
So that [benefit]

The story above is to set context for the reader. It doesn't actually have any impact on the test
itself. The phrases inside the scenarios are ties to test code using regex, which you can see in
/tests/features/step_definitions/steps.js

In this textual part of the file, you can include context about this feature, you can add links to
external documents and whatever is needed to create the full specification.

# The background will be run for every scenario
Background:
Given I am a new user

# This scenario will run as part of the Meteor dev cycle because it has the @dev tag
@dev
Scenario:
When I navigate to "/"
Then I should see the title "FormsFrame"

# This scenario will not run as part of the Meteor dev cycle because it does not have the @dev tag
# But it will run on CI if you use `meteor --test` for instance
Scenario:
When I navigate to "/"
Then I should see the title "another intentional failure"
31 changes: 31 additions & 0 deletions tests/cucumber/features/step_definitions/sample_steps.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
(function () {

'use strict';

module.exports = function () {

// You can use normal require here, cucumber is NOT run in a Meteor context (by design)
var url = require('url');

this.Given(/^I am a new user$/, function () {
// no callbacks! DDP has been promisified so you can just return it
return this.server.call('reset'); // this.ddp is a connection to the mirror
});

this.When(/^I navigate to "([^"]*)"$/, function (relativePath, callback) {
// WebdriverIO supports Promises/A+ out the box, so you can return that too
this.client. // this.browser is a pre-configured WebdriverIO + PhantomJS instance
url(url.resolve(process.env.ROOT_URL, relativePath)). // process.env.ROOT_URL always points to the mirror
call(callback);
});

this.Then(/^I should see the title "([^"]*)"$/, function (expectedTitle, callback) {
// you can use chai-as-promised in step definitions also
this.client.
waitForVisible('body *'). // WebdriverIO chain-able promise magic
getTitle().should.become(expectedTitle).and.notify(callback);
});

};

})();
13 changes: 13 additions & 0 deletions tests/cucumber/fixtures/my_fixture.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
(function () {

'use strict';

Meteor.methods({
'reset' : function() {
// you can do some resetting of your app here
// fixture code will only execute inside mirrors neither runs
// inside the main app nor gets bundled to production.
}
});

})();
7 changes: 4 additions & 3 deletions tests/jasmine/client/FormSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,12 @@ describe("Tutorials template", function() {
var div = document.createElement("DIV");
var data = {tutorials: [{}, {}]};
data.tutorials.count = function() { return 2; }


console.log("Render with data");
var comp = Blaze.renderWithData(Template.tutorials, data);

Blaze.insert(comp, div);

expect($(div).find(".tutorialLine").length).toEqual(2);
});
});
7 changes: 4 additions & 3 deletions tests/mocha/client/bug3SubFormRows.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,16 @@ unless typeof MochaWeb is "undefined"
Tracker.flush();

# subformRows
$("#field").val("SomeValue");
$("#field").val("SubFormTestValue");

$(".addRow").click();

$("#save").click();

#console.dir(["Checkbox found:", $("#check")]);
values = Session.get("values");
console.log(["Test SubformRows values:", values]);
#chai.assert.equal(v)
#console.log({m:"Test SubformRows values:", v:values});
chai.assert.isUndefined(values.form[0]._id)

# Forse form re-rendering and setResults setting
Router.go('Blank');
Expand Down

0 comments on commit 1363f4c

Please sign in to comment.