2018-07-19 01:59:04 +00:00
|
|
|
import { text, triggerable, clickable, collection, fillable, value, isPresent } from 'ember-cli-page-object';
|
|
|
|
import { getter } from 'ember-cli-page-object/macros';
|
2021-11-15 15:48:11 +00:00
|
|
|
import { settled } from '@ember/test-helpers';
|
2018-07-19 01:59:04 +00:00
|
|
|
|
2018-05-25 20:33:22 +00:00
|
|
|
import keys from 'vault/lib/keycodes';
|
|
|
|
|
|
|
|
export default {
|
2018-07-19 01:59:04 +00:00
|
|
|
toggle: clickable('[data-test-console-toggle]'),
|
2018-05-25 20:33:22 +00:00
|
|
|
consoleInput: fillable('[data-test-component="console/command-input"] input'),
|
|
|
|
consoleInputValue: value('[data-test-component="console/command-input"] input'),
|
|
|
|
logOutput: text('[data-test-component="console/output-log"]'),
|
2018-07-19 01:59:04 +00:00
|
|
|
logOutputItems: collection('[data-test-component="console/output-log"] > div', {
|
|
|
|
text: text(),
|
|
|
|
}),
|
2021-12-17 03:44:29 +00:00
|
|
|
lastLogOutput: getter(function () {
|
2018-07-19 01:59:04 +00:00
|
|
|
let count = this.logOutputItems.length;
|
2021-03-16 18:23:48 +00:00
|
|
|
let outputItemText = this.logOutputItems.objectAt(count - 1).text;
|
|
|
|
return outputItemText;
|
2018-07-19 01:59:04 +00:00
|
|
|
}),
|
|
|
|
logTextItems: collection('[data-test-component="console/log-text"]', {
|
|
|
|
text: text(),
|
|
|
|
}),
|
2021-12-17 03:44:29 +00:00
|
|
|
lastTextOutput: getter(function () {
|
2018-07-19 01:59:04 +00:00
|
|
|
let count = this.logTextItems.length;
|
|
|
|
return this.logTextItems.objectAt(count - 1).text;
|
|
|
|
}),
|
|
|
|
logJSONItems: collection('[data-test-component="console/log-json"]', {
|
|
|
|
text: text(),
|
|
|
|
}),
|
2021-12-17 03:44:29 +00:00
|
|
|
lastJSONOutput: getter(function () {
|
2018-07-19 01:59:04 +00:00
|
|
|
let count = this.logJSONItems.length;
|
|
|
|
return this.logJSONItems.objectAt(count - 1).text;
|
|
|
|
}),
|
2018-05-25 20:33:22 +00:00
|
|
|
up: triggerable('keyup', '[data-test-component="console/command-input"] input', {
|
|
|
|
eventProperties: { keyCode: keys.UP },
|
|
|
|
}),
|
|
|
|
down: triggerable('keyup', '[data-test-component="console/command-input"] input', {
|
|
|
|
eventProperties: { keyCode: keys.DOWN },
|
|
|
|
}),
|
|
|
|
enter: triggerable('keyup', '[data-test-component="console/command-input"] input', {
|
|
|
|
eventProperties: { keyCode: keys.ENTER },
|
|
|
|
}),
|
|
|
|
hasInput: isPresent('[data-test-component="console/command-input"] input'),
|
2021-12-17 03:44:29 +00:00
|
|
|
runCommands: async function (commands) {
|
2018-07-19 01:59:04 +00:00
|
|
|
let toExecute = Array.isArray(commands) ? commands : [commands];
|
2018-09-25 16:28:26 +00:00
|
|
|
for (let command of toExecute) {
|
|
|
|
await this.consoleInput(command);
|
|
|
|
await this.enter();
|
2021-11-15 15:48:11 +00:00
|
|
|
await settled();
|
2018-09-25 16:28:26 +00:00
|
|
|
}
|
2018-07-19 01:59:04 +00:00
|
|
|
},
|
2018-05-25 20:33:22 +00:00
|
|
|
};
|