creevey 0.9.0-non-webpack.2 → 0.9.0-non-webpack.2.fix-capture-element

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.
@@ -26,6 +26,6 @@ export const ForwardIcon = _ref2 => {
26
26
  viewBox: "0 0 512 512"
27
27
  }, /*#__PURE__*/React.createElement("path", {
28
28
  fill: "currentColor",
29
- d: "M460.9,246.8l-209-164.2c-7.8-6.1-19.2-0.6-19.2,9.2v328.4c0,9.8,11.4,15.3,19.2,9.2l209-164.2c5.1-4,6-11.4,2-16.5\r C462.4,248,461.7,247.3,460.9,246.8L460.9,246.8z M228.2,246.8L19.2,82.5C11.4,76.4,0,82,0,91.8v328.4c0,9.8,11.4,15.3,19.2,9.2\r l209-164.2c3-2.3,4.5-5.8,4.5-9.2C232.7,252.6,231.2,249.1,228.2,246.8z M507.3,64h-37.2c-2.5,0-4.7,2-4.7,4.4v375.3\r c0,2.4,2.1,4.4,4.7,4.4h37.2c2.5,0,4.7-2,4.7-4.4V68.4C512,66,509.9,64,507.3,64z"
29
+ d: "M460.9,246.8l-209-164.2c-7.8-6.1-19.2-0.6-19.2,9.2v328.4c0,9.8,11.4,15.3,19.2,9.2l209-164.2c5.1-4,6-11.4,2-16.5 C462.4,248,461.7,247.3,460.9,246.8L460.9,246.8z M228.2,246.8L19.2,82.5C11.4,76.4,0,82,0,91.8v328.4c0,9.8,11.4,15.3,19.2,9.2 l209-164.2c3-2.3,4.5-5.8,4.5-9.2C232.7,252.6,231.2,249.1,228.2,246.8z M507.3,64h-37.2c-2.5,0-4.7,2-4.7,4.4v375.3 c0,2.4,2.1,4.4,4.7,4.4h37.2c2.5,0,4.7-2,4.7-4.4V68.4C512,66,509.9,64,507.3,64z"
30
30
  }));
31
31
  };
@@ -1,8 +1,9 @@
1
1
  import * as Events from '@storybook/core-events';
2
2
  import * as polyfill from 'event-source-polyfill';
3
- import { buildQueries, within } from '@storybook/testing-library';
3
+ // import { buildQueries, within } from '@storybook/testing-library';
4
4
  import { addons, makeDecorator } from '@storybook/addons';
5
- import { isObject, noop } from '../../types';
5
+ import { // CreeveyStoryParams,
6
+ isObject, noop } from '../../types';
6
7
  import { denormalizeStoryParameters, serializeRawStories } from '../../shared';
7
8
  import { getConnectionUrl } from '../shared/helpers';
8
9
 
@@ -256,53 +257,49 @@ export function withCreevey() {
256
257
  window.__CREEVEY_INSERT_IGNORE_STYLES__ = insertIgnoreStyles;
257
258
  window.__CREEVEY_REMOVE_IGNORE_STYLES__ = removeIgnoreStyles;
258
259
  window.__CREEVEY_HAS_PLAY_COMPLETED_YET__ = hasPlayCompletedYet;
259
- window.__CREEVEY_SET_READY_FOR_CAPTURE__ = noop;
260
+ window.__CREEVEY_SET_READY_FOR_CAPTURE__ = noop; // const queryAllByQuery = (container: HTMLElement, query: string): HTMLElement[] =>
261
+ // [...container.querySelectorAll(query)].filter((e) => e instanceof HTMLElement) as HTMLElement[];
262
+ // const getMultipleError = (_: Element | null, query: string): string => `Found multiple elements by query: ${query}`;
263
+ // const getMissingError = (_: Element | null, query: string): string => `Unable to find an element by query: ${query}`;
264
+ // const [queryByQuery, getAllByQuery, getByQuery, findAllByQuery, findByQuery] = buildQueries(
265
+ // queryAllByQuery,
266
+ // getMultipleError,
267
+ // getMissingError,
268
+ // );
269
+ // const queries = {
270
+ // queryByQuery,
271
+ // getAllByQuery,
272
+ // getByQuery,
273
+ // findAllByQuery,
274
+ // findByQuery,
275
+ // };
260
276
 
261
- const queryAllByQuery = (container, query) => [...container.querySelectorAll(query)].filter(e => e instanceof HTMLElement);
262
-
263
- const getMultipleError = (_, query) => "Found multiple elements by query: ".concat(query);
264
-
265
- const getMissingError = (_, query) => "Unable to find an element by query: ".concat(query);
266
-
267
- const [queryByQuery, getAllByQuery, getByQuery, findAllByQuery, findByQuery] = buildQueries(queryAllByQuery, getMultipleError, getMissingError);
268
- const queries = {
269
- queryByQuery,
270
- getAllByQuery,
271
- getByQuery,
272
- findAllByQuery,
273
- findByQuery
274
- };
275
277
  return makeDecorator({
276
278
  name: 'withCreevey',
277
279
  parameterName: 'creevey',
278
280
  wrapper: (getStory, context) => {
279
- var _ref2;
280
-
281
- // TODO Define proper types, like captureElement is a promise
282
- const {
283
- captureElement
284
- } = context.parameters.creevey = (_ref2 = context.parameters.creevey) !== null && _ref2 !== void 0 ? _ref2 : {};
285
- Object.defineProperty(context.parameters.creevey, 'captureElement', {
286
- get() {
287
- switch (true) {
288
- case captureElement === undefined:
289
- return Promise.resolve(context.canvasElement);
290
-
291
- case captureElement === null:
292
- return Promise.resolve(document.documentElement);
293
-
294
- case typeof captureElement == 'string':
295
- return within(context.canvasElement, queries).findByQuery(captureElement);
296
-
297
- case typeof captureElement == 'function':
298
- // TODO Define type for it
299
- return Promise.resolve(captureElement(context));
300
- }
301
- },
302
-
303
- enumerable: true,
304
- configurable: true
305
- });
281
+ // // TODO Define proper types, like captureElement is a promise
282
+ // const { captureElement } = (context.parameters.creevey =
283
+ // (context.parameters.creevey as CreeveyStoryParams) ?? {});
284
+ // Object.defineProperty(context.parameters.creevey, 'captureElement', {
285
+ // get() {
286
+ // switch (true) {
287
+ // case captureElement === undefined:
288
+ // return Promise.resolve(context.canvasElement);
289
+ // case captureElement === null:
290
+ // return Promise.resolve(document.documentElement);
291
+ // case typeof captureElement == 'string':
292
+ // return within<typeof queries>(context.canvasElement, queries).findByQuery(captureElement as string);
293
+ // case typeof captureElement == 'function':
294
+ // // TODO Define type for it
295
+ // return Promise.resolve(
296
+ // (captureElement as unknown as (ctx: typeof context) => Promise<HTMLElement> | HTMLElement)(context),
297
+ // );
298
+ // }
299
+ // },
300
+ // enumerable: true,
301
+ // configurable: true,
302
+ // });
306
303
  return getStory(context);
307
304
  }
308
305
  });
@@ -269,10 +269,10 @@ export function useLoadImages(s1, s2, s3) {
269
269
  }, [s1, s2, s3]);
270
270
  return loaded;
271
271
  }
272
- /**
273
- * Uses the ResizeObserver API to observe changes within the given HTML Element DOM Rect.
274
- *
275
- * @returns dimensions of element's content box (which means without paddings and border width)
272
+ /**
273
+ * Uses the ResizeObserver API to observe changes within the given HTML Element DOM Rect.
274
+ *
275
+ * @returns dimensions of element's content box (which means without paddings and border width)
276
276
  */
277
277
 
278
278
  export function useResizeObserver(elementRef, onResize) {
package/package.json CHANGED
@@ -13,7 +13,7 @@
13
13
  "addon",
14
14
  "test"
15
15
  ],
16
- "version": "0.9.0-non-webpack.2",
16
+ "version": "0.9.0-non-webpack.2.fix-capture-element",
17
17
  "bin": {
18
18
  "creevey": "./lib/cjs/cli.js"
19
19
  },
@@ -1 +1 @@
1
- declare module '@babel/register';
1
+ declare module '@babel/register';
package/types/chai.d.ts CHANGED
@@ -1,12 +1,12 @@
1
- /// <reference types="chai" />
2
- declare namespace Chai {
3
- // eslint-disable-next-line @typescript-eslint/no-unused-vars
4
- interface ChaiStatic {
5
- use(fn: (chai: ChaiStatic, utils: ChaiUtils) => void): ChaiStatic;
6
- }
7
-
8
- interface Assertion {
9
- matchImage: (filename?: string) => Promise<void>;
10
- matchImages: () => Promise<void>;
11
- }
12
- }
1
+ /// <reference types="chai" />
2
+ declare namespace Chai {
3
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
4
+ interface ChaiStatic {
5
+ use(fn: (chai: ChaiStatic, utils: ChaiUtils) => void): ChaiStatic;
6
+ }
7
+
8
+ interface Assertion {
9
+ matchImage: (filename?: string) => Promise<void>;
10
+ matchImages: () => Promise<void>;
11
+ }
12
+ }
@@ -1,6 +1,6 @@
1
- /* eslint-disable @typescript-eslint/no-explicit-any */
2
- // NOTE package with typings doesn't exists
3
- declare module 'event-source-polyfill' {
4
- export const NativeEventSource: any;
5
- export const EventSourcePolyfill: any;
6
- }
1
+ /* eslint-disable @typescript-eslint/no-explicit-any */
2
+ // NOTE package with typings doesn't exists
3
+ declare module 'event-source-polyfill' {
4
+ export const NativeEventSource: any;
5
+ export const EventSourcePolyfill: any;
6
+ }
package/types/mocha.d.ts CHANGED
@@ -1,20 +1,20 @@
1
- /// <reference types="mocha" />
2
- declare namespace Mocha {
3
- interface Context {
4
- config: import('creevey').Config;
5
- browser: import('selenium-webdriver').WebDriver;
6
- until: import('selenium-webdriver/lib/until');
7
- keys: import('selenium-webdriver/lib/input').IKey;
8
- expect: Chai.ExpectStatic;
9
- takeScreenshot: () => Promise<string>;
10
- updateStoryArgs: <Args extends Record<string, unknown>>(updatedArgs: Args) => Promise<void>;
11
- readonly captureElement?: import('selenium-webdriver').WebElementPromise;
12
- browserName: string;
13
- testScope: string[];
14
- screenshots: { imageName?: string; screenshot: string }[];
15
- }
16
-
17
- interface Test {
18
- skipReason: string | boolean;
19
- }
20
- }
1
+ /// <reference types="mocha" />
2
+ declare namespace Mocha {
3
+ interface Context {
4
+ config: import('creevey').Config;
5
+ browser: import('selenium-webdriver').WebDriver;
6
+ until: import('selenium-webdriver/lib/until');
7
+ keys: import('selenium-webdriver/lib/input').IKey;
8
+ expect: Chai.ExpectStatic;
9
+ takeScreenshot: () => Promise<string>;
10
+ updateStoryArgs: <Args extends Record<string, unknown>>(updatedArgs: Args) => Promise<void>;
11
+ readonly captureElement?: import('selenium-webdriver').WebElementPromise;
12
+ browserName: string;
13
+ testScope: string[];
14
+ screenshots: { imageName?: string; screenshot: string }[];
15
+ }
16
+
17
+ interface Test {
18
+ skipReason: string | boolean;
19
+ }
20
+ }
package/types/png.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- declare module '*.png' {
2
- const content: string;
3
- export default content;
4
- }
1
+ declare module '*.png' {
2
+ const content: string;
3
+ export default content;
4
+ }