-
-
Notifications
You must be signed in to change notification settings - Fork 94
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 #111
Comments
@nucleartide Hey man! Thanks for the interest in the add-on and your kind words 🙃 One area of the add-on that I am particularly keen to improve on is testing (see #91). I have little experience in writing tests, so I'd be more than happy to accept contributions that will improve this aspect of the add-on. If you're interested in helping me make the add-on bulletproof, then fire away with the PRs 🚀 |
Ah okay! I will fire away with the PRs should I run into problems. :) |
Was any progress made on this? Ran into the same issue. My current workaround is probably going to be to set |
my solution was to extend the notifications service, override methods involving the run loop, and remove calls to the run loop. but this was a long time ago. hopefully that helps! |
This issue should get resolved in this addon, but in the meantime, here is my workaround: We check the environment variable to see if we are testing, and if so, set the auto clear duration to 0. // controllers/application.js
import Ember from 'ember';
import ENV from 'myApp/config/environment';
export default Ember.Controller.extend({
notifications: Ember.inject.service('notification-messages'),
init: function () {
const notifications = this.get('notifications');
notifications.setDefaultAutoClear(true);
if(ENV.environment === 'test') {
notifications.setDefaultClearDuration(0);
}
}
}); |
That's a good workaround for clearing the images, but makes it hard if you want to actually test the notifications in an acceptance test. I had a defaults hash that I overwrite in test: Then wrote a helper that dismisses the notifications. That way the notifications stick around during the life of your test and you can test that the right messaging appears (if that's important to you). |
Even with |
Did you tried out to set // config/environment.js
module.exports = function(environment) {
let ENV = {
'ember-cli-notifications': {
autoClear: true
}
}
if (environment === 'test') {
ENV['ember-cli-notifications'].clearDuration = 1;
}
return ENV;
}; |
We're doing something similar with the same result, but our issue isn't The delay is hardcoded at 500ms in the |
I see. Didn't noticed that one. In my opinion this dismissal animation duration should also be configurable. Maybe call it a I'm also not quite sure why the default is 500ms. The animation is only 250ms isn't it? |
Another work around, in your import NotificationMessageService from 'ember-cli-notifications/services/notification-messages-service';
NotificationMessageService.reopen({
removeNotification(notification) {
if (!notification) {
return;
}
notification.set('dismiss', true);
this.removeObject(notification);
}
}) |
Ember-cli-notifications have a fixed 500ms delay removal animation. It impacts test duration indeed. There is an issue opened about this to make delay removal animation configurable. In the mean time, we need to modify a little bit the removeNotification() method in the notifications services to bump those 500ms delay. removeNotification() source code : https://github.com/mansona/ember-cli-notifications/blob/master/addon/services/notifications.js issue : mansona/ember-cli-notifications#111
Ember-cli-notifications have a fixed 500ms delay removal animation. It impacts test duration indeed. There is an issue opened about this to make delay removal animation configurable. In the mean time, we need to modify a little bit the removeNotification() method in the notifications services to bump those 500ms delay. removeNotification() source code : https://github.com/mansona/ember-cli-notifications/blob/master/addon/services/notifications.js issue : mansona/ember-cli-notifications#111
Hey dude! First of all, this addon is great - I'm really liking the pretty default styles out of the box.
One question I have though: in acceptance tests, Ember waits for the run loop to clear before continuing. I notice that when I write an acceptance test for notifications, I have to wait
clearDuration
amount of time before my test continues. This slows down the test and is a little annoying.It seems like these two methods are causing that to happen. So my resolution was to allow those methods to run, only if Ember isn't in test mode. (Using the
Ember.testing
flag would also work, instead of a having to manually toggle a variable on the service.)Do you think it's a good idea to incorporate this change into ember-cli-notifications? Alternatively, I can simply extend the notifications service (as part of this recent change), and make the method overrides myself.
I'd love to hear what you think!
The text was updated successfully, but these errors were encountered: