creevey 0.8.1-sb7.3 → 0.8.1-sb7.4
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.
@@ -10,6 +10,8 @@ var Events = _interopRequireWildcard(require("@storybook/core-events"));
|
|
10
10
|
|
11
11
|
var polyfill = _interopRequireWildcard(require("event-source-polyfill"));
|
12
12
|
|
13
|
+
var _testingLibrary = require("@storybook/testing-library");
|
14
|
+
|
13
15
|
var _addons = require("@storybook/addons");
|
14
16
|
|
15
17
|
var _types = require("../../types");
|
@@ -18,6 +20,8 @@ var _shared = require("../../shared");
|
|
18
20
|
|
19
21
|
var _helpers = require("../shared/helpers");
|
20
22
|
|
23
|
+
var _utils = require("./utils");
|
24
|
+
|
21
25
|
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
22
26
|
|
23
27
|
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
@@ -26,7 +30,6 @@ function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj &&
|
|
26
30
|
// @ts-nocheck
|
27
31
|
|
28
32
|
/* eslint-disable */
|
29
|
-
// import { buildQueries, within } from '@storybook/testing-library';
|
30
33
|
if (typeof process != 'object' || typeof process.version != 'string') {
|
31
34
|
// NOTE If you don't use babel-polyfill or any other polyfills that add EventSource for IE11
|
32
35
|
// You don't get hot reload in IE11. So put polyfill for that to better UX
|
@@ -286,48 +289,48 @@ function withCreevey() {
|
|
286
289
|
|
287
290
|
const getMultipleError = (_, query) => "Found multiple elements by query: ".concat(query);
|
288
291
|
|
289
|
-
const getMissingError = (_, query) => "Unable to find an element by query: ".concat(query);
|
290
|
-
// queryAllByQuery,
|
291
|
-
// getMultipleError,
|
292
|
-
// getMissingError,
|
293
|
-
// );
|
294
|
-
// const queries = {
|
295
|
-
// queryByQuery,
|
296
|
-
// getAllByQuery,
|
297
|
-
// getByQuery,
|
298
|
-
// findAllByQuery,
|
299
|
-
// findByQuery,
|
300
|
-
// };
|
301
|
-
|
292
|
+
const getMissingError = (_, query) => "Unable to find an element by query: ".concat(query);
|
302
293
|
|
294
|
+
const [queryByQuery, getAllByQuery, getByQuery, findAllByQuery, findByQuery] = (0, _testingLibrary.buildQueries)(queryAllByQuery, getMultipleError, getMissingError);
|
295
|
+
const queries = {
|
296
|
+
queryByQuery,
|
297
|
+
getAllByQuery,
|
298
|
+
getByQuery,
|
299
|
+
findAllByQuery,
|
300
|
+
findByQuery
|
301
|
+
};
|
303
302
|
return (0, _addons.makeDecorator)({
|
304
303
|
name: 'withCreevey',
|
305
304
|
parameterName: 'creevey',
|
306
305
|
wrapper: (getStory, context) => {
|
306
|
+
var _ref2;
|
307
|
+
|
307
308
|
// TODO Define proper types, like captureElement is a promise
|
308
|
-
|
309
|
-
|
310
|
-
|
311
|
-
|
312
|
-
|
313
|
-
|
314
|
-
|
315
|
-
|
316
|
-
|
317
|
-
|
318
|
-
|
319
|
-
|
320
|
-
|
321
|
-
|
322
|
-
|
323
|
-
|
324
|
-
|
325
|
-
|
326
|
-
|
327
|
-
|
328
|
-
|
329
|
-
|
330
|
-
|
309
|
+
const {
|
310
|
+
captureElement
|
311
|
+
} = context.parameters.creevey = (_ref2 = context.parameters.creevey) !== null && _ref2 !== void 0 ? _ref2 : {};
|
312
|
+
Object.defineProperty(context.parameters.creevey, 'captureElement', {
|
313
|
+
get() {
|
314
|
+
switch (true) {
|
315
|
+
case captureElement === undefined:
|
316
|
+
return Promise.resolve(context.canvasElement);
|
317
|
+
|
318
|
+
case captureElement === null:
|
319
|
+
return Promise.resolve(document.documentElement);
|
320
|
+
|
321
|
+
case typeof captureElement == 'string':
|
322
|
+
return _utils.isInternetExplorer // some code from testing-library makes IE hang
|
323
|
+
? Promise.resolve(context.canvasElement.querySelector(captureElement)) : (0, _testingLibrary.within)(context.canvasElement, queries).findByQuery(captureElement);
|
324
|
+
|
325
|
+
case typeof captureElement == 'function':
|
326
|
+
// TODO Define type for it
|
327
|
+
return Promise.resolve(captureElement(context));
|
328
|
+
}
|
329
|
+
},
|
330
|
+
|
331
|
+
enumerable: true,
|
332
|
+
configurable: true
|
333
|
+
});
|
331
334
|
return getStory(context);
|
332
335
|
}
|
333
336
|
});
|
@@ -4,11 +4,12 @@
|
|
4
4
|
/* eslint-disable */
|
5
5
|
import * as Events from '@storybook/core-events';
|
6
6
|
import * as polyfill from 'event-source-polyfill';
|
7
|
-
|
7
|
+
import { buildQueries, within } from '@storybook/testing-library';
|
8
8
|
import { addons, makeDecorator } from '@storybook/addons';
|
9
9
|
import { isObject, noop } from '../../types';
|
10
10
|
import { denormalizeStoryParameters, serializeRawStories } from '../../shared';
|
11
11
|
import { getConnectionUrl } from '../shared/helpers';
|
12
|
+
import { isInternetExplorer } from './utils';
|
12
13
|
|
13
14
|
if (typeof process != 'object' || typeof process.version != 'string') {
|
14
15
|
// NOTE If you don't use babel-polyfill or any other polyfills that add EventSource for IE11
|
@@ -262,48 +263,48 @@ export function withCreevey() {
|
|
262
263
|
|
263
264
|
const getMultipleError = (_, query) => "Found multiple elements by query: ".concat(query);
|
264
265
|
|
265
|
-
const getMissingError = (_, query) => "Unable to find an element by query: ".concat(query);
|
266
|
-
// queryAllByQuery,
|
267
|
-
// getMultipleError,
|
268
|
-
// getMissingError,
|
269
|
-
// );
|
270
|
-
// const queries = {
|
271
|
-
// queryByQuery,
|
272
|
-
// getAllByQuery,
|
273
|
-
// getByQuery,
|
274
|
-
// findAllByQuery,
|
275
|
-
// findByQuery,
|
276
|
-
// };
|
277
|
-
|
266
|
+
const getMissingError = (_, query) => "Unable to find an element by query: ".concat(query);
|
278
267
|
|
268
|
+
const [queryByQuery, getAllByQuery, getByQuery, findAllByQuery, findByQuery] = buildQueries(queryAllByQuery, getMultipleError, getMissingError);
|
269
|
+
const queries = {
|
270
|
+
queryByQuery,
|
271
|
+
getAllByQuery,
|
272
|
+
getByQuery,
|
273
|
+
findAllByQuery,
|
274
|
+
findByQuery
|
275
|
+
};
|
279
276
|
return makeDecorator({
|
280
277
|
name: 'withCreevey',
|
281
278
|
parameterName: 'creevey',
|
282
279
|
wrapper: (getStory, context) => {
|
280
|
+
var _ref2;
|
281
|
+
|
283
282
|
// TODO Define proper types, like captureElement is a promise
|
284
|
-
|
285
|
-
|
286
|
-
|
287
|
-
|
288
|
-
|
289
|
-
|
290
|
-
|
291
|
-
|
292
|
-
|
293
|
-
|
294
|
-
|
295
|
-
|
296
|
-
|
297
|
-
|
298
|
-
|
299
|
-
|
300
|
-
|
301
|
-
|
302
|
-
|
303
|
-
|
304
|
-
|
305
|
-
|
306
|
-
|
283
|
+
const {
|
284
|
+
captureElement
|
285
|
+
} = context.parameters.creevey = (_ref2 = context.parameters.creevey) !== null && _ref2 !== void 0 ? _ref2 : {};
|
286
|
+
Object.defineProperty(context.parameters.creevey, 'captureElement', {
|
287
|
+
get() {
|
288
|
+
switch (true) {
|
289
|
+
case captureElement === undefined:
|
290
|
+
return Promise.resolve(context.canvasElement);
|
291
|
+
|
292
|
+
case captureElement === null:
|
293
|
+
return Promise.resolve(document.documentElement);
|
294
|
+
|
295
|
+
case typeof captureElement == 'string':
|
296
|
+
return isInternetExplorer // some code from testing-library makes IE hang
|
297
|
+
? Promise.resolve(context.canvasElement.querySelector(captureElement)) : within(context.canvasElement, queries).findByQuery(captureElement);
|
298
|
+
|
299
|
+
case typeof captureElement == 'function':
|
300
|
+
// TODO Define type for it
|
301
|
+
return Promise.resolve(captureElement(context));
|
302
|
+
}
|
303
|
+
},
|
304
|
+
|
305
|
+
enumerable: true,
|
306
|
+
configurable: true
|
307
|
+
});
|
307
308
|
return getStory(context);
|
308
309
|
}
|
309
310
|
});
|
package/package.json
CHANGED
@@ -13,7 +13,7 @@
|
|
13
13
|
"addon",
|
14
14
|
"test"
|
15
15
|
],
|
16
|
-
"version": "0.8.1-sb7.
|
16
|
+
"version": "0.8.1-sb7.4",
|
17
17
|
"bin": {
|
18
18
|
"creevey": "./lib/cjs/cli.js"
|
19
19
|
},
|
@@ -94,7 +94,7 @@
|
|
94
94
|
"@octokit/core": "^4.0.4",
|
95
95
|
"@storybook/components": "^7.6.4",
|
96
96
|
"@storybook/csf": "0.1.2",
|
97
|
-
"@storybook/testing-library": "^0.
|
97
|
+
"@storybook/testing-library": "^0.0.13",
|
98
98
|
"@storybook/theming": "^7.6.4",
|
99
99
|
"@types/chai": "^4.3.1",
|
100
100
|
"@types/selenium-webdriver": "^4.1.5",
|