Skip to content

Commit

Permalink
ui: fix job dispatch page when job doesn't have any meta fields (#10934)
Browse files Browse the repository at this point in the history
  • Loading branch information
lgfa29 committed Aug 3, 2021
1 parent 52c37e1 commit 332dc88
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 3 deletions.
6 changes: 3 additions & 3 deletions ui/app/components/job-dispatch.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ export default class JobDispatch extends Component {
super(...arguments);
// Helper for mapping the params into a useable form.
const mapper = (values = [], required) =>
const mapper = (values, required) =>
values.map(
x =>
new MetaField({
Expand All @@ -59,8 +59,8 @@ export default class JobDispatch extends Component {
);
// Fetch the different types of parameters.
const required = mapper(this.args.job.parameterizedDetails.MetaRequired, true);
const optional = mapper(this.args.job.parameterizedDetails.MetaOptional, false);
const required = mapper(this.args.job.parameterizedDetails.MetaRequired || [], true);
const optional = mapper(this.args.job.parameterizedDetails.MetaOptional || [], false);
// Merge them, required before optional.
this.metaFields = required.concat(optional);
Expand Down
14 changes: 14 additions & 0 deletions ui/tests/acceptance/job-dispatch-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,20 @@ module('Acceptance | job dispatch', function(hooks) {
});
});

test('job without meta fields', async function(assert) {
const jobWithoutMeta = server.create('job', 'parameterized', {
status: 'running',
namespaceId: namespace.name,
parameterizedJob: {
MetaRequired: null,
MetaOptional: null,
},
});

await JobDispatch.visit({ id: jobWithoutMeta.id, namespace: namespace.name });
assert.ok(JobDispatch.dispatchButton.isPresent);
});

test('payload text area is hidden when forbidden', async function(assert) {
job.parameterizedJob.Payload = 'forbidden';
job.save();
Expand Down
1 change: 1 addition & 0 deletions ui/tests/pages/jobs/dispatch.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ export default create({
scope: '[data-test-dispatch-button]',
isDisabled: property('disabled'),
click: clickable(),
isPresent: isPresent(),
},

hasError: isVisible('[data-test-dispatch-error]'),
Expand Down

0 comments on commit 332dc88

Please sign in to comment.