Skip to content

Commit

Permalink
Re-adding emptyState, reintroducing functional test
Browse files Browse the repository at this point in the history
  • Loading branch information
Maja Grubic committed Dec 6, 2019
1 parent 94fd3b3 commit 0b4a66e
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,8 @@ export class DashboardAppController {
if (dashboardContainer && !isErrorEmbeddable(dashboardContainer)) {
expandedPanelId = dashboardContainer.getInput().expandedPanelId;
}
const shouldShowEditHelp = $scope.getShouldShowEditHelp();
const shouldShowViewHelp = $scope.getShouldShowViewHelp();
return {
id: dashboardStateManager.savedDashboard.id || '',
filters: queryFilter.getFilters(),
Expand All @@ -214,6 +216,7 @@ export class DashboardAppController {
viewMode: dashboardStateManager.getViewMode(),
panels: embeddablesMap,
isFullScreenMode: dashboardStateManager.getFullScreenMode(),
isEmptyState: shouldShowEditHelp || shouldShowViewHelp,
useMargins: dashboardStateManager.getUseMargins(),
lastReloadRequestTime,
title: dashboardStateManager.getTitle(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,7 @@ test('renders DashboardViewport with no visualizations', () => {
test('renders DashboardEmptyScreen', () => {
const renderEmptyScreen = jest.fn();
const { props, options } = getProps({ renderEmpty: renderEmptyScreen });
props.container.updateInput({ isEmptyState: true });
const component = mount(
<I18nProvider>
<KibanaContextProvider services={options}>
Expand Down Expand Up @@ -174,7 +175,7 @@ test('renders exit full screen button when in full screen mode and empty screen'
const renderEmptyScreen = jest.fn();
renderEmptyScreen.mockReturnValue(React.createElement('div'));
const { props, options } = getProps({ renderEmpty: renderEmptyScreen });
props.container.updateInput({ isFullScreenMode: true });
props.container.updateInput({ isEmptyState: true, isFullScreenMode: true });
const component = mount(
<I18nProvider>
<KibanaContextProvider services={options}>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ interface State {
title: string;
description?: string;
panels: { [key: string]: PanelState };
isEmptyState?: boolean;
}

export class DashboardViewport extends React.Component<DashboardViewportProps, State> {
Expand All @@ -45,26 +46,40 @@ export class DashboardViewport extends React.Component<DashboardViewportProps, S
private mounted: boolean = false;
constructor(props: DashboardViewportProps) {
super(props);
const { isFullScreenMode, panels, useMargins, title } = this.props.container.getInput();
const {
isFullScreenMode,
panels,
useMargins,
title,
isEmptyState,
} = this.props.container.getInput();

this.state = {
isFullScreenMode,
panels,
useMargins,
title,
isEmptyState,
};
}

public componentDidMount() {
this.mounted = true;
this.subscription = this.props.container.getInput$().subscribe(() => {
const { isFullScreenMode, useMargins, title, description } = this.props.container.getInput();
const {
isFullScreenMode,
useMargins,
title,
description,
isEmptyState,
} = this.props.container.getInput();
if (this.mounted) {
this.setState({
isFullScreenMode,
description,
useMargins,
title,
isEmptyState,
});
}
});
Expand Down Expand Up @@ -122,7 +137,7 @@ export class DashboardViewport extends React.Component<DashboardViewportProps, S
public render() {
return (
<React.Fragment>
{this.props.renderEmpty ? this.renderEmptyScreen() : null}
{this.state.isEmptyState ? this.renderEmptyScreen() : null}
{this.renderContainerScreen()}
</React.Fragment>
);
Expand Down
6 changes: 4 additions & 2 deletions test/functional/apps/dashboard/full_screen_mode.js
Original file line number Diff line number Diff line change
Expand Up @@ -74,10 +74,12 @@ export default function ({ getService, getPageObjects }) {
expect(exists).to.be(true);
});

it.skip('exits when the logo button is clicked on', async () => {
it('exits when the text button is clicked on', async () => {
await PageObjects.dashboard.clickFullScreenMode();
await PageObjects.dashboard.waitForRenderComplete();
await PageObjects.dashboard.clickExitFullScreenLogoButton();
const logoButton = await PageObjects.dashboard.getExitFullScreenLogoButton();
await logoButton.moveMouseTo();
await PageObjects.dashboard.clickExitFullScreenTextButton();
await retry.try(async () => {
const isChromeVisible = await PageObjects.common.isChromeVisible();
expect(isChromeVisible).to.be(true);
Expand Down

0 comments on commit 0b4a66e

Please sign in to comment.