Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Testing with ember-cli #211

Closed
alvincrespo opened this issue Jun 23, 2014 · 4 comments
Closed

Testing with ember-cli #211

alvincrespo opened this issue Jun 23, 2014 · 4 comments
Labels

Comments

@alvincrespo
Copy link

I'm trying to find documentation on how to get ember-simple-auth to run fine in our tests. Unfortunately I'm having an issue where if I simulate the login experience, the mechanism for authentication keeps it around in the next test.

For example, If in test 1 I test the user can view the login page, and then test 2 is to testa successful login, then test 3 fails because I test whether you can register, but you are already logged in.

Is there something I can do in the qunit teardown to remove the session/token?

@seriousben
Copy link

For that purpose, I use the ephemeral store:
ember-simple-auth-session-store:ephemeral
When testing. So that on the app.destroy the store stops existing and the
user is not logged in.

We also fake authentication for authenticated test by using:

var session = App.__container__.lookup('ember-simple-auth-session:main');
session.set('isAuthenticated', true);
session.set('accessToken', 'authenticated');

@alvincrespo
Copy link
Author

@seriousbenat360pi Thanks for your help on this!

I'm curious how I may be able to set ember-simple-auth-session-store:ephemeral during testing when visiting http://localhost:4200/tests in ember-cli? Would reopen or reopenClass do something like that?

@seriousben
Copy link

Good question, to do this I have a check in the initializer app.get('testing')... unfortunately we could not change the simple-auth initializer once its loaded and we could not inject another store either.

@marcoow
Copy link
Member

marcoow commented Jun 23, 2014

Yes, changing the store after setup isn't really supported - checking whether you're running in test env on startup is the way to go for now. Just as a heads up: in the next version all configuration will be removed to window.ENV['simple-auth'] so that you can change it depending on app state in a cleaner way without having to change the initializer (which will in fact go away).

@marcoow marcoow closed this as completed Jun 23, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants