mirror of
https://github.com/documize/community.git
synced 2025-08-08 06:55:28 +02:00
Add waitToDisappear helper and minor cleanup
This commit is contained in:
parent
81ecb75391
commit
78e22379dc
4 changed files with 36 additions and 13 deletions
|
@ -4,8 +4,8 @@ import config from '../../config/environment';
|
||||||
import './stub-session';
|
import './stub-session';
|
||||||
import './stub-audit';
|
import './stub-audit';
|
||||||
import './user-login';
|
import './user-login';
|
||||||
import './allow-anonymous-access';
|
|
||||||
import './wait-to-appear';
|
import './wait-to-appear';
|
||||||
|
import './wait-to-disappear';
|
||||||
import './stub-user-notification';
|
import './stub-user-notification';
|
||||||
|
|
||||||
export default function startApp(attrs) {
|
export default function startApp(attrs) {
|
||||||
|
|
|
@ -1,19 +1,18 @@
|
||||||
import Ember from 'ember';
|
import Ember from 'ember';
|
||||||
import miscUtil from 'documize/utils/misc';
|
|
||||||
|
|
||||||
const userNotification = Ember.Component.extend({
|
const userNotification = Ember.Component.extend({
|
||||||
notifications: [],
|
notifications: [],
|
||||||
|
|
||||||
didInsertElement() {
|
didInsertElement() {
|
||||||
// this.eventBus.subscribe('notifyUser', this, 'showNotification');
|
this.eventBus.subscribe('notifyUser', this, 'notifyHandler');
|
||||||
},
|
},
|
||||||
|
|
||||||
willDestroyElement() {
|
willDestroyElement() {
|
||||||
// this.eventBus.unsubscribe('notifyUser');
|
this.eventBus.unsubscribe('notifyUser');
|
||||||
},
|
},
|
||||||
|
|
||||||
showNotification(msg) {
|
showNotification(msg) {
|
||||||
// console.log(msg);
|
return msg;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
@ -6,10 +6,11 @@ function isVisible(selector) {
|
||||||
|
|
||||||
function checkVisibility(selector, interval, resolve, visibility) {
|
function checkVisibility(selector, interval, resolve, visibility) {
|
||||||
if (isVisible(selector) === visibility) {
|
if (isVisible(selector) === visibility) {
|
||||||
|
console.log("found in appear");
|
||||||
resolve($(selector));
|
resolve($(selector));
|
||||||
} else {
|
} else {
|
||||||
console.log('waiting for visibility');
|
|
||||||
Ember.run.later(null, function() {
|
Ember.run.later(null, function() {
|
||||||
|
console.log("waiting in appear");
|
||||||
checkVisibility(selector, interval, resolve, visibility);
|
checkVisibility(selector, interval, resolve, visibility);
|
||||||
}, interval);
|
}, interval);
|
||||||
}
|
}
|
||||||
|
|
23
app/tests/helpers/wait-to-disappear.js
Normal file
23
app/tests/helpers/wait-to-disappear.js
Normal file
|
@ -0,0 +1,23 @@
|
||||||
|
import Ember from 'ember';
|
||||||
|
|
||||||
|
function isVisible(selector) {
|
||||||
|
return $(selector).length > 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
function checkVisibility(selector, interval, resolve, visibility) {
|
||||||
|
if (isVisible(selector) === visibility) {
|
||||||
|
console.log("found");
|
||||||
|
resolve($(selector));
|
||||||
|
} else {
|
||||||
|
Ember.run.later(null, function() {
|
||||||
|
console.log("waiting");
|
||||||
|
checkVisibility(selector, interval, resolve, visibility);
|
||||||
|
}, interval);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export default Ember.Test.registerAsyncHelper('waitToDisappear', function(app, selector, interval = 200) {
|
||||||
|
return new Ember.RSVP.Promise(function(resolve) {
|
||||||
|
checkVisibility(selector, interval, resolve, false);
|
||||||
|
});
|
||||||
|
});
|
Loading…
Add table
Add a link
Reference in a new issue