github.com/anuvu/nomad@v0.8.7-atom1/ui/tests/integration/job-page/parts/summary-test.js (about) 1 import { getOwner } from '@ember/application'; 2 import hbs from 'htmlbars-inline-precompile'; 3 import wait from 'ember-test-helpers/wait'; 4 import { find } from 'ember-native-dom-helpers'; 5 import { test, moduleForComponent } from 'ember-qunit'; 6 import { startMirage } from 'nomad-ui/initializers/ember-cli-mirage'; 7 import { initialize as fragmentSerializerInitializer } from 'nomad-ui/initializers/fragment-serializer'; 8 9 moduleForComponent('job-page/parts/summary', 'Integration | Component | job-page/parts/summary', { 10 integration: true, 11 beforeEach() { 12 fragmentSerializerInitializer(getOwner(this)); 13 window.localStorage.clear(); 14 this.store = getOwner(this).lookup('service:store'); 15 this.server = startMirage(); 16 this.server.create('namespace'); 17 }, 18 afterEach() { 19 this.server.shutdown(); 20 window.localStorage.clear(); 21 }, 22 }); 23 24 test('jobs with children use the children diagram', function(assert) { 25 this.server.create('job', 'periodic', { 26 createAllocations: false, 27 }); 28 29 this.store.findAll('job'); 30 31 return wait().then(() => { 32 this.set('job', this.store.peekAll('job').get('firstObject')); 33 34 this.render(hbs` 35 {{job-page/parts/summary job=job}} 36 `); 37 38 return wait().then(() => { 39 assert.ok(find('[data-test-children-status-bar]'), 'Children status bar found'); 40 assert.notOk(find('[data-test-allocation-status-bar]'), 'Allocation status bar not found'); 41 }); 42 }); 43 }); 44 45 test('jobs without children use the allocations diagram', function(assert) { 46 this.server.create('job', { 47 createAllocations: false, 48 }); 49 50 this.store.findAll('job'); 51 52 return wait().then(() => { 53 this.set('job', this.store.peekAll('job').get('firstObject')); 54 55 this.render(hbs` 56 {{job-page/parts/summary job=job}} 57 `); 58 59 return wait().then(() => { 60 assert.ok(find('[data-test-allocation-status-bar]'), 'Allocation status bar found'); 61 assert.notOk(find('[data-test-children-status-bar]'), 'Children status bar not found'); 62 }); 63 }); 64 }); 65 66 test('the allocations diagram lists all allocation status figures', function(assert) { 67 this.server.create('job', { 68 createAllocations: false, 69 }); 70 71 this.store.findAll('job'); 72 73 return wait().then(() => { 74 this.set('job', this.store.peekAll('job').get('firstObject')); 75 76 this.render(hbs` 77 {{job-page/parts/summary job=job}} 78 `); 79 80 return wait().then(() => { 81 assert.equal( 82 find('[data-test-legend-value="queued"]').textContent, 83 this.get('job.queuedAllocs'), 84 `${this.get('job.queuedAllocs')} are queued` 85 ); 86 87 assert.equal( 88 find('[data-test-legend-value="starting"]').textContent, 89 this.get('job.startingAllocs'), 90 `${this.get('job.startingAllocs')} are starting` 91 ); 92 93 assert.equal( 94 find('[data-test-legend-value="running"]').textContent, 95 this.get('job.runningAllocs'), 96 `${this.get('job.runningAllocs')} are running` 97 ); 98 99 assert.equal( 100 find('[data-test-legend-value="complete"]').textContent, 101 this.get('job.completeAllocs'), 102 `${this.get('job.completeAllocs')} are complete` 103 ); 104 105 assert.equal( 106 find('[data-test-legend-value="failed"]').textContent, 107 this.get('job.failedAllocs'), 108 `${this.get('job.failedAllocs')} are failed` 109 ); 110 111 assert.equal( 112 find('[data-test-legend-value="lost"]').textContent, 113 this.get('job.lostAllocs'), 114 `${this.get('job.lostAllocs')} are lost` 115 ); 116 }); 117 }); 118 }); 119 120 test('the children diagram lists all children status figures', function(assert) { 121 this.server.create('job', 'periodic', { 122 createAllocations: false, 123 }); 124 125 this.store.findAll('job'); 126 127 return wait().then(() => { 128 this.set('job', this.store.peekAll('job').get('firstObject')); 129 130 this.render(hbs` 131 {{job-page/parts/summary job=job}} 132 `); 133 134 return wait().then(() => { 135 assert.equal( 136 find('[data-test-legend-value="queued"]').textContent, 137 this.get('job.pendingChildren'), 138 `${this.get('job.pendingChildren')} are pending` 139 ); 140 141 assert.equal( 142 find('[data-test-legend-value="running"]').textContent, 143 this.get('job.runningChildren'), 144 `${this.get('job.runningChildren')} are running` 145 ); 146 147 assert.equal( 148 find('[data-test-legend-value="complete"]').textContent, 149 this.get('job.deadChildren'), 150 `${this.get('job.deadChildren')} are dead` 151 ); 152 }); 153 }); 154 });