Skip to content

Commit

Permalink
Make sure no one can show the chrome if the default setting is hidden.
Browse files Browse the repository at this point in the history
add tests

Fixes elastic#13040
  • Loading branch information
stacey-gammon committed Aug 1, 2017
1 parent d36080b commit e4842bf
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 1 deletion.
4 changes: 4 additions & 0 deletions src/ui/public/chrome/api/controls.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
};
Expand Down
1 change: 1 addition & 0 deletions src/ui/public/chrome/directives/kbn_chrome.html
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<div class="content" chrome-context data-test-subj="kibanaChrome">
<global-nav
chrome="chrome"
data-test-subj="globalNav"
is-visible="chrome.getVisible()"
logo-brand="chrome.getBrand('logo')"
small-logo-brand="chrome.getBrand('smallLogo')"
Expand Down
26 changes: 26 additions & 0 deletions test/functional/apps/dashboard/_dashboard.js
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,32 @@ export default function ({ getService, getPageObjects }) {
});
});

describe('embed mode', () => {
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();
Expand Down
4 changes: 3 additions & 1 deletion test/functional/page_objects/common_page.js
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down

0 comments on commit e4842bf

Please sign in to comment.