github.com/anth0d/nomad@v0.0.0-20221214183521-ae3a0a2cad06/ui/tests/pages/components/allocations.js (about) 1 import { 2 attribute, 3 collection, 4 clickable, 5 isPresent, 6 text, 7 } from 'ember-cli-page-object'; 8 import { singularize } from 'ember-inflector'; 9 10 export default function ( 11 selector = '[data-test-allocation]', 12 propKey = 'allocations' 13 ) { 14 const lookupKey = `${singularize(propKey)}For`; 15 // Remove the bracket notation 16 const attr = selector.substring(1, selector.length - 1); 17 18 return { 19 [propKey]: collection(selector, { 20 id: attribute(attr), 21 shortId: text('[data-test-short-id]'), 22 createTime: text('[data-test-create-time]'), 23 createTooltip: attribute( 24 'aria-label', 25 '[data-test-create-time] .tooltip' 26 ), 27 modifyTime: text('[data-test-modify-time]'), 28 health: text('[data-test-health]'), 29 status: text('[data-test-client-status]'), 30 job: text('[data-test-job]'), 31 taskGroup: text('[data-test-task-group]'), 32 client: text('[data-test-client]'), 33 clientTooltip: attribute('aria-label', '[data-test-client] .tooltip'), 34 jobVersion: text('[data-test-job-version]'), 35 volume: text('[data-test-volume]'), 36 cpu: text('[data-test-cpu]'), 37 cpuTooltip: attribute('aria-label', '[data-test-cpu] .tooltip'), 38 mem: text('[data-test-mem]'), 39 memTooltip: attribute('aria-label', '[data-test-mem] .tooltip'), 40 rescheduled: isPresent( 41 '[data-test-indicators] [data-test-icon="reschedule"]' 42 ), 43 44 visit: clickable('[data-test-short-id] a'), 45 visitRow: clickable(), 46 visitJob: clickable('[data-test-job]'), 47 visitClient: clickable('[data-test-client] a'), 48 }), 49 50 [lookupKey]: function (id) { 51 return this[propKey].toArray().find((allocation) => allocation.id === id); 52 }, 53 }; 54 }