Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ui: fix job dispatch page when job doesn't have any meta fields #10934

Merged
merged 1 commit into from
Aug 3, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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) =>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why are we removing the default parameter on this function?

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