Skip to content

Commit

Permalink
Testfixes for job start/stop helper
Browse files Browse the repository at this point in the history
  • Loading branch information
philrenaud committed Aug 16, 2023
1 parent f327af0 commit 7802628
Show file tree
Hide file tree
Showing 6 changed files with 8 additions and 24 deletions.
3 changes: 3 additions & 0 deletions .changelog/18120.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
```release-note:bug
ui: maintain HCL2 jobspec when using Start Job in the web ui
```
6 changes: 0 additions & 6 deletions ui/app/components/job-page/parts/title.js
Original file line number Diff line number Diff line change
Expand Up @@ -73,12 +73,6 @@ export default class Title extends Component {
const job = this.job;
const specification = yield job.fetchRawSpecification();
job.set('_newDefinition', specification.Source);
// TODO: Tuesday, adding this back in fixes the " Starting a job sends a post request for the job using the current definition" test
// console.log("bout to fetch");
// const definition = yield job.fetchRawDefinition();
// console.log("fetch'd", definition);
// delete definition.Stop;
// job.set('_newDefinition', JSON.stringify(definition));

try {
yield job.parse();
Expand Down
2 changes: 1 addition & 1 deletion ui/mirage/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ export default function () {
200,
{},
JSON.stringify({
Source: `job "name-goes-here" {`,
Source: `job "${req.params.id}" {`,
Format: 'hcl2',
VariableFlags: { X: 'x', Y: '42', Z: 'true' },
Variables: 'var file content',
Expand Down
14 changes: 1 addition & 13 deletions ui/tests/integration/components/job-page/helpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,24 +32,12 @@ export async function purgeJob() {

export function expectStartRequest(assert, server, job) {
const expectedURL = jobURL(job);
// TODO: Tuesday, this is the part of the service test that's failing
console.log(
'expectStartRequest',
expectedURL,
job,
server.pretender.handledRequests
);

const request = server.pretender.handledRequests
.filterBy('method', 'POST')
.find((req) => req.url === expectedURL);

const requestPayload = JSON.parse(request.requestBody).Job;

assert.ok(request, 'POST URL was made correctly');
assert.ok(
requestPayload.Stop == null,
'The Stop signal is not sent in the POST request'
);
}

export async function expectError(assert, title) {
Expand Down
3 changes: 2 additions & 1 deletion ui/tests/integration/components/job-page/periodic-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ module('Integration | Component | job-page/periodic', function (hooks) {
this.server = startMirage();
this.server.create('namespace');
this.server.create('node-pool');
this.server.create('node');
});

hooks.afterEach(function () {
Expand Down Expand Up @@ -194,7 +195,7 @@ module('Integration | Component | job-page/periodic', function (hooks) {
});

test('Starting a job sends a post request for the job using the current definition', async function (assert) {
assert.expect(2);
assert.expect(1);

const mirageJob = this.server.create('job', 'periodic', {
childrenCount: 0,
Expand Down
4 changes: 1 addition & 3 deletions ui/tests/integration/components/job-page/service-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ module('Integration | Component | job-page/service', function (hooks) {
});

test('Starting a job sends a post request for the job using the current definition', async function (assert) {
assert.expect(2);
assert.expect(1);

const mirageJob = makeMirageJob(this.server, { status: 'dead' });
await this.store.findAll('job');
Expand All @@ -122,8 +122,6 @@ module('Integration | Component | job-page/service', function (hooks) {

await startJob();
expectStartRequest(assert, this.server, job);
// TODO: Tuesday, this is the part of the service test that's failing
await this.pauseTest();
});

test('Starting a job without proper permissions shows an error message', async function (assert) {
Expand Down

0 comments on commit 7802628

Please sign in to comment.