334e16a6cf
1. All {{ivy-codemirror}} components need 'refreshing' when they become
visible via our own `didAppear` method on the `{{code-editor}}`
component
(also see:)
- https://github.com/hashicorp/consul/pull/4190#discussion_r193270223
- 73db111db8 (r225264296)
2. On initial investigation, it looks like the component we are using
for the code editor doesn't distinguish between setting its `value`
programatically and a `keyup` event, i.e. an interaction from the user.
We currently pretend that whenever its `value` changes, it is a `keyup`
event. This means that when we reset the `value` to `""`
programmatically for form resetting purposes, a 'pretend keyup' event
would also be fired, which would in turn kick off the validation, which
would fail and show an error message for empty values in other fields of
the form - something that is perfectly valid if you haven't typed
anything yet. We solved this by checking for `isPristine` on fields that
are allowed to be empty before you have typed anything.
22 lines
699 B
JavaScript
22 lines
699 B
JavaScript
export default function(scenario, assert, find, currentPage) {
|
|
scenario.then('I see the $property form with yaml\n$yaml', function(property, data) {
|
|
try {
|
|
let obj;
|
|
try {
|
|
obj = find(property);
|
|
} catch (e) {
|
|
obj = currentPage();
|
|
}
|
|
return Object.keys(data).reduce(function(prev, item, i, arr) {
|
|
const name = `${obj.prefix || property}[${item}]`;
|
|
const $el = document.querySelector(`[name="${name}"]`);
|
|
const actual = $el.value;
|
|
const expected = data[item];
|
|
assert.strictEqual(actual, expected, `Expected settings to be ${expected} was ${actual}`);
|
|
}, obj);
|
|
} catch (e) {
|
|
throw e;
|
|
}
|
|
});
|
|
}
|