-
Notifications
You must be signed in to change notification settings - Fork 8.3k
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
[SOM] Preserve saved object references when saving the object #66584
[SOM] Preserve saved object references when saving the object #66584
Conversation
Pinging @elastic/kibana-platform (Team:Platform) |
// Special handling for references which isn't within "attributes" | ||
fields = [...fields, ...createFields('references', object.references)]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This was missed when migrating from legacy.
Ideally, we would create fields with full path instead of assuming all fields are in attributes
to avoid that kind of hack (that would break for example if a given editable SO type had a references
attributes), but this is outside of the scope of this mere fix.
return browser.execute( | ||
(editor: string, value: string) => { | ||
return (window as any).ace.edit(editor).setValue(value); | ||
}, | ||
editorId, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Using the ace
API from the browser side instead of performing 'real' user interactions is far from ideal, however as ace
autocompletes user input (for example, user type [
, ace automatically adds the closing ]
), it was just over complicated to use focus
+ sendKeys
, so this will have to be good enough.
Same things with getAceEditorFieldValue
: parsing the text content from the ace editor structure is a pain.
@@ -99,5 +121,48 @@ export default function({ getPageObjects, getService }: FtrProviderContext) { | |||
const objects = await PageObjects.settings.getSavedObjectsInTable(); | |||
expect(objects.includes('A Dashboard')).to.be(false); | |||
}); | |||
|
|||
it('preserves the object references when saving', async () => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
testing that references are properly displayed and preserved during save
, then testing that updating the references actually works.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tested locally and it worked! Few nits / questions on test, but otherwise LGTM
expect(JSON.parse(await getAceEditorFieldValue('references'))).to.eql( | ||
JSON.parse(referencesValue) | ||
); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are we just parsing to ensure that key order doesn't effect the test outcome? Might be good to comment as such.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Correct assumption. We were getting the key in arbitrary order here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unfortunately this check doesn't prevent again this regression. The references
text was rendered already as an empty array before this patch, clicking saving and checking the results will not discover if we are facing this issue again.
IMHO I think it's better to check, if possible, the presence of the references
array directly on the saved object from ES, or somewhere else on the UI
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if possible, the presence of the references array directly on the saved object from ES, or somewhere else on the UI
- from ES: Unfortunately this is not possible from an e2e test.
- somewhere else on the UI: AFAIK we are not displaying
references
anywhere expect in the SOM edition page.
As we control the source data for the test however, I can assert that the displayed relations matches the references from the dataset.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
dataset/assertion modified in d453272
await PageObjects.settings.navigateTo(); | ||
await PageObjects.settings.clickKibanaSavedObjects(); | ||
|
||
let objects = await PageObjects.settings.getSavedObjectsInTable(); | ||
expect(objects.includes('A Pie')).to.be(true); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These steps don't seem necessary for this test?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This was mostly to insert webdriver implicit timing to wait for the listing page.
I will replace this with just await PageObjects.settings.getSavedObjectsInTable()
objects = await PageObjects.settings.getSavedObjectsInTable(); | ||
expect(objects.includes('A Pie')).to.be(true); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we need to do this again?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've left a comment on the functional test, we should probably revisit it to avoid this regression again in the future
expect(JSON.parse(await getAceEditorFieldValue('references'))).to.eql( | ||
JSON.parse(referencesValue) | ||
); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unfortunately this check doesn't prevent again this regression. The references
text was rendered already as an empty array before this patch, clicking saving and checking the results will not discover if we are facing this issue again.
IMHO I think it's better to check, if possible, the presence of the references
array directly on the saved object from ES, or somewhere else on the UI
💚 Build SucceededHistory
To update your PR or re-run it, just comment with: |
…c#66584) * create field for references and add comments * add FTR test * remove comments * address comments * use real reference in dataset and assert against it.
…c#66584) * create field for references and add comments * add FTR test * remove comments * address comments * use real reference in dataset and assert against it.
…c#66584) * create field for references and add comments * add FTR test * remove comments * address comments * use real reference in dataset and assert against it. # Conflicts: # src/plugins/saved_objects_management/public/lib/create_field_list.test.ts # src/plugins/saved_objects_management/public/lib/create_field_list.ts # src/plugins/saved_objects_management/public/management_section/object_view/components/field.tsx # src/plugins/saved_objects_management/public/management_section/object_view/components/form.tsx
#66843) * create field for references and add comments * add FTR test * remove comments * address comments * use real reference in dataset and assert against it.
#66844) * create field for references and add comments * add FTR test * remove comments * address comments * use real reference in dataset and assert against it.
#66845) * create field for references and add comments * add FTR test * remove comments * address comments * use real reference in dataset and assert against it. # Conflicts: # src/plugins/saved_objects_management/public/lib/create_field_list.test.ts # src/plugins/saved_objects_management/public/lib/create_field_list.ts # src/plugins/saved_objects_management/public/management_section/object_view/components/field.tsx # src/plugins/saved_objects_management/public/management_section/object_view/components/form.tsx
…ine-editor * 'master' of github.com:elastic/kibana: (157 commits) [ML] fix url assertion (#66850) Skip failing lens test(s). #66779 [SOM] Preserve saved object references when saving the object (#66584) Use ES API from start contract (#66157) Reorganize Management apps into Ingest, Data, Alerts and Insights, Security, Kibana, and Stack groups (#65796) [Uptime] Fix flaky navigation to certs page in tests (#66806) [Maps] Do not check count for blended layers when layer is not visible (#66460) [SIEM] Fixes glob patterns from directory changes recently for GraphQL chore(NA): bump static-fs to 1.0.2 (#66775) [Maps] Handle cross cluster index _settings resp (#66797) [SIEM][Lists] Adds 90% of the REST API and client API for exception lists and exception items allow any type for customResponseHeaders config (#66689) [APM] Disable map layout animation (#66763) [ML] Add linking to dataframe from job management tab (#65778) [Maps] Get number of categories from palette (#66454) move oss features registration to KP (#66524) [kbn/plugin-helpers] typescript-ify (#66513) Add kibana-operations as codeowners for .ci/es-snapshots and vars/ (#66746) FTR: move basic services under common folder (#66563) Migrate Beats Management UI to KP (#65791) ... # Conflicts: # x-pack/plugins/ingest_pipelines/public/application/components/pipeline_form/pipeline_form.tsx # x-pack/plugins/ingest_pipelines/public/application/components/pipeline_form/pipeline_form_fields.tsx
* master: [ML] fix url assertion (elastic#66850) Skip failing lens test(s). elastic#66779 [SOM] Preserve saved object references when saving the object (elastic#66584) Use ES API from start contract (elastic#66157) Reorganize Management apps into Ingest, Data, Alerts and Insights, Security, Kibana, and Stack groups (elastic#65796) [Uptime] Fix flaky navigation to certs page in tests (elastic#66806) [Maps] Do not check count for blended layers when layer is not visible (elastic#66460) [SIEM] Fixes glob patterns from directory changes recently for GraphQL chore(NA): bump static-fs to 1.0.2 (elastic#66775) [Maps] Handle cross cluster index _settings resp (elastic#66797) [SIEM][Lists] Adds 90% of the REST API and client API for exception lists and exception items allow any type for customResponseHeaders config (elastic#66689) [APM] Disable map layout animation (elastic#66763) [ML] Add linking to dataframe from job management tab (elastic#65778)
Summary
Fix #66542
Fix a bug causing the edition of a saved objects from the
management
section to removes all itsreferences
, resulting in a corrupted object.