creevey 0.9.0-beta.2 → 0.9.0-beta.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.
- package/CHANGELOG.md +35 -0
- package/README.md +9 -1
- package/addon/README.md +3 -0
- package/addon/package.json +4 -0
- package/docs/config.md +29 -26
- package/jest.config.js +6 -0
- package/lib/cjs/client/addon/Manager.js +122 -270
- package/lib/cjs/client/addon/components/Addon.js +17 -38
- package/lib/cjs/client/addon/components/Icons.js +11 -7
- package/lib/cjs/client/addon/components/Panel.js +17 -13
- package/lib/cjs/client/addon/components/TestSelect.js +11 -9
- package/lib/cjs/client/addon/components/Tools.js +21 -40
- package/lib/cjs/client/addon/decorator.js +1 -1
- package/lib/cjs/client/addon/index.js +31 -0
- package/lib/cjs/client/addon/preset.ie11.js +74 -0
- package/lib/cjs/client/addon/preset.js +14 -33
- package/lib/cjs/client/addon/register.js +46 -70
- package/lib/cjs/client/addon/utils.js +6 -2
- package/lib/cjs/client/addon/withCreevey.js +161 -342
- package/lib/cjs/client/shared/components/ImagesView/BlendView.js +23 -21
- package/lib/cjs/client/shared/components/ImagesView/ImagesView.js +22 -18
- package/lib/cjs/client/shared/components/ImagesView/SideBySideView.js +42 -64
- package/lib/cjs/client/shared/components/ImagesView/SlideView.js +35 -48
- package/lib/cjs/client/shared/components/ImagesView/SwapView.js +24 -43
- package/lib/cjs/client/shared/components/ImagesView/index.js +9 -9
- package/lib/cjs/client/shared/components/PageFooter/PageFooter.js +12 -8
- package/lib/cjs/client/shared/components/PageFooter/Paging.js +14 -18
- package/lib/cjs/client/shared/components/PageHeader/ImagePreview.js +22 -18
- package/lib/cjs/client/shared/components/PageHeader/PageHeader.js +42 -67
- package/lib/cjs/client/shared/components/ResultsPage.js +39 -69
- package/lib/cjs/client/shared/creeveyClientApi.js +55 -82
- package/lib/cjs/client/shared/helpers.js +139 -210
- package/lib/cjs/client/shared/viewMode.js +5 -5
- package/lib/cjs/client/web/142.js +2 -0
- package/lib/cjs/client/web/142.js.LICENSE.txt +12 -0
- package/lib/cjs/client/web/32.js +1 -0
- package/lib/cjs/client/web/551.js +1 -0
- package/lib/cjs/client/web/566.js +2 -0
- package/lib/cjs/client/web/566.js.LICENSE.txt +31 -0
- package/lib/cjs/client/web/691.js +2 -0
- package/lib/cjs/client/web/691.js.LICENSE.txt +8 -0
- package/lib/cjs/client/web/725.js +1 -0
- package/lib/cjs/client/web/main.js +2 -38
- package/lib/cjs/client/web/main.js.LICENSE.txt +49 -0
- package/lib/cjs/creevey.js +3 -5
- package/lib/cjs/index.js +4 -4
- package/lib/cjs/server/config.js +2 -4
- package/lib/cjs/server/docker.js +3 -7
- package/lib/cjs/server/extract.js +1 -5
- package/lib/cjs/server/index.js +1 -1
- package/lib/cjs/server/loaders/babel/creevey-plugin.js +1 -3
- package/lib/cjs/server/loaders/babel/helpers.js +13 -23
- package/lib/cjs/server/loaders/babel/register.js +2 -4
- package/lib/cjs/server/loaders/webpack/compile.js +34 -51
- package/lib/cjs/server/loaders/webpack/creevey-loader.js +20 -22
- package/lib/cjs/server/loaders/webpack/dummy-hmr.js +2 -7
- package/lib/cjs/server/loaders/webpack/mdx-loader.js +2 -2
- package/lib/cjs/server/loaders/webpack/start.js +1 -1
- package/lib/cjs/server/logger.js +2 -1
- package/lib/cjs/server/master/index.js +2 -2
- package/lib/cjs/server/master/pool.js +9 -18
- package/lib/cjs/server/master/runner.js +53 -66
- package/lib/cjs/server/master/server.js +5 -3
- package/lib/cjs/server/messages.js +8 -10
- package/lib/cjs/server/selenium/browser.js +22 -46
- package/lib/cjs/server/selenium/selenoid.js +5 -7
- package/lib/cjs/server/stories.js +16 -33
- package/lib/cjs/server/storybook/entry.js +7 -22
- package/lib/cjs/server/storybook/helpers.js +20 -27
- package/lib/cjs/server/storybook/providers/browser.js +5 -9
- package/lib/cjs/server/storybook/providers/nodejs.js +7 -9
- package/lib/cjs/server/update.js +1 -5
- package/lib/cjs/server/utils.js +27 -36
- package/lib/cjs/server/worker/reporter.js +8 -20
- package/lib/cjs/server/worker/worker.js +6 -16
- package/lib/cjs/shared/index.js +101 -0
- package/lib/cjs/shared/serializeRegExp.js +42 -0
- package/lib/cjs/types.js +6 -6
- package/lib/esm/client/addon/Manager.js +122 -270
- package/lib/esm/client/addon/components/Addon.js +15 -34
- package/lib/esm/client/addon/components/Icons.js +10 -6
- package/lib/esm/client/addon/components/Panel.js +17 -13
- package/lib/esm/client/addon/components/TestSelect.js +11 -9
- package/lib/esm/client/addon/components/Tools.js +19 -36
- package/lib/esm/client/addon/decorator.js +1 -1
- package/lib/esm/client/addon/index.js +2 -0
- package/lib/esm/client/addon/preset.ie11.js +59 -0
- package/lib/esm/client/addon/preset.js +12 -27
- package/lib/esm/client/addon/register.js +42 -66
- package/lib/esm/client/addon/utils.js +3 -2
- package/lib/esm/client/addon/withCreevey.js +155 -341
- package/lib/esm/client/shared/components/ImagesView/BlendView.js +21 -17
- package/lib/esm/client/shared/components/ImagesView/ImagesView.js +21 -17
- package/lib/esm/client/shared/components/ImagesView/SideBySideView.js +40 -60
- package/lib/esm/client/shared/components/ImagesView/SlideView.js +33 -44
- package/lib/esm/client/shared/components/ImagesView/SwapView.js +22 -39
- package/lib/esm/client/shared/components/PageFooter/PageFooter.js +12 -8
- package/lib/esm/client/shared/components/PageFooter/Paging.js +14 -18
- package/lib/esm/client/shared/components/PageHeader/ImagePreview.js +22 -18
- package/lib/esm/client/shared/components/PageHeader/PageHeader.js +37 -60
- package/lib/esm/client/shared/components/ResultsPage.js +36 -64
- package/lib/esm/client/shared/creeveyClientApi.js +57 -84
- package/lib/esm/client/shared/helpers.js +123 -194
- package/lib/esm/client/shared/viewMode.js +4 -4
- package/lib/esm/creevey.js +3 -5
- package/lib/esm/index.js +1 -3
- package/lib/esm/server/config.js +2 -4
- package/lib/esm/server/docker.js +2 -2
- package/lib/esm/server/extract.js +1 -3
- package/lib/esm/server/index.js +1 -1
- package/lib/esm/server/loaders/babel/creevey-plugin.js +1 -3
- package/lib/esm/server/loaders/babel/helpers.js +12 -22
- package/lib/esm/server/loaders/babel/register.js +3 -5
- package/lib/esm/server/loaders/webpack/compile.js +35 -52
- package/lib/esm/server/loaders/webpack/creevey-loader.js +9 -10
- package/lib/esm/server/loaders/webpack/dummy-hmr.js +2 -6
- package/lib/esm/server/loaders/webpack/mdx-loader.js +2 -2
- package/lib/esm/server/loaders/webpack/start.js +1 -1
- package/lib/esm/server/master/index.js +2 -2
- package/lib/esm/server/master/pool.js +7 -18
- package/lib/esm/server/master/runner.js +53 -66
- package/lib/esm/server/master/server.js +5 -3
- package/lib/esm/server/messages.js +3 -5
- package/lib/esm/server/selenium/browser.js +19 -43
- package/lib/esm/server/selenium/selenoid.js +4 -6
- package/lib/esm/server/stories.js +16 -32
- package/lib/esm/server/storybook/entry.js +5 -22
- package/lib/esm/server/storybook/helpers.js +11 -20
- package/lib/esm/server/storybook/providers/browser.js +4 -5
- package/lib/esm/server/storybook/providers/nodejs.js +7 -8
- package/lib/esm/server/update.js +1 -5
- package/lib/esm/server/utils.js +18 -31
- package/lib/esm/server/worker/reporter.js +8 -20
- package/lib/esm/server/worker/worker.js +6 -16
- package/lib/esm/shared/index.js +78 -0
- package/lib/esm/shared/serializeRegExp.js +24 -0
- package/lib/types/cli.d.ts +1 -1
- package/lib/types/client/addon/Manager.d.ts +37 -37
- package/lib/types/client/addon/components/Addon.d.ts +8 -8
- package/lib/types/client/addon/components/Icons.d.ts +7 -7
- package/lib/types/client/addon/components/Panel.d.ts +9 -9
- package/lib/types/client/addon/components/TestSelect.d.ts +8 -9
- package/lib/types/client/addon/components/Tools.d.ts +6 -6
- package/lib/types/client/addon/decorator.d.ts +1 -1
- package/lib/types/client/addon/index.d.ts +2 -0
- package/lib/types/client/addon/preset.d.ts +23 -24
- package/lib/types/client/addon/preset.ie11.d.ts +10 -0
- package/lib/types/client/addon/readyForCapture.d.ts +6 -6
- package/lib/types/client/addon/register.d.ts +3 -3
- package/lib/types/client/addon/utils.d.ts +3 -2
- package/lib/types/client/addon/withCreevey.d.ts +24 -24
- package/lib/types/client/shared/components/ImagesView/BlendView.d.ts +3 -3
- package/lib/types/client/shared/components/ImagesView/ImagesView.d.ts +24 -25
- package/lib/types/client/shared/components/ImagesView/SideBySideView.d.ts +3 -3
- package/lib/types/client/shared/components/ImagesView/SlideView.d.ts +3 -3
- package/lib/types/client/shared/components/ImagesView/SwapView.d.ts +3 -3
- package/lib/types/client/shared/components/ImagesView/index.d.ts +5 -5
- package/lib/types/client/shared/components/PageFooter/PageFooter.d.ts +8 -9
- package/lib/types/client/shared/components/PageFooter/Paging.d.ts +7 -8
- package/lib/types/client/shared/components/PageHeader/ImagePreview.d.ts +12 -12
- package/lib/types/client/shared/components/PageHeader/PageHeader.d.ts +16 -17
- package/lib/types/client/shared/components/ResultsPage.d.ts +18 -18
- package/lib/types/client/shared/creeveyClientApi.d.ts +9 -9
- package/lib/types/client/shared/helpers.d.ts +46 -46
- package/lib/types/client/shared/viewMode.d.ts +4 -4
- package/lib/types/client/web/CreeveyApp.d.ts +11 -12
- package/lib/types/client/web/CreeveyContext.d.ts +11 -11
- package/lib/types/client/web/CreeveyLoader.d.ts +2 -3
- package/lib/types/client/web/CreeveyView/SideBar/Checkbox.d.ts +19 -19
- package/lib/types/client/web/CreeveyView/SideBar/Search.d.ts +6 -6
- package/lib/types/client/web/CreeveyView/SideBar/SideBar.d.ts +14 -14
- package/lib/types/client/web/CreeveyView/SideBar/SideBarHeader.d.ts +12 -13
- package/lib/types/client/web/CreeveyView/SideBar/SuiteLink.d.ts +33 -33
- package/lib/types/client/web/CreeveyView/SideBar/TestLink.d.ts +7 -8
- package/lib/types/client/web/CreeveyView/SideBar/TestStatusIcon.d.ts +10 -10
- package/lib/types/client/web/CreeveyView/SideBar/TestsStatus.d.ts +9 -9
- package/lib/types/client/web/CreeveyView/SideBar/Toggle.d.ts +6 -6
- package/lib/types/client/web/CreeveyView/SideBar/index.d.ts +1 -1
- package/lib/types/client/web/KeyboardEventsContext.d.ts +13 -13
- package/lib/types/client/web/index.d.ts +4 -4
- package/lib/types/creevey.d.ts +1 -1
- package/lib/types/index.d.ts +0 -1
- package/lib/types/server/config.d.ts +4 -4
- package/lib/types/server/docker.d.ts +7 -7
- package/lib/types/server/extract.d.ts +2 -2
- package/lib/types/server/index.d.ts +2 -2
- package/lib/types/server/loaders/babel/creevey-plugin.d.ts +1 -1
- package/lib/types/server/loaders/babel/helpers.d.ts +19 -19
- package/lib/types/server/loaders/babel/register.d.ts +5 -5
- package/lib/types/server/loaders/hooks/mdx.d.ts +1 -1
- package/lib/types/server/loaders/hooks/svelte.d.ts +1 -1
- package/lib/types/server/loaders/webpack/compile.d.ts +2 -2
- package/lib/types/server/loaders/webpack/creevey-loader.d.ts +4 -2
- package/lib/types/server/loaders/webpack/dummy-hmr.d.ts +10 -10
- package/lib/types/server/loaders/webpack/mdx-loader.d.ts +6 -6
- package/lib/types/server/loaders/webpack/start.d.ts +1 -1
- package/lib/types/server/logger.d.ts +10 -6
- package/lib/types/server/master/api.d.ts +7 -7
- package/lib/types/server/master/index.d.ts +3 -3
- package/lib/types/server/master/master.d.ts +7 -7
- package/lib/types/server/master/pool.d.ts +31 -31
- package/lib/types/server/master/runner.d.ts +26 -26
- package/lib/types/server/master/server.d.ts +2 -2
- package/lib/types/server/messages.d.ts +27 -27
- package/lib/types/server/selenium/browser.d.ts +17 -17
- package/lib/types/server/selenium/index.d.ts +2 -2
- package/lib/types/server/selenium/selenoid.d.ts +3 -3
- package/lib/types/server/stories.d.ts +8 -8
- package/lib/types/server/storybook/entry.d.ts +17 -18
- package/lib/types/server/storybook/helpers.d.ts +24 -24
- package/lib/types/server/storybook/providers/browser.d.ts +4 -4
- package/lib/types/server/storybook/providers/hybrid.d.ts +4 -4
- package/lib/types/server/storybook/providers/nodejs.d.ts +9 -9
- package/lib/types/server/testsFiles/parser.d.ts +12 -12
- package/lib/types/server/testsFiles/register.d.ts +2 -2
- package/lib/types/server/update.d.ts +2 -2
- package/lib/types/server/utils.d.ts +24 -20
- package/lib/types/server/worker/chai-image.d.ts +6 -6
- package/lib/types/server/worker/helpers.d.ts +8 -8
- package/lib/types/server/worker/index.d.ts +1 -1
- package/lib/types/server/worker/reporter.d.ts +8 -8
- package/lib/types/server/worker/worker.d.ts +4 -4
- package/lib/types/{shared.d.ts → shared/index.d.ts} +7 -16
- package/lib/types/shared/serializeRegExp.d.ts +9 -0
- package/lib/types/types.d.ts +489 -489
- package/package.json +114 -102
- package/preset/ie11.js +5 -0
- package/{preset.js → preset/index.js} +2 -2
- package/types/mdx.d.ts +3 -2
- package/lib/cjs/client/web/1.js +0 -13
- package/lib/cjs/client/web/2.js +0 -1
- package/lib/cjs/shared.js +0 -124
- package/lib/esm/shared.js +0 -93
- package/storybook-static/stories.json +0 -21
@@ -3,13 +3,15 @@
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
4
4
|
value: true
|
5
5
|
});
|
6
|
-
exports.withCreevey = withCreevey;
|
7
6
|
exports.capture = capture;
|
7
|
+
exports.withCreevey = withCreevey;
|
8
8
|
|
9
9
|
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,81 +20,45 @@ var _shared = require("../../shared");
|
|
18
20
|
|
19
21
|
var _helpers = require("../shared/helpers");
|
20
22
|
|
21
|
-
|
22
|
-
|
23
|
-
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; }
|
24
|
-
|
25
|
-
function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
|
26
|
-
|
27
|
-
function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
28
|
-
|
29
|
-
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
30
|
-
|
31
|
-
function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
|
32
|
-
|
33
|
-
function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
|
34
|
-
|
35
|
-
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
|
23
|
+
var _utils = require("./utils");
|
36
24
|
|
37
|
-
function
|
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); }
|
38
26
|
|
39
|
-
function
|
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; }
|
40
28
|
|
41
|
-
|
42
|
-
|
43
|
-
if ((typeof process === "undefined" ? "undefined" : _typeof(process)) != 'object' || typeof process.version != 'string') {
|
29
|
+
if (typeof process != 'object' || typeof process.version != 'string') {
|
44
30
|
// NOTE If you don't use babel-polyfill or any other polyfills that add EventSource for IE11
|
45
31
|
// You don't get hot reload in IE11. So put polyfill for that to better UX
|
46
32
|
// Don't load in nodejs environment
|
47
33
|
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
|
48
|
-
|
49
|
-
|
34
|
+
const {
|
35
|
+
NativeEventSource,
|
36
|
+
EventSourcePolyfill
|
37
|
+
} = polyfill; // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
|
50
38
|
|
51
39
|
window.EventSource = NativeEventSource || EventSourcePolyfill;
|
52
40
|
}
|
53
41
|
|
54
|
-
|
55
|
-
|
56
|
-
function resetCurrentStory(_x) {
|
57
|
-
return _resetCurrentStory.apply(this, arguments);
|
58
|
-
}
|
42
|
+
const disableAnimationsStyles = "\n*,\n*:hover,\n*::before,\n*::after {\n animation-delay: -0.0001ms !important;\n animation-duration: 0s !important;\n animation-play-state: paused !important;\n cursor: none !important;\n caret-color: transparent !important;\n transition: 0s !important;\n}\n";
|
59
43
|
|
60
|
-
function
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
return channel.emit(Events.SET_CURRENT_STORY, {
|
68
|
-
storyId: true,
|
69
|
-
name: '',
|
70
|
-
kind: ''
|
71
|
-
});
|
72
|
-
}, 0);
|
73
|
-
return _context4.abrupt("return", new Promise(function (resolve) {
|
74
|
-
return channel.once(Events.STORY_MISSING, resolve);
|
75
|
-
}));
|
76
|
-
|
77
|
-
case 2:
|
78
|
-
case "end":
|
79
|
-
return _context4.stop();
|
80
|
-
}
|
81
|
-
}
|
82
|
-
}, _callee4);
|
83
|
-
}));
|
84
|
-
return _resetCurrentStory.apply(this, arguments);
|
44
|
+
async function resetCurrentStory(channel) {
|
45
|
+
setTimeout(() => channel.emit(Events.SET_CURRENT_STORY, {
|
46
|
+
storyId: true,
|
47
|
+
name: '',
|
48
|
+
kind: ''
|
49
|
+
}), 0);
|
50
|
+
return new Promise(resolve => channel.once(Events.STORY_MISSING, resolve));
|
85
51
|
}
|
86
52
|
|
87
53
|
function catchRenderError(channel) {
|
88
|
-
|
89
|
-
|
90
|
-
return rejectCallback = reject;
|
91
|
-
});
|
54
|
+
let rejectCallback;
|
55
|
+
const promise = new Promise((_resolve, reject) => rejectCallback = reject);
|
92
56
|
|
93
57
|
function errorHandler(_ref) {
|
94
|
-
|
95
|
-
|
58
|
+
let {
|
59
|
+
title,
|
60
|
+
description
|
61
|
+
} = _ref;
|
96
62
|
rejectCallback({
|
97
63
|
message: title,
|
98
64
|
stack: description
|
@@ -116,10 +82,8 @@ function catchRenderError(channel) {
|
|
116
82
|
}
|
117
83
|
|
118
84
|
function waitForStoryRendered(channel) {
|
119
|
-
|
120
|
-
|
121
|
-
return resolveCallback = resolve;
|
122
|
-
});
|
85
|
+
let resolveCallback;
|
86
|
+
const promise = new Promise(resolve => resolveCallback = resolve);
|
123
87
|
|
124
88
|
function renderHandler() {
|
125
89
|
resolveCallback();
|
@@ -137,13 +101,11 @@ function waitForStoryRendered(channel) {
|
|
137
101
|
|
138
102
|
function waitForFontsLoaded() {
|
139
103
|
if (!document.fonts) return;
|
140
|
-
|
141
|
-
return font.status == 'loading';
|
142
|
-
});
|
104
|
+
const areFontsLoading = Array.from(document.fonts).some(font => font.status == 'loading');
|
143
105
|
|
144
106
|
if (areFontsLoading) {
|
145
|
-
return new Promise(
|
146
|
-
|
107
|
+
return new Promise(resolve => {
|
108
|
+
const fontsLoadedHandler = () => {
|
147
109
|
document.fonts.removeEventListener('loadingdone', fontsLoadedHandler);
|
148
110
|
resolve();
|
149
111
|
};
|
@@ -154,247 +116,133 @@ function waitForFontsLoaded() {
|
|
154
116
|
}
|
155
117
|
|
156
118
|
function waitForCaptureCall() {
|
157
|
-
return new Promise(
|
158
|
-
return captureResolver = resolve;
|
159
|
-
});
|
119
|
+
return new Promise(resolve => captureResolver = resolve);
|
160
120
|
}
|
161
121
|
|
162
122
|
function initCreeveyState() {
|
163
123
|
var _window$localStorage$;
|
164
124
|
|
165
|
-
|
125
|
+
const prevState = JSON.parse((_window$localStorage$ = window.localStorage.getItem('Creevey_Tests')) !== null && _window$localStorage$ !== void 0 ? _window$localStorage$ : '{}');
|
166
126
|
if (prevState.creeveyHost) window.__CREEVEY_SERVER_HOST__ = prevState.creeveyHost;
|
167
127
|
if (prevState.creeveyPort) window.__CREEVEY_SERVER_PORT__ = prevState.creeveyPort;
|
168
128
|
if (prevState.setStoriesCounter) setStoriesCounter = prevState.setStoriesCounter;
|
169
129
|
if (prevState.isTestBrowser) isTestBrowser = prevState.isTestBrowser;
|
170
|
-
window.addEventListener('beforeunload',
|
130
|
+
window.addEventListener('beforeunload', () => {
|
171
131
|
window.localStorage.setItem('Creevey_Tests', JSON.stringify({
|
172
132
|
creeveyHost: window.__CREEVEY_SERVER_HOST__,
|
173
133
|
creeveyPort: window.__CREEVEY_SERVER_PORT__,
|
174
|
-
setStoriesCounter
|
175
|
-
isTestBrowser
|
134
|
+
setStoriesCounter,
|
135
|
+
isTestBrowser
|
176
136
|
}));
|
177
137
|
});
|
178
138
|
}
|
179
139
|
|
180
|
-
|
181
|
-
|
182
|
-
|
183
|
-
|
184
|
-
|
140
|
+
let isTestBrowser = false;
|
141
|
+
let captureResolver;
|
142
|
+
let waitForCreevey;
|
143
|
+
let creeveyReady;
|
144
|
+
let setStoriesCounter = 0;
|
185
145
|
|
186
146
|
function withCreevey() {
|
187
|
-
|
188
|
-
|
147
|
+
let currentStory = '';
|
148
|
+
let isAnimationDisabled = false;
|
189
149
|
initCreeveyState();
|
190
150
|
|
191
151
|
function disableAnimation() {
|
192
152
|
isAnimationDisabled = true;
|
193
|
-
|
194
|
-
|
153
|
+
const style = document.createElement('style');
|
154
|
+
const textNode = document.createTextNode(disableAnimationsStyles);
|
195
155
|
style.setAttribute('type', 'text/css');
|
196
156
|
style.appendChild(textNode);
|
197
157
|
document.head.appendChild(style);
|
198
158
|
}
|
199
159
|
|
200
|
-
function getStories() {
|
201
|
-
|
202
|
-
}
|
160
|
+
async function getStories() {
|
161
|
+
var _window$__STORYBOOK_S;
|
203
162
|
|
204
|
-
|
205
|
-
|
206
|
-
|
207
|
-
|
208
|
-
|
209
|
-
|
210
|
-
|
211
|
-
|
212
|
-
|
213
|
-
|
214
|
-
|
215
|
-
|
216
|
-
|
217
|
-
|
218
|
-
|
219
|
-
|
220
|
-
|
221
|
-
|
222
|
-
|
223
|
-
|
224
|
-
|
225
|
-
|
226
|
-
|
227
|
-
|
228
|
-
|
229
|
-
|
230
|
-
|
231
|
-
|
232
|
-
|
233
|
-
|
234
|
-
break;
|
235
|
-
}
|
236
|
-
|
237
|
-
_context.next = 9;
|
238
|
-
return store.cacheAllCSFFiles();
|
239
|
-
|
240
|
-
case 9:
|
241
|
-
_addons.addons.getChannel().emit(Events.SET_STORIES, store.getSetStoriesPayload());
|
242
|
-
|
243
|
-
_context.next = 13;
|
244
|
-
break;
|
245
|
-
|
246
|
-
case 12:
|
247
|
-
return _context.abrupt("return");
|
248
|
-
|
249
|
-
case 13:
|
250
|
-
_addons.addons.getChannel().on(Events.SET_STORIES, function (data) {
|
251
|
-
// TODO Figure out how to get only updated stories
|
252
|
-
// TODO Subscribe on hmr? like use dummy-hmr
|
253
|
-
setStoriesCounter += 1;
|
254
|
-
var stories = (0, _shared.serializeRawStories)((0, _shared.denormalizeStoryParameters)(data));
|
255
|
-
var storiesByFiles = new Map();
|
256
|
-
Object.values(stories).forEach(function (story) {
|
257
|
-
var storiesFromFile = storiesByFiles.get(story.parameters.fileName);
|
258
|
-
if (storiesFromFile) storiesFromFile.push(story);else storiesByFiles.set(story.parameters.fileName, [story]);
|
259
|
-
});
|
260
|
-
void fetch("http://".concat((0, _helpers.getConnectionUrl)(), "/stories"), {
|
261
|
-
method: 'POST',
|
262
|
-
headers: {
|
263
|
-
'Content-Type': 'application/json'
|
264
|
-
},
|
265
|
-
body: JSON.stringify({
|
266
|
-
setStoriesCounter: setStoriesCounter,
|
267
|
-
stories: _toConsumableArray(storiesByFiles.entries())
|
268
|
-
})
|
269
|
-
});
|
270
|
-
});
|
271
|
-
|
272
|
-
return _context.abrupt("return", storiesPromise);
|
273
|
-
|
274
|
-
case 15:
|
275
|
-
case "end":
|
276
|
-
return _context.stop();
|
277
|
-
}
|
278
|
-
}
|
279
|
-
}, _callee);
|
280
|
-
}));
|
281
|
-
return _getStories.apply(this, arguments);
|
282
|
-
}
|
163
|
+
const storiesPromise = new Promise(resolve => _addons.addons.getChannel().once(Events.SET_STORIES, data => resolve((0, _shared.serializeRawStories)((0, _shared.denormalizeStoryParameters)(data)))));
|
164
|
+
const store = (_window$__STORYBOOK_S = window.__STORYBOOK_STORY_STORE__) !== null && _window$__STORYBOOK_S !== void 0 ? _window$__STORYBOOK_S : {};
|
165
|
+
|
166
|
+
if (store.cacheAllCSFFiles) {
|
167
|
+
await store.cacheAllCSFFiles();
|
168
|
+
|
169
|
+
_addons.addons.getChannel().emit(Events.SET_STORIES, store.getSetStoriesPayload());
|
170
|
+
} else return;
|
171
|
+
|
172
|
+
_addons.addons.getChannel().on(Events.SET_STORIES, data => {
|
173
|
+
// TODO Figure out how to get only updated stories
|
174
|
+
// TODO Subscribe on hmr? like use dummy-hmr
|
175
|
+
setStoriesCounter += 1;
|
176
|
+
const stories = (0, _shared.serializeRawStories)((0, _shared.denormalizeStoryParameters)(data));
|
177
|
+
const storiesByFiles = new Map();
|
178
|
+
Object.values(stories).forEach(story => {
|
179
|
+
const storiesFromFile = storiesByFiles.get(story.parameters.fileName);
|
180
|
+
if (storiesFromFile) storiesFromFile.push(story);else storiesByFiles.set(story.parameters.fileName, [story]);
|
181
|
+
});
|
182
|
+
void fetch("http://".concat((0, _helpers.getConnectionUrl)(), "/stories"), {
|
183
|
+
method: 'POST',
|
184
|
+
headers: {
|
185
|
+
'Content-Type': 'application/json'
|
186
|
+
},
|
187
|
+
body: JSON.stringify({
|
188
|
+
setStoriesCounter,
|
189
|
+
stories: [...storiesByFiles.entries()]
|
190
|
+
})
|
191
|
+
});
|
192
|
+
});
|
283
193
|
|
284
|
-
|
285
|
-
return _selectStory.apply(this, arguments);
|
194
|
+
return storiesPromise;
|
286
195
|
}
|
287
196
|
|
288
|
-
function
|
289
|
-
|
290
|
-
|
291
|
-
|
292
|
-
|
293
|
-
|
294
|
-
|
295
|
-
|
296
|
-
|
297
|
-
|
298
|
-
|
299
|
-
|
300
|
-
|
301
|
-
|
302
|
-
|
303
|
-
|
304
|
-
|
305
|
-
|
306
|
-
|
307
|
-
|
308
|
-
|
309
|
-
|
310
|
-
|
311
|
-
|
312
|
-
|
313
|
-
|
314
|
-
|
315
|
-
|
316
|
-
|
317
|
-
|
318
|
-
|
319
|
-
|
320
|
-
|
321
|
-
|
322
|
-
|
323
|
-
|
324
|
-
});
|
325
|
-
setTimeout(function () {
|
326
|
-
return channel.emit(Events.SET_CURRENT_STORY, {
|
327
|
-
storyId: storyId,
|
328
|
-
name: name,
|
329
|
-
kind: kind
|
330
|
-
});
|
331
|
-
}, 0);
|
332
|
-
_context3.prev = 15;
|
333
|
-
_context3.next = 18;
|
334
|
-
return Promise.race([_asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee2() {
|
335
|
-
return regeneratorRuntime.wrap(function _callee2$(_context2) {
|
336
|
-
while (1) {
|
337
|
-
switch (_context2.prev = _context2.next) {
|
338
|
-
case 0:
|
339
|
-
_context2.next = 2;
|
340
|
-
return Promise.race([renderPromise, capturePromise]);
|
341
|
-
|
342
|
-
case 2:
|
343
|
-
_context2.next = 4;
|
344
|
-
return waitForFontsLoaded();
|
345
|
-
|
346
|
-
case 4:
|
347
|
-
_context2.next = 6;
|
348
|
-
return waitForReady;
|
349
|
-
|
350
|
-
case 6:
|
351
|
-
case "end":
|
352
|
-
return _context2.stop();
|
353
|
-
}
|
354
|
-
}
|
355
|
-
}, _callee2);
|
356
|
-
}))(), errorPromise]);
|
357
|
-
|
358
|
-
case 18:
|
359
|
-
callback([null, isCaptureCalled]);
|
360
|
-
_context3.next = 25;
|
361
|
-
break;
|
362
|
-
|
363
|
-
case 21:
|
364
|
-
_context3.prev = 21;
|
365
|
-
_context3.t0 = _context3["catch"](15);
|
366
|
-
// NOTE Event `STORY_THREW_EXCEPTION` triggered only in react and vue frameworks and return Error instance
|
367
|
-
// NOTE Event `STORY_ERRORED` return error-like object without `name` field
|
368
|
-
errorMessage = _context3.t0 instanceof Error ? (_reason$stack = _context3.t0.stack) !== null && _reason$stack !== void 0 ? _reason$stack : _context3.t0.message : (0, _types.isObject)(_context3.t0) ? "".concat(_context3.t0.message, "\n ").concat(_context3.t0.stack) : _context3.t0;
|
369
|
-
callback([errorMessage]);
|
370
|
-
|
371
|
-
case 25:
|
372
|
-
_context3.prev = 25;
|
373
|
-
renderPromise.cancel();
|
374
|
-
errorPromise.cancel();
|
375
|
-
return _context3.finish(25);
|
376
|
-
|
377
|
-
case 29:
|
378
|
-
case "end":
|
379
|
-
return _context3.stop();
|
380
|
-
}
|
381
|
-
}
|
382
|
-
}, _callee3, null, [[15, 21, 25, 29]]);
|
383
|
-
}));
|
384
|
-
return _selectStory.apply(this, arguments);
|
197
|
+
async function selectStory(storyId, kind, name, shouldWaitForReady, callback) {
|
198
|
+
if (!isAnimationDisabled) disableAnimation();
|
199
|
+
isTestBrowser = true;
|
200
|
+
|
201
|
+
const channel = _addons.addons.getChannel();
|
202
|
+
|
203
|
+
const waitForReady = shouldWaitForReady ? new Promise(resolve => window.__CREEVEY_SET_READY_FOR_CAPTURE__ = resolve) : Promise.resolve();
|
204
|
+
if (storyId == currentStory) await resetCurrentStory(channel);else currentStory = storyId;
|
205
|
+
let isCaptureCalled = false;
|
206
|
+
const renderPromise = waitForStoryRendered(channel);
|
207
|
+
const errorPromise = catchRenderError(channel);
|
208
|
+
const capturePromise = waitForCaptureCall().then(() => isCaptureCalled = true);
|
209
|
+
setTimeout(() => channel.emit(Events.SET_CURRENT_STORY, {
|
210
|
+
storyId,
|
211
|
+
name,
|
212
|
+
kind
|
213
|
+
}), 0);
|
214
|
+
|
215
|
+
try {
|
216
|
+
await Promise.race([(async () => {
|
217
|
+
await Promise.race([renderPromise, capturePromise]);
|
218
|
+
await waitForFontsLoaded();
|
219
|
+
await waitForReady;
|
220
|
+
})(), errorPromise]);
|
221
|
+
callback([null, isCaptureCalled]);
|
222
|
+
} catch (reason) {
|
223
|
+
var _reason$stack;
|
224
|
+
|
225
|
+
// NOTE Event `STORY_THREW_EXCEPTION` triggered only in react and vue frameworks and return Error instance
|
226
|
+
// NOTE Event `STORY_ERRORED` return error-like object without `name` field
|
227
|
+
const errorMessage = reason instanceof Error ? (_reason$stack = reason.stack) !== null && _reason$stack !== void 0 ? _reason$stack : reason.message : (0, _types.isObject)(reason) ? "".concat(reason.message, "\n ").concat(reason.stack) : reason;
|
228
|
+
callback([errorMessage]);
|
229
|
+
} finally {
|
230
|
+
renderPromise.cancel();
|
231
|
+
errorPromise.cancel();
|
232
|
+
}
|
385
233
|
}
|
386
234
|
|
387
235
|
function updateGlobals(globals) {
|
388
236
|
_addons.addons.getChannel().emit(Events.UPDATE_GLOBALS, {
|
389
|
-
globals
|
237
|
+
globals
|
390
238
|
});
|
391
239
|
}
|
392
240
|
|
393
241
|
function insertIgnoreStyles(ignoreSelectors) {
|
394
|
-
|
242
|
+
const stylesElement = document.createElement('style');
|
395
243
|
stylesElement.setAttribute('type', 'text/css');
|
396
244
|
document.head.appendChild(stylesElement);
|
397
|
-
ignoreSelectors.forEach(
|
245
|
+
ignoreSelectors.forEach(selector => {
|
398
246
|
stylesElement.innerHTML += "\n ".concat(selector, " {\n background: #000 !important;\n box-shadow: none !important;\n text-shadow: none !important;\n outline: 0 !important;\n color: rgba(0,0,0,0) !important;\n }\n ").concat(selector, " *, ").concat(selector, "::before, ").concat(selector, "::after {\n visibility: hidden !important;\n }\n ");
|
399
247
|
});
|
400
248
|
return stylesElement;
|
@@ -408,17 +256,17 @@ function withCreevey() {
|
|
408
256
|
|
409
257
|
function hasPlayCompletedYet(callback) {
|
410
258
|
creeveyReady();
|
411
|
-
|
412
|
-
|
259
|
+
let isCaptureCalled = false;
|
260
|
+
let isPlayCompleted = false;
|
413
261
|
|
414
|
-
|
262
|
+
const channel = _addons.addons.getChannel();
|
415
263
|
|
416
|
-
void waitForStoryRendered(channel).then(
|
264
|
+
void waitForStoryRendered(channel).then(() => {
|
417
265
|
if (isCaptureCalled) return;
|
418
266
|
isPlayCompleted = true;
|
419
267
|
callback(true);
|
420
268
|
});
|
421
|
-
void waitForCaptureCall().then(
|
269
|
+
void waitForCaptureCall().then(() => {
|
422
270
|
if (isPlayCompleted) return;
|
423
271
|
isCaptureCalled = true;
|
424
272
|
callback(false);
|
@@ -431,49 +279,51 @@ function withCreevey() {
|
|
431
279
|
window.__CREEVEY_INSERT_IGNORE_STYLES__ = insertIgnoreStyles;
|
432
280
|
window.__CREEVEY_REMOVE_IGNORE_STYLES__ = removeIgnoreStyles;
|
433
281
|
window.__CREEVEY_HAS_PLAY_COMPLETED_YET__ = hasPlayCompletedYet;
|
434
|
-
window.__CREEVEY_SET_READY_FOR_CAPTURE__ = _types.noop;
|
435
|
-
|
436
|
-
|
437
|
-
|
438
|
-
|
439
|
-
// queryAllByQuery,
|
440
|
-
// getMultipleError,
|
441
|
-
// getMissingError,
|
442
|
-
// );
|
443
|
-
// const queries = {
|
444
|
-
// queryByQuery,
|
445
|
-
// getAllByQuery,
|
446
|
-
// getByQuery,
|
447
|
-
// findAllByQuery,
|
448
|
-
// findByQuery,
|
449
|
-
// };
|
282
|
+
window.__CREEVEY_SET_READY_FOR_CAPTURE__ = _types.noop;
|
283
|
+
|
284
|
+
const queryAllByQuery = (container, query) => [...container.querySelectorAll(query)].filter(e => e instanceof HTMLElement);
|
285
|
+
|
286
|
+
const getMultipleError = (_, query) => "Found multiple elements by query: ".concat(query);
|
450
287
|
|
288
|
+
const getMissingError = (_, query) => "Unable to find an element by query: ".concat(query);
|
289
|
+
|
290
|
+
const [queryByQuery, getAllByQuery, getByQuery, findAllByQuery, findByQuery] = (0, _testingLibrary.buildQueries)(queryAllByQuery, getMultipleError, getMissingError);
|
291
|
+
const queries = {
|
292
|
+
queryByQuery,
|
293
|
+
getAllByQuery,
|
294
|
+
getByQuery,
|
295
|
+
findAllByQuery,
|
296
|
+
findByQuery
|
297
|
+
};
|
451
298
|
return (0, _addons.makeDecorator)({
|
452
299
|
name: 'withCreevey',
|
453
300
|
parameterName: 'creevey',
|
454
|
-
wrapper:
|
301
|
+
wrapper: (getStory, context) => {
|
455
302
|
var _ref2;
|
456
303
|
|
457
304
|
// TODO Define proper types, like captureElement is a promise
|
458
|
-
|
459
|
-
|
460
|
-
|
305
|
+
const {
|
306
|
+
captureElement
|
307
|
+
} = context.parameters.creevey = (_ref2 = context.parameters.creevey) !== null && _ref2 !== void 0 ? _ref2 : {};
|
461
308
|
Object.defineProperty(context.parameters.creevey, 'captureElement', {
|
462
|
-
get
|
309
|
+
get() {
|
463
310
|
switch (true) {
|
464
311
|
case captureElement === undefined:
|
465
312
|
return Promise.resolve(context.canvasElement);
|
466
313
|
|
467
314
|
case captureElement === null:
|
468
315
|
return Promise.resolve(document.documentElement);
|
469
|
-
|
470
|
-
|
316
|
+
|
317
|
+
case typeof captureElement == 'string':
|
318
|
+
return _utils.isInternetExplorer // some code from testing-library makes IE hang
|
319
|
+
? Promise.resolve(context.canvasElement.querySelector(captureElement)) : (0, _testingLibrary.within)(context.canvasElement, queries).findByQuery(captureElement);
|
471
320
|
|
472
321
|
case typeof captureElement == 'function':
|
473
322
|
// TODO Define type for it
|
474
323
|
return Promise.resolve(captureElement(context));
|
475
324
|
}
|
476
325
|
},
|
326
|
+
|
477
327
|
enumerable: true,
|
478
328
|
configurable: true
|
479
329
|
});
|
@@ -482,50 +332,19 @@ function withCreevey() {
|
|
482
332
|
});
|
483
333
|
}
|
484
334
|
|
485
|
-
function capture(
|
486
|
-
|
487
|
-
|
488
|
-
|
489
|
-
|
490
|
-
|
491
|
-
|
492
|
-
|
493
|
-
|
494
|
-
|
495
|
-
|
496
|
-
|
497
|
-
|
498
|
-
|
499
|
-
|
500
|
-
return _context5.abrupt("return");
|
501
|
-
|
502
|
-
case 2:
|
503
|
-
captureResolver();
|
504
|
-
waitForCreevey = new Promise(function (resolve) {
|
505
|
-
return creeveyReady = resolve;
|
506
|
-
});
|
507
|
-
_context5.next = 6;
|
508
|
-
return fetch("http://".concat((0, _helpers.getConnectionUrl)(), "/capture"), {
|
509
|
-
method: 'POST',
|
510
|
-
headers: {
|
511
|
-
'Content-Type': 'application/json'
|
512
|
-
},
|
513
|
-
body: JSON.stringify({
|
514
|
-
workerId: window.__CREEVEY_WORKER_ID__,
|
515
|
-
options: options
|
516
|
-
})
|
517
|
-
});
|
518
|
-
|
519
|
-
case 6:
|
520
|
-
_context5.next = 8;
|
521
|
-
return waitForCreevey;
|
522
|
-
|
523
|
-
case 8:
|
524
|
-
case "end":
|
525
|
-
return _context5.stop();
|
526
|
-
}
|
527
|
-
}
|
528
|
-
}, _callee5);
|
529
|
-
}));
|
530
|
-
return _capture.apply(this, arguments);
|
335
|
+
async function capture(options) {
|
336
|
+
if (!isTestBrowser) return;
|
337
|
+
captureResolver();
|
338
|
+
waitForCreevey = new Promise(resolve => creeveyReady = resolve);
|
339
|
+
await fetch("http://".concat((0, _helpers.getConnectionUrl)(), "/capture"), {
|
340
|
+
method: 'POST',
|
341
|
+
headers: {
|
342
|
+
'Content-Type': 'application/json'
|
343
|
+
},
|
344
|
+
body: JSON.stringify({
|
345
|
+
workerId: window.__CREEVEY_WORKER_ID__,
|
346
|
+
options
|
347
|
+
})
|
348
|
+
});
|
349
|
+
await waitForCreevey;
|
531
350
|
}
|