2018-09-25 16:28:26 +00:00
|
|
|
import { waitFor, settled } from '@ember/test-helpers';
|
|
|
|
import { collection, text, clickable } from 'ember-cli-page-object';
|
2018-04-03 14:16:57 +00:00
|
|
|
import { getter } from 'ember-cli-page-object/macros';
|
|
|
|
|
|
|
|
export default {
|
|
|
|
latestMessage: getter(function() {
|
2018-09-25 16:28:26 +00:00
|
|
|
return this.latestItem.text;
|
2018-04-03 14:16:57 +00:00
|
|
|
}),
|
2018-09-25 16:28:26 +00:00
|
|
|
latestItem: getter(function() {
|
|
|
|
const count = this.messages.length;
|
|
|
|
return this.messages.objectAt(count - 1);
|
2018-04-03 14:16:57 +00:00
|
|
|
}),
|
2018-09-25 16:28:26 +00:00
|
|
|
messages: collection('[data-test-flash-message-body]', {
|
|
|
|
click: clickable(),
|
|
|
|
text: text(),
|
|
|
|
}),
|
|
|
|
waitForFlash() {
|
|
|
|
return waitFor('[data-test-flash-message-body]');
|
|
|
|
},
|
|
|
|
clickLast() {
|
|
|
|
return this.latestItem.click();
|
|
|
|
},
|
|
|
|
async clickAll() {
|
|
|
|
for (let message of this.messages) {
|
|
|
|
message.click();
|
|
|
|
}
|
|
|
|
await settled();
|
|
|
|
},
|
2018-04-03 14:16:57 +00:00
|
|
|
};
|