FIX: Empty param-inout form should reject submit (#309)
The `onSubmit` hook will only be triggered when the form is valid, so we need to clear the contents of `serializedData` in advance in `submit`. Otherwise, it may not throw a validation error.
This commit is contained in:
@@ -169,4 +169,36 @@ module("Data Explorer Plugin | Component | param-input", function (hooks) {
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
test("empty form will reject submit", async function (assert) {
|
||||
this.setProperties({
|
||||
param_info: [
|
||||
{
|
||||
identifier: "string",
|
||||
type: "string",
|
||||
default: null,
|
||||
nullable: false,
|
||||
},
|
||||
],
|
||||
initialValues: {},
|
||||
onRegisterApi: ({ submit }) => {
|
||||
this.submit = submit;
|
||||
},
|
||||
});
|
||||
|
||||
await render(hbs`
|
||||
<ParamInputForm
|
||||
@initialValues={{this.initialValues}}
|
||||
@paramInfo={{this.param_info}}
|
||||
@onRegisterApi={{this.onRegisterApi}}
|
||||
/>`);
|
||||
|
||||
assert.rejects(this.submit());
|
||||
|
||||
// After successfully submitting the test once, edit and submit again.
|
||||
await fillIn(`[name="string"]`, "foo");
|
||||
await this.submit();
|
||||
await fillIn(`[name="string"]`, "");
|
||||
assert.rejects(this.submit());
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user