open-vault/ui/tests/pages/components/flash-message.js

30 lines
762 B
JavaScript
Raw Normal View History

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() {
return this.latestItem.text;
2018-04-03 14:16:57 +00:00
}),
latestItem: getter(function() {
const count = this.messages.length;
return this.messages.objectAt(count - 1);
2018-04-03 14:16:57 +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
};