github.com/anth0d/nomad@v0.0.0-20221214183521-ae3a0a2cad06/ui/tests/pages/components/recommendation-card.js (about) 1 import { 2 attribute, 3 collection, 4 hasClass, 5 isPresent, 6 text, 7 } from 'ember-cli-page-object'; 8 import { getter } from 'ember-cli-page-object/macros'; 9 10 import toggle from 'nomad-ui/tests/pages/components/toggle'; 11 12 export default { 13 scope: '[data-test-task-group-recommendations]', 14 15 slug: { 16 jobName: text('[data-test-job-name]'), 17 groupName: text('[data-test-task-group-name]'), 18 }, 19 20 namespace: text('[data-test-namespace]'), 21 22 copyButton: { 23 scope: '[data-test-copy-button]', 24 clipboardText: attribute('data-clipboard-text', 'button'), 25 }, 26 27 totalsTable: totalsTableComponent('[data-test-group-totals]'), 28 29 narrative: text('[data-test-narrative]'), 30 31 togglesTable: { 32 scope: '[data-test-toggles-table]', 33 34 toggleAllIsPresent: isPresent('[data-test-toggle-all]'), 35 toggleAllCPU: toggle('[data-test-tasks-head] [data-test-cpu-toggle]'), 36 toggleAllMemory: toggle('[data-test-tasks-head] [data-test-memory-toggle]'), 37 38 tasks: collection('[data-test-task-toggles]', { 39 name: text('[data-test-name]'), 40 cpu: toggle('[data-test-cpu-toggle]'), 41 memory: toggle('[data-test-memory-toggle]'), 42 43 isActive: hasClass('active'), 44 }), 45 }, 46 47 activeTask: { 48 scope: '[data-test-active-task]', 49 50 name: text('[data-test-task-name]'), 51 totalsTable: totalsTableComponent(''), 52 53 charts: collection('[data-test-chart-for]', { 54 resource: text('text.resource'), 55 }), 56 57 cpuChart: resourceChartComponent('[data-test-chart-for=CPU]'), 58 memoryChart: resourceChartComponent('[data-test-chart-for=MemoryMB]'), 59 }, 60 61 acceptButton: { 62 scope: '[data-test-accept]', 63 isDisabled: attribute('disabled'), 64 }, 65 66 dismissButton: { 67 scope: '[data-test-dismiss]', 68 }, 69 }; 70 71 function totalsTableCell(scope) { 72 return { 73 scope, 74 isIncrease: hasClass('increase'), 75 isDecrease: hasClass('decrease'), 76 isNeutral: getter(function () { 77 return !this.isIncrease && !this.isDecrease; 78 }), 79 }; 80 } 81 82 function totalsTableComponent(scope) { 83 return { 84 scope, 85 86 current: { 87 scope: '[data-test-current]', 88 cpu: totalsTableCell('[data-test-cpu]'), 89 memory: totalsTableCell('[data-test-memory]'), 90 }, 91 92 recommended: { 93 scope: '[data-test-recommended]', 94 cpu: totalsTableCell('[data-test-cpu]'), 95 memory: totalsTableCell('[data-test-memory]'), 96 }, 97 98 unitDiff: { 99 cpu: text('[data-test-cpu-unit-diff]'), 100 memory: text('[data-test-memory-unit-diff]'), 101 }, 102 103 percentDiff: { 104 cpu: text('[data-test-cpu-percent-diff]'), 105 memory: text('[data-test-memory-percent-diff]'), 106 }, 107 }; 108 } 109 110 function resourceChartComponent(scope) { 111 return { 112 scope, 113 114 isIncrease: hasClass('increase'), 115 isDecrease: hasClass('decrease'), 116 isDisabled: hasClass('disabled'), 117 }; 118 }