Created
October 2, 2011 02:03
-
-
Save cjroebuck/1256944 to your computer and use it in GitHub Desktop.
Test showing zombie's browser.fire not firing the event handler which is attached via Backbone.Event
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
♢ Open Button Test | |
Zombie: GET http://www.documentcloud.org/public/search/ | |
Zombie: GET http://www.documentcloud.org/public/search/ => 200 | |
Zombie: GET http://www.documentcloud.org/assets/core.js?1317236698 | |
Zombie: GET http://www.documentcloud.org/assets/core.js?1317236698 => 200 | |
Zombie: Firing timeout 1, delay: 1 | |
Zombie: Firing timeout 2, delay: 1 | |
Zombie: Firing timeout 3, delay: 1 | |
Zombie: Firing timeout 4, delay: 1 | |
Zombie: GET http://www.documentcloud.org/search/documents.json?per_page=10&order=score&mentions=3&q= | |
Zombie: GET http://www.documentcloud.org/search/documents.json?per_page=10&order=score&mentions=3&q= => 200 | |
Zombie: Firing timeout 6, delay: 1 | |
Clicking the Open Button on Doc Cloud Given the app is running, When I visit the site at http://www.documentcloud.org/public/search/, | |
✓ Then I should get a 200 | |
✓ Then I should not see the overlay class | |
Zombie: Firing interval 5, interval: 13 | |
Clicking the Open Button on Doc Cloud Given the app is running, When I visit the site at http://www.documentcloud.org/public/search/, When I click the open_viewers button, | |
✗ Then I should see the overlay class | |
» expected expression to evaluate to true, but was undefined // vows.js:93 | |
Zombie: Firing interval 5, interval: 13 | |
Clicking the Open Button on Doc Cloud Given the app is running, When I visit the site at http://www.documentcloud.org/public/search/, When I click the open_viewers button, When I use jQuerys click() method via browser.evaluate, | |
✓ Then I should see the overlay class |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
should = require 'should' | |
vowsbdd = require 'vows-bdd' | |
zombie = require 'zombie' | |
assert = require 'assert' | |
brow = new zombie.Browser debug:true, runScripts:true | |
vowsbdd.Feature('Open Button Test') | |
.scenario('Clicking the Open Button on Doc Cloud') | |
.given 'the app is running', -> | |
@callback() | |
.when 'I visit the site at http://www.documentcloud.org/public/search/', -> | |
brow.visit 'http://www.documentcloud.org/public/search/', @callback | |
.then 'I should get a 200', (err, browser, status) -> | |
if err | |
throw err.message | |
browser.statusCode.should.equal (200) | |
.and 'I should not see the overlay class', (err, browser, status) -> | |
el = browser.querySelector '.overlay' | |
should.not.exist(el) | |
.when 'I click the open_viewers button', (browser, status) -> | |
el = browser.querySelector('#open_viewers') | |
# expect the browsert to alert() the message: 'Please select a document to open.' when the open button is clicked | |
browser.prompted 'Please select a document to open.', () -> | |
console.log 'This never gets called...' | |
browser.fire 'click', el, @callback | |
.then 'I should see the overlay class', (err, browser, status) -> | |
el = browser.querySelector '.overlay' | |
should.ok el # This class should now be visible following the click but isn't | |
.when 'I use jQuerys click() method via browser.evaluate', (browser, status) -> | |
browser.evaluate("$('#open_viewers').click()") | |
browser.wait @callback | |
.then 'I should see the overlay class', (err, browser,status) -> | |
el = browser.querySelector '.overlay' | |
should.ok el # This class is now available | |
.complete() | |
.finish(module) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//Showing the relevant parts of the doc cloud backbone app, you can see the click event handler when the #open_viewers elem is clicked | |
dc.ui.Toolbar = Backbone.View.extend({ | |
id : 'toolbar', | |
events : { | |
'click #open_viewers' : '_clickOpenViewers', | |
'click #size_toggle' : '_toggleSize' | |
}, | |
_clickOpenViewers : function() { | |
this.openViewers(); | |
}, | |
openViewers : function(checkEdit, suffix, afterLoad) { | |
if (!Documents.selectedCount) return dc.ui.Dialog.alert('Please select a document to open.'); | |
var continuation = function(docs) { | |
_.each(docs, function(doc){ | |
var win = doc.openAppropriateVersion(suffix); | |
if (afterLoad) { | |
win.DV || (win.DV = {}); | |
win.DV.afterLoad = afterLoad; | |
} | |
}); | |
}; | |
checkEdit ? this.edit(continuation) : continuation(Documents.selected()); | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment