creevey 0.10.0-beta.22 → 0.10.0-beta.23

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -20,7 +20,7 @@
20
20
  sans-serif;
21
21
  }
22
22
  </style>
23
- <script type="module" crossorigin src="./assets/index-iytWuaD6.js"></script>
23
+ <script type="module" crossorigin src="./assets/index-Bk1_hhr8.js"></script>
24
24
  </head>
25
25
  <body>
26
26
  <div id="root"></div>
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "creevey",
3
3
  "description": "Cross-browser screenshot testing tool for Storybook with fancy UI Runner",
4
- "version": "0.10.0-beta.22",
4
+ "version": "0.10.0-beta.23",
5
5
  "type": "commonjs",
6
6
  "bin": "dist/cli.js",
7
7
  "main": "./dist/index.js",
@@ -1,4 +1,4 @@
1
- import React, { JSX, useEffect } from 'react';
1
+ import React, { JSX, useContext, useEffect } from 'react';
2
2
  import { Tabs } from '@storybook/components';
3
3
  import { CloseAltIcon } from '@storybook/icons';
4
4
  import { styled, withTheme, Theme } from '@storybook/theming';
@@ -6,6 +6,7 @@ import { ImagesViewMode, Images } from '../../../../types.js';
6
6
  import { getImageUrl } from '../../helpers.js';
7
7
  import { ImagePreview } from './ImagePreview.js';
8
8
  import { viewModes } from '../../viewMode.js';
9
+ import { CreeveyContext } from '../../../web/CreeveyContext.js';
9
10
 
10
11
  interface PageHeaderProps {
11
12
  title: string[];
@@ -76,6 +77,7 @@ export function PageHeader({
76
77
  onImageChange,
77
78
  onViewModeChange,
78
79
  }: PageHeaderProps): JSX.Element | null {
80
+ const { isReport } = useContext(CreeveyContext);
79
81
  const imageEntires = Object.entries(images) as [string, Images][];
80
82
 
81
83
  const handleViewModeChange = (mode: string): void => {
@@ -110,7 +112,7 @@ export function PageHeader({
110
112
  <ImagePreview
111
113
  key={name}
112
114
  imageName={name}
113
- url={`${getImageUrl(title, name)}/${image.actual}`}
115
+ url={`${getImageUrl(title, name, isReport)}/${image.actual}`}
114
116
  isActive={name === imageName}
115
117
  onClick={onImageChange}
116
118
  error={imagesWithError.includes(name)}
@@ -1,4 +1,4 @@
1
- import React, { JSX, useCallback, useEffect, useState } from 'react';
1
+ import React, { JSX, useCallback, useContext, useEffect, useState } from 'react';
2
2
  import { Placeholder, ScrollArea } from '@storybook/components';
3
3
  import { styled, withTheme, Theme } from '@storybook/theming';
4
4
  import { ImagesView } from './ImagesView/ImagesView.js';
@@ -7,6 +7,7 @@ import { PageFooter } from './PageFooter/PageFooter.js';
7
7
  import { getImageUrl } from '../helpers.js';
8
8
  import { getViewMode, VIEW_MODE_KEY, viewModes } from '../viewMode.js';
9
9
  import { ImagesViewMode, TestResult } from '../../../types.js';
10
+ import { CreeveyContext } from '../../web/CreeveyContext.js';
10
11
 
11
12
  interface ResultsPageProps {
12
13
  path: string[];
@@ -65,8 +66,9 @@ export function ResultsPageInternal({
65
66
  onRetryChange,
66
67
  }: ResultsPageProps): JSX.Element {
67
68
  const result = results[retry - 1] ?? {};
69
+ const { isReport } = useContext(CreeveyContext);
68
70
  const [viewMode, setViewMode] = useState<ImagesViewMode>(getViewMode());
69
- const url = getImageUrl(path, imageName);
71
+ const url = getImageUrl(path, imageName, isReport);
70
72
  const image = result.images?.[imageName];
71
73
  const canApprove = Boolean(image && approved?.[imageName] != retry - 1 && result.status != 'success');
72
74
  const hasDiffAndExpect = canApprove && Boolean(image?.diff && image.expect);
@@ -299,12 +299,14 @@ export function getConnectionUrl(): string {
299
299
  .join(':');
300
300
  }
301
301
 
302
- export function getImageUrl(path: string[], imageName: string): string {
302
+ export function getImageUrl(path: string[], imageName: string, isReport?: boolean): string {
303
303
  // path => [title, story, test, browser]
304
304
  const browser = path.slice(-1)[0];
305
305
  const imagesUrl = window.location.host
306
306
  ? `${window.location.protocol}//${getConnectionUrl()}${
307
- window.location.pathname == '/' ? '/report' : window.location.pathname.split('/').slice(0, -1).join('/')
307
+ window.location.pathname == '/' && !isReport
308
+ ? '/report'
309
+ : window.location.pathname.split('/').slice(0, -1).join('/')
308
310
  }/${encodeURI(path.slice(0, -1).join('/'))}`
309
311
  : encodeURI(path.slice(0, -1).join('/'));
310
312