2019-07-23 19:40:32 +00:00
|
|
|
import { click, find } from '@ember/test-helpers';
|
2018-04-19 21:21:25 +00:00
|
|
|
|
|
|
|
export function jobURL(job, path = '') {
|
|
|
|
const id = job.get('plainId');
|
|
|
|
const namespace = job.get('namespace.name') || 'default';
|
|
|
|
let expectedURL = `/v1/job/${id}${path}`;
|
|
|
|
if (namespace !== 'default') {
|
|
|
|
expectedURL += `?namespace=${namespace}`;
|
|
|
|
}
|
|
|
|
return expectedURL;
|
|
|
|
}
|
|
|
|
|
2019-07-23 19:40:32 +00:00
|
|
|
export async function stopJob() {
|
|
|
|
await click('[data-test-stop] [data-test-idle-button]');
|
|
|
|
await click('[data-test-stop] [data-test-confirm-button]');
|
2018-04-19 21:21:25 +00:00
|
|
|
}
|
|
|
|
|
2019-07-23 19:40:32 +00:00
|
|
|
export async function startJob() {
|
|
|
|
await click('[data-test-start] [data-test-idle-button]');
|
|
|
|
await click('[data-test-start] [data-test-confirm-button]');
|
2018-08-24 20:18:10 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
export function expectStartRequest(assert, server, job) {
|
|
|
|
const expectedURL = jobURL(job);
|
|
|
|
const request = server.pretender.handledRequests
|
|
|
|
.filterBy('method', 'POST')
|
2021-12-28 14:45:20 +00:00
|
|
|
.find((req) => req.url === expectedURL);
|
2018-08-24 20:18:10 +00:00
|
|
|
|
|
|
|
const requestPayload = JSON.parse(request.requestBody).Job;
|
|
|
|
|
|
|
|
assert.ok(request, 'POST URL was made correctly');
|
2021-12-28 16:08:12 +00:00
|
|
|
assert.ok(
|
|
|
|
requestPayload.Stop == null,
|
|
|
|
'The Stop signal is not sent in the POST request'
|
|
|
|
);
|
2018-08-24 20:18:10 +00:00
|
|
|
}
|
|
|
|
|
2019-07-23 19:40:32 +00:00
|
|
|
export async function expectError(assert, title) {
|
|
|
|
assert.equal(
|
|
|
|
find('[data-test-job-error-title]').textContent,
|
|
|
|
title,
|
|
|
|
'Appropriate error is shown'
|
|
|
|
);
|
|
|
|
assert.ok(
|
|
|
|
find('[data-test-job-error-body]').textContent.includes('ACL'),
|
|
|
|
'The error message mentions ACLs'
|
|
|
|
);
|
2018-04-19 21:21:25 +00:00
|
|
|
|
2019-07-23 19:40:32 +00:00
|
|
|
await click('[data-test-job-error-close]');
|
2021-12-28 16:08:12 +00:00
|
|
|
assert.notOk(
|
|
|
|
find('[data-test-job-error-title]'),
|
|
|
|
'Error message is dismissable'
|
|
|
|
);
|
2018-04-19 21:21:25 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
export function expectDeleteRequest(assert, server, job) {
|
|
|
|
const expectedURL = jobURL(job);
|
|
|
|
|
|
|
|
assert.ok(
|
|
|
|
server.pretender.handledRequests
|
|
|
|
.filterBy('method', 'DELETE')
|
2021-12-28 14:45:20 +00:00
|
|
|
.find((req) => req.url === expectedURL),
|
2018-04-19 21:21:25 +00:00
|
|
|
'DELETE URL was made correctly'
|
|
|
|
);
|
|
|
|
}
|