github.com/iqoqo/nomad@v0.11.3-0.20200911112621-d7021c74d101/ui/tests/integration/job-page/parts/body-test.js (about) 1 import { module, test } from 'qunit'; 2 import { setupRenderingTest } from 'ember-qunit'; 3 import { find, findAll, render } from '@ember/test-helpers'; 4 import hbs from 'htmlbars-inline-precompile'; 5 import { startMirage } from 'nomad-ui/initializers/ember-cli-mirage'; 6 7 module('Integration | Component | job-page/parts/body', function(hooks) { 8 setupRenderingTest(hooks); 9 10 hooks.beforeEach(function() { 11 window.localStorage.clear(); 12 this.server = startMirage(); 13 this.server.createList('namespace', 3); 14 }); 15 16 hooks.afterEach(function() { 17 this.server.shutdown(); 18 window.localStorage.clear(); 19 }); 20 21 test('includes a subnav for the job', async function(assert) { 22 this.set('job', {}); 23 24 await render(hbs` 25 {{#job-page/parts/body job=job}} 26 <div class="inner-content">Inner content</div> 27 {{/job-page/parts/body}} 28 `); 29 30 assert.ok(find('[data-test-subnav="job"]'), 'Job subnav is rendered'); 31 }); 32 33 test('the subnav includes the deployments link when the job is a service', async function(assert) { 34 const store = this.owner.lookup('service:store'); 35 const job = await store.createRecord('job', { 36 id: 'service-job', 37 type: 'service', 38 }); 39 40 this.set('job', job); 41 42 await render(hbs` 43 {{#job-page/parts/body job=job}} 44 <div class="inner-content">Inner content</div> 45 {{/job-page/parts/body}} 46 `); 47 48 const subnavLabels = findAll('[data-test-tab]').map(anchor => anchor.textContent); 49 assert.ok(subnavLabels.some(label => label === 'Definition'), 'Definition link'); 50 assert.ok(subnavLabels.some(label => label === 'Versions'), 'Versions link'); 51 assert.ok(subnavLabels.some(label => label === 'Deployments'), 'Deployments link'); 52 }); 53 54 test('the subnav does not include the deployments link when the job is not a service', async function(assert) { 55 const store = this.owner.lookup('service:store'); 56 const job = await store.createRecord('job', { 57 id: 'batch-job', 58 type: 'batch', 59 }); 60 61 this.set('job', job); 62 63 await render(hbs` 64 {{#job-page/parts/body job=job}} 65 <div class="inner-content">Inner content</div> 66 {{/job-page/parts/body}} 67 `); 68 69 const subnavLabels = findAll('[data-test-tab]').map(anchor => anchor.textContent); 70 assert.ok(subnavLabels.some(label => label === 'Definition'), 'Definition link'); 71 assert.ok(subnavLabels.some(label => label === 'Versions'), 'Versions link'); 72 assert.notOk(subnavLabels.some(label => label === 'Deployments'), 'Deployments link'); 73 }); 74 75 test('body yields content to a section after the subnav', async function(assert) { 76 this.set('job', {}); 77 78 await render(hbs` 79 {{#job-page/parts/body job=job}} 80 <div class="inner-content">Inner content</div> 81 {{/job-page/parts/body}} 82 `); 83 84 assert.ok( 85 find('[data-test-subnav="job"] + .section > .inner-content'), 86 'Content is rendered immediately after the subnav' 87 ); 88 }); 89 });