Skip to content

Instantly share code, notes, and snippets.

@wookiehangover
Created September 25, 2013 00:44
Show Gist options
  • Save wookiehangover/6693493 to your computer and use it in GitHub Desktop.
Save wookiehangover/6693493 to your computer and use it in GitHub Desktop.
mochaAppium:
options:
usePromises: true
# Mocha options
reporter: 'spec'
timeout: 30e3
slow: 10e3
iphone:
src: ['www/spec/functional/sanity.js']
options:
app: path.resolve('./platforms/ios/build/APP_NAME.app')
device: 'iPhone Simulator'
platform: 'MAC'
version: '6.1'
var assert = require('chai').assert;
var helpers = require('../helpers');
var wdquery = require('wd-query');
describe('Playing a quiz', function(){
var browser, $;
var user = {
email: 'testing@quickleft.com',
password: 'password'
};
before(function(done){
browser = this.browser;
$ = wdquery(browser);
browser.windowHandles()
.then(function(handles){
assert.ok(handles.length > 0);
return browser.window(handles[0]);
})
.done(done);
});
after(function(done){
browser.get('#logout')
.done(done);
});
it('logs in', function(done){
helpers.logout(browser)
.then(function(){
$('.sign-in').click()
})
.then(function(){
return $('.auth .email-btn').click();
})
.then(function(){
return $('#signin-email').val(user.email);
})
.then(function(){
return $('#signin-password').val(user.password);
})
.then(function(){
return $('.signin button').click();
})
.delay(1000)
.done(done);
});
it('selects a venue', function(done){
// venue selection
$('.venue-search-btn').click()
.delay(1000)
.then(function(){
return $('.venues li:nth-of-type(2)').tap();
})
.delay(1000)
.done(done);
});
it('assembles a team', function(done){
// team selection
$('.recent-teams li:nth-of-type(1)').tap()
.delay(1000)
.then(function(){
return $('#build-team .start-quiz').tap();
})
.delay(1000)
.then(function(){
return $('.modal-cancel-action').click();
})
.delay(1000)
.done(done);
});
it('waits for the quiz to start', function(done){
// quiz start, round 1
browser.waitForElementByCssSelector('.modal-footer button', 30e3)
.delay(1000)
.then(function(elem){
return $('.modal-footer button').click();
})
.delay(1000)
.then(function(){
return $('#welcome-message .dismiss').click();
})
.then(function(){
return browser.waitForElementByCssSelector('.modal-footer button', 30e3);
})
.delay(1000)
.then(function(elem){
return $('.modal-footer button').click();
})
.delay(500)
.done(done);
});
it('answers some questions', function(done){
$('.rounds .active .answer-sheet .control-group:nth-of-type(1) input').val('hello')
.then(function(){
return $('.rounds .active .answer-sheet .control-group:nth-of-type(2) input').val('world');
})
.then(function(){
return $('.rounds .active .answer-sheet .control-group:nth-of-type(3) input').val('these');
})
.then(function(){
return $('.rounds .active .answer-sheet .control-group:nth-of-type(4) input').val('are');
})
.then(function(){
return $('.rounds .active .answer-sheet .control-group:nth-of-type(5) input').val('the');
})
.then(function(){
return $('.rounds .active .answer-sheet .control-group:nth-of-type(6) input').val('answers');
})
.then(function(){
return $('.rounds .active .answer-sheet .control-group:nth-of-type(7) input').val('check');
})
.then(function(){
return $('.rounds .active .answer-sheet .control-group:nth-of-type(8) input').val('yoself');
})
.then(function(){
return browser.waitForElementByCssSelector('.modal-footer button', 30e3);
})
.delay(500)
.then(function(elem){
return $('.modal-footer button').click();
})
.delay(20e3)
.done(done);
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment