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

[Dashboard] Fix "Unlink from library" panel title bug #156589

Merged
merged 7 commits into from
May 5, 2023

Conversation

Heenawter
Copy link
Contributor

@Heenawter Heenawter commented May 3, 2023

Closes #156539
Closes #156544

Summary

As part of investigating the attached flaky test suite, I realized that the flakiness was because we weren't waiting long enough for a panel to be added and/or removed from the library - so, I added a check to ensure the library notification appears in saveToLibrary, and similarly I added a check to ensure that the library notification disappears in unlinkFromLibary.

However, after adding these extra checks, the following test started to fail:

it('unlinking a by reference panel with a custom title will keep the current title', async () => {
await dashboardPanelActions.customizePanel();
await dashboardCustomizePanel.setCustomPanelTitle(CUSTOM_TITLE);
await dashboardCustomizePanel.clickSaveButton();
await dashboardPanelActions.unlinkFromLibary();
const newPanelTitle = (await PageObjects.dashboard.getPanelTitles())[0];
expect(newPanelTitle).to.equal(CUSTOM_TITLE);
});

Way, way, way back in 8.1, one of my first PRs was meant to fix some problems with dashboard panel titles - as part of this, I was supposed to make sure that, if a by-reference panel is given a custom panel title, the title should remain the same after unlinking (i.e. it should remain as the custom title rather than resetting to the by-reference title). So, I added the above test to verify this behaviour.

Turns out, though, that this test had a flaw - because we weren't waiting long enough for the panel to actually be disconnected from the library, this test was only passing because it was grabbing and comparing titles before the unlink was complete - so, even though the title actually was being reset back to the original library title, this test did not catch this bug. This has been the case since 8.1 when this test was introduced - not sure how it was missed, but we never actually fixed the bug where dashboard panel titles are getting reset when unlinking from the library.

So, this PR actually accomplishes two things:

  1. It fixes the flakiness of the attached tests by adding the extra library notification checks:
  2. It ensures that, if a by-reference panel has a custom title, unlinking it from the library will not impact that title.

Before

Screen.Recording.2023-05-03.at.4.19.44.PM.mov

After

Screen.Recording.2023-05-03.at.4.21.09.PM.mov

Checklist

For maintainers

@Heenawter Heenawter added bug Fixes for quality problems that affect the customer experience release_note:fix Team:Presentation Presentation Team for Dashboard, Input Controls, and Canvas loe:medium Medium Level of Effort impact:high Addressing this issue will have a high level of impact on the quality/strength of our product. v8.9.0 labels May 3, 2023
@Heenawter Heenawter self-assigned this May 3, 2023
const { savedObjectId, ...originalInputToPropagate } = input;

return {
...originalInputToPropagate,
// by value visualizations should not have default titles and/or descriptions
...{ attributes: omit(attributes, ['title', 'description']) },
title: libraryTitle,
Copy link
Contributor Author

@Heenawter Heenawter May 4, 2023

Choose a reason for hiding this comment

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

This was added as part of #122199 - I tried to find justification for this in the original PR, but couldn't find anything. So, after digging into my Slack discussions with @ThomThomson at the time, I believe this may have been left in accidentally.

Basically, since saved searches can only ever be cloned by reference, I wasn't sure how to handle custom titles when they were cloned - should they reflect the library title, or the custom title? I originally went with displaying the library title to make it clear that this object was cloned by reference, but @ThomThomson brought up that this might be confusing and was a fairly niche scenario - so ultimately, we decided that a saved search with a custom title, when cloned, should display the custom title in the dashboard while the cloned saved object would still be under the library title. This is what that looks like now:

Screen.Recording.2023-05-04.at.10.28.22.AM.mov

As mentioned, my best guess is that this line may have been left in accidentally when exploring these options (although this would have been silly, because getInputAsValueType isn't even called when cloning saved search embeddables since they are cloned by reference... 🤷) and, because the test meant to catch this was not working as expected, we didn't catch it at the time.

I've tested a bunch of different custom title + cloning scenarios, and I can't think of any reason this line would be necessary... So I think it's safe to remove so that we can get the desired behaviour when unlinking panels.

Comment on lines -254 to -255
await testSubjects.click('confirmSaveSavedObjectButton');
await testSubjects.existOrFail('addPanelToLibrarySuccess');
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Now that we are waiting for the object to be added to the library as part of the saveToLibrary method, this was causing a failure because the 'confirmSaveSavedObjectButton' was no longer present on the screen.

@Heenawter Heenawter marked this pull request as ready for review May 4, 2023 16:31
@Heenawter Heenawter requested review from a team as code owners May 4, 2023 16:31
@elasticmachine
Copy link
Contributor

Pinging @elastic/kibana-presentation (Team:Presentation)

@Heenawter Heenawter added the backport:prev-minor Backport to (8.x) the previous minor version (i.e. one version back from main) label May 4, 2023
@botelastic botelastic bot added the Feature:Embedding Embedding content via iFrame label May 4, 2023
@kibana-ci
Copy link
Collaborator

💚 Build Succeeded

Metrics [docs]

Page load bundle

Size of the bundles that are downloaded on every page load. Target size is below 100kb

id before after diff
embeddable 75.7KB 75.7KB -18.0B
Unknown metric groups

ESLint disabled line counts

id before after diff
enterpriseSearch 19 21 +2
securitySolution 398 401 +3
total +5

Total ESLint disabled count

id before after diff
enterpriseSearch 20 22 +2
securitySolution 478 481 +3
total +5

History

To update your PR or re-run it, just comment with:
@elasticmachine merge upstream

cc @Heenawter

@nreese nreese self-requested a review May 4, 2023 17:54
Copy link
Contributor

@nreese nreese left a comment

Choose a reason for hiding this comment

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

LGTM thanks for unskipping this test so quickly. Great to see tests getting re-enabled.
code review only

Copy link
Contributor

@stratoula stratoula left a comment

Choose a reason for hiding this comment

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

Changes LGTM, code review only!

@Heenawter Heenawter merged commit ce7ef40 into elastic:main May 5, 2023
@Heenawter Heenawter deleted the fix-flaky-test-156539 branch May 5, 2023 14:54
kibanamachine pushed a commit to kibanamachine/kibana that referenced this pull request May 5, 2023
Closes elastic#156539
Closes elastic#156544

## Summary

As part of investigating the attached flaky test suite, I realized that
the flakiness was because we weren't waiting long enough for a panel to
be added and/or removed from the library - so, I added a check to ensure
the library notification appears in `saveToLibrary`, and similarly I
added a check to ensure that the library notification **disappears** in
`unlinkFromLibary`.

However, after adding these extra checks, the following test started to
fail:

https://github.com/elastic/kibana/blob/23a45bde21b36be49a1174b9bde1fc340de67534/x-pack/test/functional/apps/dashboard/group2/panel_titles.ts#L148-L155

Way, way, way back in `8.1`, one of my [first
PRs](elastic#120815) was meant to fix
some problems with dashboard panel titles - as part of this, I was
**supposed** to make sure that, if a by-reference panel is given a
custom panel title, the title should remain the same after unlinking
(i.e. it should remain as the custom title rather than resetting to the
by-reference title). So, I added the above test to verify this
behaviour.

Turns out, though, that this test had a flaw - because we weren't
waiting long enough for the panel to actually be disconnected from the
library, this test was only passing because it was grabbing and
comparing titles **before** the unlink was complete - so, even though
the title actually **was** being reset back to the original library
title, this test did not catch this bug. This has been the case since
`8.1` when this test was introduced - not sure how it was missed, but we
never actually fixed the bug where dashboard panel titles are getting
reset when unlinking from the library.

So, this PR actually accomplishes two things:
1) It fixes the flakiness of the attached tests by adding the extra
library notification checks:
<a
href="https://buildkite.com/elastic/kibana-flaky-test-suite-runner/builds/2217"><img
src="https://user-images.githubusercontent.com/8698078/236044233-8a07aadc-8a55-40f2-9ed2-798a91501f68.png"/></a>
2) It ensures that, if a by-reference panel has a custom title,
unlinking it from the library will not impact that title.

### Before

https://user-images.githubusercontent.com/8698078/236062484-b1cedc47-cb19-4273-aec7-17d24b55953b.mov

### After

https://user-images.githubusercontent.com/8698078/236062862-aace4f09-d007-401a-ba57-b9b74fda0b33.mov

### Checklist

- [x] [Unit or functional
tests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)
were updated or added to match the most common scenarios
- [x] This was checked for [cross-browser
compatibility](https://www.elastic.co/support/matrix#matrix_browsers)

### For maintainers

- [ ] This was checked for breaking API changes and was [labeled
appropriately](https://www.elastic.co/guide/en/kibana/master/contributing.html#kibana-release-notes-process)

(cherry picked from commit ce7ef40)
@kibanamachine
Copy link
Contributor

💚 All backports created successfully

Status Branch Result
8.8

Note: Successful backport PRs will be merged automatically after passing CI.

Questions ?

Please refer to the Backport tool documentation

kibanamachine added a commit that referenced this pull request May 5, 2023
…#156871)

# Backport

This will backport the following commits from `main` to `8.8`:
- [[Dashboard] Fix "Unlink from library" panel title bug
(#156589)](#156589)

<!--- Backport version: 8.9.7 -->

### Questions ?
Please refer to the [Backport tool
documentation](https://github.com/sqren/backport)

<!--BACKPORT [{"author":{"name":"Hannah
Mudge","email":"Heenawter@users.noreply.github.com"},"sourceCommit":{"committedDate":"2023-05-05T14:54:39Z","message":"[Dashboard]
Fix \"Unlink from library\" panel title bug (#156589)\n\nCloses
https://github.com/elastic/kibana/issues/156539\r\nCloses
https://github.com/elastic/kibana/issues/156544\r\n\r\n##
Summary\r\n\r\n\r\nAs part of investigating the attached flaky test
suite, I realized that\r\nthe flakiness was because we weren't waiting
long enough for a panel to\r\nbe added and/or removed from the library -
so, I added a check to ensure\r\nthe library notification appears in
`saveToLibrary`, and similarly I\r\nadded a check to ensure that the
library notification **disappears**
in\r\n`unlinkFromLibary`.\r\n\r\nHowever, after adding these extra
checks, the following test started
to\r\nfail:\r\n\r\n\r\nhttps://github.com/elastic/kibana/blob/23a45bde21b36be49a1174b9bde1fc340de67534/x-pack/test/functional/apps/dashboard/group2/panel_titles.ts#L148-L155\r\n\r\nWay,
way, way back in `8.1`, one of my
[first\r\nPRs](#120815) was meant
to fix\r\nsome problems with dashboard panel titles - as part of this, I
was\r\n**supposed** to make sure that, if a by-reference panel is given
a\r\ncustom panel title, the title should remain the same after
unlinking\r\n(i.e. it should remain as the custom title rather than
resetting to the\r\nby-reference title). So, I added the above test to
verify this\r\nbehaviour.\r\n\r\nTurns out, though, that this test had a
flaw - because we weren't\r\nwaiting long enough for the panel to
actually be disconnected from the\r\nlibrary, this test was only passing
because it was grabbing and\r\ncomparing titles **before** the unlink
was complete - so, even though\r\nthe title actually **was** being reset
back to the original library\r\ntitle, this test did not catch this bug.
This has been the case since\r\n`8.1` when this test was introduced -
not sure how it was missed, but we\r\nnever actually fixed the bug where
dashboard panel titles are getting\r\nreset when unlinking from the
library.\r\n\r\nSo, this PR actually accomplishes two things:\r\n1) It
fixes the flakiness of the attached tests by adding the extra\r\nlibrary
notification
checks:\r\n<a\r\nhref=\"https://buildkite.com/elastic/kibana-flaky-test-suite-runner/builds/2217\"><img\r\nsrc=\"https://user-images.githubusercontent.com/8698078/236044233-8a07aadc-8a55-40f2-9ed2-798a91501f68.png\"/></a>\r\n2)
It ensures that, if a by-reference panel has a custom
title,\r\nunlinking it from the library will not impact that
title.\r\n\r\n###
Before\r\n\r\n\r\nhttps://user-images.githubusercontent.com/8698078/236062484-b1cedc47-cb19-4273-aec7-17d24b55953b.mov\r\n\r\n\r\n###
After\r\n\r\n\r\nhttps://user-images.githubusercontent.com/8698078/236062862-aace4f09-d007-401a-ba57-b9b74fda0b33.mov\r\n\r\n\r\n\r\n###
Checklist\r\n\r\n- [x] [Unit or
functional\r\ntests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)\r\nwere
updated or added to match the most common scenarios\r\n- [x] This was
checked for
[cross-browser\r\ncompatibility](https://www.elastic.co/support/matrix#matrix_browsers)\r\n\r\n###
For maintainers\r\n\r\n- [ ] This was checked for breaking API changes
and was
[labeled\r\nappropriately](https://www.elastic.co/guide/en/kibana/master/contributing.html#kibana-release-notes-process)","sha":"ce7ef40d9a79313be64057af6fb7f143a44a434a","branchLabelMapping":{"^v8.9.0$":"main","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["bug","Feature:Embedding","release_note:fix","Team:Presentation","loe:days","impact:high","backport:prev-minor","v8.9.0"],"number":156589,"url":"https://github.com/elastic/kibana/pull/156589","mergeCommit":{"message":"[Dashboard]
Fix \"Unlink from library\" panel title bug (#156589)\n\nCloses
https://github.com/elastic/kibana/issues/156539\r\nCloses
https://github.com/elastic/kibana/issues/156544\r\n\r\n##
Summary\r\n\r\n\r\nAs part of investigating the attached flaky test
suite, I realized that\r\nthe flakiness was because we weren't waiting
long enough for a panel to\r\nbe added and/or removed from the library -
so, I added a check to ensure\r\nthe library notification appears in
`saveToLibrary`, and similarly I\r\nadded a check to ensure that the
library notification **disappears**
in\r\n`unlinkFromLibary`.\r\n\r\nHowever, after adding these extra
checks, the following test started
to\r\nfail:\r\n\r\n\r\nhttps://github.com/elastic/kibana/blob/23a45bde21b36be49a1174b9bde1fc340de67534/x-pack/test/functional/apps/dashboard/group2/panel_titles.ts#L148-L155\r\n\r\nWay,
way, way back in `8.1`, one of my
[first\r\nPRs](#120815) was meant
to fix\r\nsome problems with dashboard panel titles - as part of this, I
was\r\n**supposed** to make sure that, if a by-reference panel is given
a\r\ncustom panel title, the title should remain the same after
unlinking\r\n(i.e. it should remain as the custom title rather than
resetting to the\r\nby-reference title). So, I added the above test to
verify this\r\nbehaviour.\r\n\r\nTurns out, though, that this test had a
flaw - because we weren't\r\nwaiting long enough for the panel to
actually be disconnected from the\r\nlibrary, this test was only passing
because it was grabbing and\r\ncomparing titles **before** the unlink
was complete - so, even though\r\nthe title actually **was** being reset
back to the original library\r\ntitle, this test did not catch this bug.
This has been the case since\r\n`8.1` when this test was introduced -
not sure how it was missed, but we\r\nnever actually fixed the bug where
dashboard panel titles are getting\r\nreset when unlinking from the
library.\r\n\r\nSo, this PR actually accomplishes two things:\r\n1) It
fixes the flakiness of the attached tests by adding the extra\r\nlibrary
notification
checks:\r\n<a\r\nhref=\"https://buildkite.com/elastic/kibana-flaky-test-suite-runner/builds/2217\"><img\r\nsrc=\"https://user-images.githubusercontent.com/8698078/236044233-8a07aadc-8a55-40f2-9ed2-798a91501f68.png\"/></a>\r\n2)
It ensures that, if a by-reference panel has a custom
title,\r\nunlinking it from the library will not impact that
title.\r\n\r\n###
Before\r\n\r\n\r\nhttps://user-images.githubusercontent.com/8698078/236062484-b1cedc47-cb19-4273-aec7-17d24b55953b.mov\r\n\r\n\r\n###
After\r\n\r\n\r\nhttps://user-images.githubusercontent.com/8698078/236062862-aace4f09-d007-401a-ba57-b9b74fda0b33.mov\r\n\r\n\r\n\r\n###
Checklist\r\n\r\n- [x] [Unit or
functional\r\ntests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)\r\nwere
updated or added to match the most common scenarios\r\n- [x] This was
checked for
[cross-browser\r\ncompatibility](https://www.elastic.co/support/matrix#matrix_browsers)\r\n\r\n###
For maintainers\r\n\r\n- [ ] This was checked for breaking API changes
and was
[labeled\r\nappropriately](https://www.elastic.co/guide/en/kibana/master/contributing.html#kibana-release-notes-process)","sha":"ce7ef40d9a79313be64057af6fb7f143a44a434a"}},"sourceBranch":"main","suggestedTargetBranches":[],"targetPullRequestStates":[{"branch":"main","label":"v8.9.0","labelRegex":"^v8.9.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/156589","number":156589,"mergeCommit":{"message":"[Dashboard]
Fix \"Unlink from library\" panel title bug (#156589)\n\nCloses
https://github.com/elastic/kibana/issues/156539\r\nCloses
https://github.com/elastic/kibana/issues/156544\r\n\r\n##
Summary\r\n\r\n\r\nAs part of investigating the attached flaky test
suite, I realized that\r\nthe flakiness was because we weren't waiting
long enough for a panel to\r\nbe added and/or removed from the library -
so, I added a check to ensure\r\nthe library notification appears in
`saveToLibrary`, and similarly I\r\nadded a check to ensure that the
library notification **disappears**
in\r\n`unlinkFromLibary`.\r\n\r\nHowever, after adding these extra
checks, the following test started
to\r\nfail:\r\n\r\n\r\nhttps://github.com/elastic/kibana/blob/23a45bde21b36be49a1174b9bde1fc340de67534/x-pack/test/functional/apps/dashboard/group2/panel_titles.ts#L148-L155\r\n\r\nWay,
way, way back in `8.1`, one of my
[first\r\nPRs](#120815) was meant
to fix\r\nsome problems with dashboard panel titles - as part of this, I
was\r\n**supposed** to make sure that, if a by-reference panel is given
a\r\ncustom panel title, the title should remain the same after
unlinking\r\n(i.e. it should remain as the custom title rather than
resetting to the\r\nby-reference title). So, I added the above test to
verify this\r\nbehaviour.\r\n\r\nTurns out, though, that this test had a
flaw - because we weren't\r\nwaiting long enough for the panel to
actually be disconnected from the\r\nlibrary, this test was only passing
because it was grabbing and\r\ncomparing titles **before** the unlink
was complete - so, even though\r\nthe title actually **was** being reset
back to the original library\r\ntitle, this test did not catch this bug.
This has been the case since\r\n`8.1` when this test was introduced -
not sure how it was missed, but we\r\nnever actually fixed the bug where
dashboard panel titles are getting\r\nreset when unlinking from the
library.\r\n\r\nSo, this PR actually accomplishes two things:\r\n1) It
fixes the flakiness of the attached tests by adding the extra\r\nlibrary
notification
checks:\r\n<a\r\nhref=\"https://buildkite.com/elastic/kibana-flaky-test-suite-runner/builds/2217\"><img\r\nsrc=\"https://user-images.githubusercontent.com/8698078/236044233-8a07aadc-8a55-40f2-9ed2-798a91501f68.png\"/></a>\r\n2)
It ensures that, if a by-reference panel has a custom
title,\r\nunlinking it from the library will not impact that
title.\r\n\r\n###
Before\r\n\r\n\r\nhttps://user-images.githubusercontent.com/8698078/236062484-b1cedc47-cb19-4273-aec7-17d24b55953b.mov\r\n\r\n\r\n###
After\r\n\r\n\r\nhttps://user-images.githubusercontent.com/8698078/236062862-aace4f09-d007-401a-ba57-b9b74fda0b33.mov\r\n\r\n\r\n\r\n###
Checklist\r\n\r\n- [x] [Unit or
functional\r\ntests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)\r\nwere
updated or added to match the most common scenarios\r\n- [x] This was
checked for
[cross-browser\r\ncompatibility](https://www.elastic.co/support/matrix#matrix_browsers)\r\n\r\n###
For maintainers\r\n\r\n- [ ] This was checked for breaking API changes
and was
[labeled\r\nappropriately](https://www.elastic.co/guide/en/kibana/master/contributing.html#kibana-release-notes-process)","sha":"ce7ef40d9a79313be64057af6fb7f143a44a434a"}}]}]
BACKPORT-->

Co-authored-by: Hannah Mudge <Heenawter@users.noreply.github.com>
smith pushed a commit to smith/kibana that referenced this pull request May 5, 2023
Closes elastic#156539
Closes elastic#156544

## Summary


As part of investigating the attached flaky test suite, I realized that
the flakiness was because we weren't waiting long enough for a panel to
be added and/or removed from the library - so, I added a check to ensure
the library notification appears in `saveToLibrary`, and similarly I
added a check to ensure that the library notification **disappears** in
`unlinkFromLibary`.

However, after adding these extra checks, the following test started to
fail:


https://github.com/elastic/kibana/blob/23a45bde21b36be49a1174b9bde1fc340de67534/x-pack/test/functional/apps/dashboard/group2/panel_titles.ts#L148-L155

Way, way, way back in `8.1`, one of my [first
PRs](elastic#120815) was meant to fix
some problems with dashboard panel titles - as part of this, I was
**supposed** to make sure that, if a by-reference panel is given a
custom panel title, the title should remain the same after unlinking
(i.e. it should remain as the custom title rather than resetting to the
by-reference title). So, I added the above test to verify this
behaviour.

Turns out, though, that this test had a flaw - because we weren't
waiting long enough for the panel to actually be disconnected from the
library, this test was only passing because it was grabbing and
comparing titles **before** the unlink was complete - so, even though
the title actually **was** being reset back to the original library
title, this test did not catch this bug. This has been the case since
`8.1` when this test was introduced - not sure how it was missed, but we
never actually fixed the bug where dashboard panel titles are getting
reset when unlinking from the library.

So, this PR actually accomplishes two things:
1) It fixes the flakiness of the attached tests by adding the extra
library notification checks:
<a
href="https://buildkite.com/elastic/kibana-flaky-test-suite-runner/builds/2217"><img
src="https://user-images.githubusercontent.com/8698078/236044233-8a07aadc-8a55-40f2-9ed2-798a91501f68.png"/></a>
2) It ensures that, if a by-reference panel has a custom title,
unlinking it from the library will not impact that title.

### Before


https://user-images.githubusercontent.com/8698078/236062484-b1cedc47-cb19-4273-aec7-17d24b55953b.mov


### After


https://user-images.githubusercontent.com/8698078/236062862-aace4f09-d007-401a-ba57-b9b74fda0b33.mov



### Checklist

- [x] [Unit or functional
tests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)
were updated or added to match the most common scenarios
- [x] This was checked for [cross-browser
compatibility](https://www.elastic.co/support/matrix#matrix_browsers)

### For maintainers

- [ ] This was checked for breaking API changes and was [labeled
appropriately](https://www.elastic.co/guide/en/kibana/master/contributing.html#kibana-release-notes-process)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport:prev-minor Backport to (8.x) the previous minor version (i.e. one version back from main) bug Fixes for quality problems that affect the customer experience Feature:Embedding Embedding content via iFrame impact:high Addressing this issue will have a high level of impact on the quality/strength of our product. loe:medium Medium Level of Effort release_note:fix Team:Presentation Presentation Team for Dashboard, Input Controls, and Canvas v8.8.0 v8.9.0
Projects
None yet
6 participants