github.com/iqoqo/nomad@v0.11.3-0.20200911112621-d7021c74d101/ui/tests/integration/job-page/helpers.js (about) 1 import { click, find } from '@ember/test-helpers'; 2 3 export function jobURL(job, path = '') { 4 const id = job.get('plainId'); 5 const namespace = job.get('namespace.name') || 'default'; 6 let expectedURL = `/v1/job/${id}${path}`; 7 if (namespace !== 'default') { 8 expectedURL += `?namespace=${namespace}`; 9 } 10 return expectedURL; 11 } 12 13 export async function stopJob() { 14 await click('[data-test-stop] [data-test-idle-button]'); 15 await click('[data-test-stop] [data-test-confirm-button]'); 16 } 17 18 export async function startJob() { 19 await click('[data-test-start] [data-test-idle-button]'); 20 await click('[data-test-start] [data-test-confirm-button]'); 21 } 22 23 export function expectStartRequest(assert, server, job) { 24 const expectedURL = jobURL(job); 25 const request = server.pretender.handledRequests 26 .filterBy('method', 'POST') 27 .find(req => req.url === expectedURL); 28 29 const requestPayload = JSON.parse(request.requestBody).Job; 30 31 assert.ok(request, 'POST URL was made correctly'); 32 assert.ok(requestPayload.Stop == null, 'The Stop signal is not sent in the POST request'); 33 } 34 35 export async function expectError(assert, title) { 36 assert.equal( 37 find('[data-test-job-error-title]').textContent, 38 title, 39 'Appropriate error is shown' 40 ); 41 assert.ok( 42 find('[data-test-job-error-body]').textContent.includes('ACL'), 43 'The error message mentions ACLs' 44 ); 45 46 await click('[data-test-job-error-close]'); 47 assert.notOk(find('[data-test-job-error-title]'), 'Error message is dismissable'); 48 } 49 50 export function expectDeleteRequest(assert, server, job) { 51 const expectedURL = jobURL(job); 52 53 assert.ok( 54 server.pretender.handledRequests 55 .filterBy('method', 'DELETE') 56 .find(req => req.url === expectedURL), 57 'DELETE URL was made correctly' 58 ); 59 }