2021-10-07 21:11:38 +00:00
|
|
|
import { attribute, collection, clickable, text } from 'ember-cli-page-object';
|
|
|
|
import { singularize } from 'ember-inflector';
|
|
|
|
|
2021-12-28 14:45:20 +00:00
|
|
|
export default function (selector = '[data-test-client]', propKey = 'clients') {
|
2021-10-07 21:11:38 +00:00
|
|
|
const lookupKey = `${singularize(propKey)}For`;
|
|
|
|
// Remove the bracket notation
|
|
|
|
const attr = selector.substring(1, selector.length - 1);
|
|
|
|
|
|
|
|
return {
|
|
|
|
[propKey]: collection(selector, {
|
|
|
|
id: attribute(attr),
|
|
|
|
shortId: text('[data-test-short-id]'),
|
|
|
|
name: text('[data-test-name]'),
|
|
|
|
status: text('[data-test-job-status]'),
|
|
|
|
|
|
|
|
createTime: {
|
|
|
|
scope: '[data-test-create-time]',
|
|
|
|
tooltip: {
|
|
|
|
scope: '.tooltip',
|
|
|
|
text: attribute('aria-label'),
|
|
|
|
},
|
|
|
|
},
|
|
|
|
|
|
|
|
modifyTime: {
|
|
|
|
scope: '[data-test-modify-time]',
|
|
|
|
tooltip: {
|
|
|
|
scope: '.tooltip',
|
|
|
|
text: attribute('aria-label'),
|
|
|
|
},
|
|
|
|
},
|
|
|
|
|
|
|
|
visit: clickable('[data-test-short-id] a'),
|
|
|
|
visitRow: clickable(),
|
|
|
|
}),
|
|
|
|
|
2021-12-28 14:45:20 +00:00
|
|
|
[lookupKey]: function (id) {
|
|
|
|
return this[propKey].toArray().find((client) => client.id === id);
|
2021-10-07 21:11:38 +00:00
|
|
|
},
|
|
|
|
};
|
|
|
|
}
|