diff --git a/.meteor/.finished-upgraders b/.meteor/.finished-upgraders index 68df3d8..8a76103 100644 --- a/.meteor/.finished-upgraders +++ b/.meteor/.finished-upgraders @@ -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 diff --git a/.meteor/packages b/.meteor/packages index b49d336..dfad6e6 100644 --- a/.meteor/packages +++ b/.meteor/packages @@ -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 diff --git a/.meteor/release b/.meteor/release index 7b32bf7..dab6b55 100644 --- a/.meteor/release +++ b/.meteor/release @@ -1 +1 @@ -METEOR@0.9.3 +METEOR@1.1.0.2 diff --git a/.meteor/versions b/.meteor/versions index d3682f9..1f5a871 100644 --- a/.meteor/versions +++ b/.meteor/versions @@ -1,64 +1,72 @@ amplify@1.0.0 -application-configuration@1.0.2 -autopublish@1.0.0 -autoupdate@1.1.1 -base64@1.0.0 -binary-heap@1.0.0 -blaze-tools@1.0.0 -blaze@2.0.1 -boilerplate-generator@1.0.0 -callback-hook@1.0.0 -check@1.0.1 -coffeescript@1.0.3 -ctl-helper@1.0.3 -ctl@1.0.1 -ddp@1.0.9 -deps@1.0.4 -ejson@1.0.3 -fastclick@1.0.0 -follower-livedata@1.0.1 -geojson-utils@1.0.0 -handlebars@1.0.0 -html-tools@1.0.1 -htmljs@1.0.1 -http@1.0.6 -id-map@1.0.0 -insecure@1.0.0 -iron:core@0.3.4 -iron:dynamic-template@0.4.1 -iron:layout@0.4.1 -iron:router@0.9.4 -jquery@1.0.0 -json@1.0.0 -less@1.0.9 -livedata@1.0.10 -logging@1.0.3 -meteor-platform@1.1.1 -meteor@1.1.1 -mike:mocha@0.3.14 -minifiers@1.1.0 -minimongo@1.0.3 -mobile-status-bar@1.0.0 -mongo@1.0.6 -observe-sequence@1.0.2 -ordered-dict@1.0.0 -random@1.0.0 -reactive-dict@1.0.3 -reactive-var@1.0.2 -reload@1.1.0 -retry@1.0.0 -routepolicy@1.0.1 -session@1.0.2 -spacebars-compiler@1.0.2 -spacebars@1.0.2 +autoupdate@1.2.1 +base64@1.0.3 +binary-heap@1.0.3 +blaze@2.1.2 +blaze-tools@1.0.3 +boilerplate-generator@1.0.3 +callback-hook@1.0.3 +check@1.0.5 +coffeescript@1.0.6 +ddp@1.1.0 +deps@1.0.7 +ejson@1.0.6 +fastclick@1.0.3 +geojson-utils@1.0.3 +handlebars@1.0.3 +html-tools@1.0.4 +htmljs@1.0.4 +http@1.1.0 +id-map@1.0.3 +insecure@1.0.3 +iron:controller@1.0.7 +iron:core@1.0.7 +iron:dynamic-template@1.0.7 +iron:layout@1.0.7 +iron:location@1.0.7 +iron:middleware-stack@1.0.7 +iron:router@1.0.7 +iron:url@1.0.7 +jquery@1.11.3_2 +json@1.0.3 +launch-screen@1.0.2 +less@1.0.14 +livedata@1.0.13 +logging@1.0.7 +meteor@1.1.6 +meteor-platform@1.2.2 +mike:mocha@0.5.4 +minifiers@1.1.5 +minimongo@1.0.8 +mobile-status-bar@1.0.3 +mongo@1.1.0 +observe-sequence@1.0.6 +ordered-dict@1.0.3 +package-version-parser@3.0.3 +practicalmeteor:chai@1.9.2_3 +practicalmeteor:loglevel@1.1.0_3 +random@1.0.3 +reactive-dict@1.1.0 +reactive-var@1.0.5 +reload@1.1.3 +retry@1.0.3 +routepolicy@1.0.5 +sanjo:long-running-child-process@1.0.3 +sanjo:meteor-files-helpers@1.1.0_4 +sanjo:meteor-version@1.0.0 +session@1.1.0 +spacebars@1.0.6 +spacebars-compiler@1.0.6 spastai:form-frame@0.0.11 -templating@1.0.7 -tracker@1.0.2 -ui@1.0.3 -underscore@1.0.0 -url@1.0.0 -velocity:core@0.2.14 -velocity:html-reporter@0.2.3 -velocity:shim@0.0.1 -webapp-hashing@1.0.0 -webapp@1.1.2 +templating@1.1.1 +tracker@1.0.7 +ui@1.0.6 +underscore@1.0.3 +url@1.0.4 +velocity:chokidar@0.12.6_1 +velocity:core@0.6.1 +velocity:html-reporter@0.5.3 +velocity:meteor-internals@1.1.0_7 +velocity:shim@0.1.0 +webapp@1.2.0 +webapp-hashing@1.0.3 diff --git a/README.md b/README.md index c2a4ee3..9d963dd 100644 --- a/README.md +++ b/README.md @@ -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 ------------- diff --git a/packages/spastai:form-frame/fieldSubformRows.js b/packages/spastai:form-frame/fieldSubformRows.js index ee278d7..b866847 100644 --- a/packages/spastai:form-frame/fieldSubformRows.js +++ b/packages/spastai:form-frame/fieldSubformRows.js @@ -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 @@ -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() { @@ -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); diff --git a/packages/spastai:form-frame/helpers.coffee b/packages/spastai:form-frame/helpers.coffee index b80f80c..8c6fac7 100644 --- a/packages/spastai:form-frame/helpers.coffee +++ b/packages/spastai:form-frame/helpers.coffee @@ -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 diff --git a/tests/cucumber/.screenshots/0-step_failed_1432362143851.png b/tests/cucumber/.screenshots/0-step_failed_1432362143851.png new file mode 100644 index 0000000..0104648 Binary files /dev/null and b/tests/cucumber/.screenshots/0-step_failed_1432362143851.png differ diff --git a/tests/cucumber/.screenshots/0-step_failed_1432362147490.png b/tests/cucumber/.screenshots/0-step_failed_1432362147490.png new file mode 100644 index 0000000..0104648 Binary files /dev/null and b/tests/cucumber/.screenshots/0-step_failed_1432362147490.png differ diff --git a/tests/cucumber/.screenshots/0-step_failed_1432364115963.png b/tests/cucumber/.screenshots/0-step_failed_1432364115963.png new file mode 100644 index 0000000..f1a5a88 Binary files /dev/null and b/tests/cucumber/.screenshots/0-step_failed_1432364115963.png differ diff --git a/tests/cucumber/.screenshots/1-step_failed_1432364116165.png b/tests/cucumber/.screenshots/1-step_failed_1432364116165.png new file mode 100644 index 0000000..f1a5a88 Binary files /dev/null and b/tests/cucumber/.screenshots/1-step_failed_1432364116165.png differ diff --git a/tests/cucumber/.screenshots/2-step_failed_1432364116363.png b/tests/cucumber/.screenshots/2-step_failed_1432364116363.png new file mode 100644 index 0000000..f1a5a88 Binary files /dev/null and b/tests/cucumber/.screenshots/2-step_failed_1432364116363.png differ diff --git a/tests/cucumber/features/formsFrame.feature b/tests/cucumber/features/formsFrame.feature new file mode 100644 index 0000000..0b015ef --- /dev/null +++ b/tests/cucumber/features/formsFrame.feature @@ -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 diff --git a/tests/cucumber/features/sample.feature b/tests/cucumber/features/sample.feature new file mode 100644 index 0000000..dd18f9b --- /dev/null +++ b/tests/cucumber/features/sample.feature @@ -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" diff --git a/tests/cucumber/features/step_definitions/sample_steps.js b/tests/cucumber/features/step_definitions/sample_steps.js new file mode 100644 index 0000000..0c11b31 --- /dev/null +++ b/tests/cucumber/features/step_definitions/sample_steps.js @@ -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); + }); + + }; + +})(); \ No newline at end of file diff --git a/tests/cucumber/fixtures/my_fixture.js b/tests/cucumber/fixtures/my_fixture.js new file mode 100644 index 0000000..238d8c8 --- /dev/null +++ b/tests/cucumber/fixtures/my_fixture.js @@ -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. + } + }); + +})(); \ No newline at end of file diff --git a/tests/jasmine/client/FormSpec.js b/tests/jasmine/client/FormSpec.js index bea3fdc..5499b70 100644 --- a/tests/jasmine/client/FormSpec.js +++ b/tests/jasmine/client/FormSpec.js @@ -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); }); }); diff --git a/tests/mocha/client/bug3SubFormRows.coffee b/tests/mocha/client/bug3SubFormRows.coffee index ff370d1..9531238 100644 --- a/tests/mocha/client/bug3SubFormRows.coffee +++ b/tests/mocha/client/bug3SubFormRows.coffee @@ -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');