Skip to content

Commit

Permalink
test: add vrt for different themes
Browse files Browse the repository at this point in the history
  • Loading branch information
nickofthyme committed Aug 19, 2021
1 parent 8a70f05 commit 28aa946
Show file tree
Hide file tree
Showing 14 changed files with 40 additions and 0 deletions.
18 changes: 18 additions & 0 deletions integration/helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import path from 'path';
import { getStorybook, configure } from '@storybook/react';

import { Rotation } from '../packages/charts/src';
import { ThemeId } from '../storybook/use_base_theme';
// @ts-ignore
import { isLegacyVRTServer } from './config';

Expand Down Expand Up @@ -144,4 +145,21 @@ export const eachRotation = {
},
};

const themeIds = Object.values(ThemeId);

/**
* This is a wrapper around it.each for Themes
* Returns the requried query params to trigger correct theme
*/
export const eachTheme = {
it(fn: (theme: ThemeId, urlParam: string) => any, title = 'theme - %s') {
// eslint-disable-next-line jest/valid-title
return it.each<ThemeId>(themeIds)(title, (theme) => fn(theme, `&globals=theme:${theme}`));
},
describe(fn: (theme: ThemeId, urlParam: string) => any, title = 'theme - %s') {
// eslint-disable-next-line jest/valid-title, jest/valid-describe
return describe.each<ThemeId>(themeIds)(title, (theme) => fn(theme, `&globals=theme:${theme}`));
},
};

/* eslint-enable jest/no-export */
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
22 changes: 22 additions & 0 deletions integration/tests/goal_stories.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
* Side Public License, v 1.
*/

import { eachTheme } from '../helpers';
import { common } from '../page_objects';

describe('Goal stories', () => {
Expand All @@ -14,10 +15,31 @@ describe('Goal stories', () => {
'http://localhost:9001/?path=/story/goal-alpha--gaps&knob-show target=false&knob-target=260',
);
});

it('should render actual tooltip color on hover', async () => {
await common.expectChartWithMouseAtUrlToMatchScreenshot(
'http://localhost:9001/?path=/story/goal-alpha--gaps&knob-show target=false&knob-target=260&globals=background:white',
{ right: 245, bottom: 120 },
);
});

eachTheme.describe((_, params) => {
it('should render gauge with target story', async () => {
await common.expectChartAtUrlToMatchScreenshot(
`https://elastic.github.io/elastic-charts/?path=/story/goal-alpha--gauge-with-target${params}`,
);
});

it('should render minimal goal story', async () => {
await common.expectChartAtUrlToMatchScreenshot(
`https://elastic.github.io/elastic-charts/?path=/story/goal-alpha--minimal-goal${params}`,
);
});

it('should render vertical negative story', async () => {
await common.expectChartAtUrlToMatchScreenshot(
`https://elastic.github.io/elastic-charts/?path=/story/goal-alpha--vertical-negative${params}`,
);
});
});
});

0 comments on commit 28aa946

Please sign in to comment.