Skip to content

Commit

Permalink
Build: Fix flaky story (#8459)
Browse files Browse the repository at this point in the history
Build: Fix flaky story

Co-authored-by: Michael Shilman <shilman@users.noreply.github.com>
  • Loading branch information
ndelangen and shilman committed Oct 18, 2019
2 parents a64df49 + bd04414 commit fd7193a
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 4 deletions.
15 changes: 11 additions & 4 deletions lib/ui/src/components/layout/layout.stories.js
@@ -1,10 +1,12 @@
import { setInterval, window } from 'global';
import { setInterval } from 'global';
import React, { Component, Fragment } from 'react';
import PropTypes from 'prop-types';
import { storiesOf } from '@storybook/react';
import { withKnobs, boolean, number } from '@storybook/addon-knobs';
import { styled } from '@storybook/theming';

import { isChromatic } from 'storybook-chromatic/isChromatic';

import { Desktop } from './desktop';
import { Mobile } from './mobile';

Expand All @@ -16,6 +18,7 @@ import { panels } from '../panel/panel.stories';
import { previewProps } from '../preview/preview.stories';

import { mockDataset } from '../sidebar/treeview/treeview.mockdata';
import { store } from './persist';

const realNavProps = {
title: 'Title',
Expand Down Expand Up @@ -145,16 +148,20 @@ storiesOf('UI|Layout/Desktop', module)
.addDecorator(withKnobs)
.addDecorator(storyFn => {
const mocked = boolean('mock', true);
const height = number('height', window.innerHeight);
const width = number('width', window.innerWidth);
const height = number('height', 1200);
const width = number('width', 1200);

if (isChromatic) {
store.local.set(`storybook-layout`, {});
}

const props = {
height,
width,
...(mocked ? mockProps : realProps),
};

return <div style={{ minHeight: 600, minWidth: 600 }}>{storyFn({ props })}</div>;
return <div style={{ minHeight: 1200, minWidth: 1200 }}>{storyFn({ props })}</div>;
})
.add('default', ({ props }) => <Desktop {...props} />)
.add('no addons', ({ props }) => <Desktop {...props} panelCount={0} />)
Expand Down
2 changes: 2 additions & 0 deletions lib/ui/src/components/layout/persist.js
Expand Up @@ -2,6 +2,8 @@ import store from 'store2';
import debounce from 'lodash/debounce';
import memoize from 'memoizerific';

export { store };

export const get = () => {
try {
const data = store.local.get(`storybook-layout`);
Expand Down

1 comment on commit fd7193a

@vercel
Copy link

@vercel vercel bot commented on fd7193a Oct 18, 2019

Choose a reason for hiding this comment

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

Please sign in to comment.