From e4842bf366db5473a8b8508c1f3a1a77f8faeae0 Mon Sep 17 00:00:00 2001 From: Stacey Gammon Date: Tue, 1 Aug 2017 10:56:09 -0400 Subject: [PATCH] Make sure no one can show the chrome if the default setting is hidden. add tests Fixes https://github.com/elastic/kibana/issues/13040 --- src/ui/public/chrome/api/controls.js | 4 +++ .../public/chrome/directives/kbn_chrome.html | 1 + test/functional/apps/dashboard/_dashboard.js | 26 +++++++++++++++++++ test/functional/page_objects/common_page.js | 4 ++- 4 files changed, 34 insertions(+), 1 deletion(-) diff --git a/src/ui/public/chrome/api/controls.js b/src/ui/public/chrome/api/controls.js index 771a995474a45..6405f00562362 100644 --- a/src/ui/public/chrome/api/controls.js +++ b/src/ui/public/chrome/api/controls.js @@ -19,6 +19,10 @@ export default function (chrome, internals) { * @return {chrome} */ chrome.setVisible = function (display) { + if (!def) { + // If the default chrome visibility is off, we don't want it to ever appear. + return; + } internals.visible = Boolean(display); return chrome; }; diff --git a/src/ui/public/chrome/directives/kbn_chrome.html b/src/ui/public/chrome/directives/kbn_chrome.html index 6aaa3bc54ee6a..1d6a34e84bfd6 100644 --- a/src/ui/public/chrome/directives/kbn_chrome.html +++ b/src/ui/public/chrome/directives/kbn_chrome.html @@ -1,6 +1,7 @@
{ + it('hides the chrome', async () => { + let isChromeVisible = await PageObjects.common.isChromeVisible(); + expect(isChromeVisible).to.be(true); + + const currentUrl = await remote.getCurrentUrl(); + const newUrl = currentUrl + '&embed=true'; + // Embed parameter only works on a hard refresh. + const useTimeStamp = true; + await remote.get(newUrl.toString(), useTimeStamp); + + await retry.try(async () => { + isChromeVisible = await PageObjects.common.isChromeVisible(); + expect(isChromeVisible).to.be(false); + }); + }); + + after(async function () { + const currentUrl = await remote.getCurrentUrl(); + const newUrl = currentUrl.replace('&embed=true', ''); + // Remove the timestamp so the rest of the tests retain state across app navigation. + const useTimeStamp = false; + await remote.get(newUrl.toString(), useTimeStamp); + }); + }); + describe('add new visualization link', () => { it('adds a new visualization', async () => { await PageObjects.dashboard.clickAddVisualization(); diff --git a/test/functional/page_objects/common_page.js b/test/functional/page_objects/common_page.js index 56714a95b3047..7e093da521a86 100644 --- a/test/functional/page_objects/common_page.js +++ b/test/functional/page_objects/common_page.js @@ -257,7 +257,9 @@ export function CommonPageProvider({ getService, getPageObjects }) { } async isChromeVisible() { - return await testSubjects.exists('kibanaChrome'); + const globalNavShown = await testSubjects.exists('globalNav'); + const topNavShown = await testSubjects.exists('top-nav'); + return globalNavShown && topNavShown; } async waitForTopNavToBeVisible() {