Last active
August 19, 2016 20:16
-
-
Save TimFletcher/24c577f2355295bfb5e887700169d2da to your computer and use it in GitHub Desktop.
Chimp login fixtures problem
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
export default { | |
users: { | |
create() { | |
server.execute(() => { | |
const email = '[email protected]'; | |
const password = 'jkjkjkjk'; | |
let userId; | |
try { | |
const user = Meteor.users.findOne({ emails: { $elemMatch: { address: email } } }); | |
userId = user._id; | |
} catch (e) { | |
userId = Accounts.createUser({ | |
username: 'test', | |
email, | |
password, | |
profile: { firstName: 'Tim', lastName: 'Fletcher' }, | |
}); | |
} | |
// Always reset user password as a test may have changed it | |
Accounts.setPassword(userId, password, { logout: false }); | |
}); | |
}, | |
serverLogin(user) { | |
server.call('login', { user: { email: user.email }, password: user.password }); | |
}, | |
clientLogin(accountHolder) { | |
browser.url('http://localhost:3100'); // the client must be on a Meteor app page before you can call `execute` on it | |
browser.executeAsync(function(accountHolder, done){ | |
Meteor.loginWithPassword(accountHolder.email, accountHolder.password, done); | |
}, accountHolder); | |
}, | |
login(user) { | |
this.serverLogin(user); | |
this.clientLogin(user); | |
}, | |
}, | |
common: { | |
reset() { | |
// Make sure the DDP connection is not logged in before clearing the database | |
server.call('logout'); | |
server.execute(() => { Package['xolvio:cleaner'].resetDatabase(); }); | |
}, | |
}, | |
}; |
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
[chimp] Running... | |
Change Password Form | |
1) "before each" hook | |
0 passing (3s) | |
1 failing | |
1) Change Password Form "before each" hook: | |
Uncaught Error: asynchronous script timeout: result was not received in 0 seconds | |
at Object.Future.wait (node_modules/fibers/future.js:449:15) | |
at Object.<anonymous> (node_modules/wdio-sync/build/index.js:345:27) | |
at Object.clientLogin (fixtures.js:42:15) | |
at Object.login (fixtures.js:49:12) | |
at Context.<anonymous> (change_password.js:13:20) | |
at node_modules/chimp/dist/lib/utils/fiberize.js:25:14 | |
- - - - - |
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
import fixtures from './fixtures'; | |
describe('Change Password Form', () => { | |
beforeEach(() => { | |
fixtures.common.reset(); | |
fixtures.users.create(); | |
fixtures.users.login({ email: '[email protected]', password: 'jkjkjkjk' }); | |
}); | |
it('can change password @watch', () => { | |
browser.execute(function(done){ | |
console.log('never gets here....'); | |
}); | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment