creevey 0.9.0-beta.2 → 0.9.0-non-webpack.1
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/AUTHORS +15 -15
- package/CHANGELOG.md +1275 -1275
- package/LICENSE +21 -21
- package/README.md +7 -0
- package/addon/README.md +3 -0
- package/addon/package.json +4 -0
- package/docs/config.md +212 -212
- package/docs/grid.md +10 -10
- package/docs/tests.md +63 -63
- package/jest.config.js +6 -0
- package/lib/cjs/client/addon/Manager.js +123 -271
- package/lib/cjs/client/addon/components/Addon.js +17 -38
- package/lib/cjs/client/addon/components/Icons.js +12 -8
- 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.js +13 -32
- package/lib/cjs/client/addon/register.js +46 -70
- package/lib/cjs/client/addon/utils.js +1 -1
- package/lib/cjs/client/addon/withCreevey.js +164 -344
- 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 +143 -214
- 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/index.html +19 -19
- 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 +1 -1
- package/lib/cjs/server/docker.js +3 -7
- 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 +1 -3
- package/lib/cjs/server/loaders/webpack/compile.js +31 -24
- package/lib/cjs/server/loaders/webpack/creevey-loader.js +10 -5
- package/lib/cjs/server/loaders/webpack/dummy-hmr.js +2 -7
- package/lib/cjs/server/loaders/webpack/mdx-loader.js +1 -1
- 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 +2 -2
- package/lib/cjs/server/messages.js +8 -10
- package/lib/cjs/server/selenium/browser.js +23 -31
- package/lib/cjs/server/selenium/selenoid.js +5 -7
- package/lib/cjs/server/stories.js +9 -20
- package/lib/cjs/server/storybook/entry.js +5 -3
- package/lib/cjs/server/storybook/helpers.js +15 -21
- package/lib/cjs/server/storybook/providers/browser.js +5 -9
- package/lib/cjs/server/storybook/providers/nodejs.js +4 -4
- package/lib/cjs/server/update.js +1 -5
- package/lib/cjs/server/utils.js +13 -15
- 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 +123 -271
- package/lib/esm/client/addon/components/Addon.js +15 -34
- package/lib/esm/client/addon/components/Icons.js +11 -7
- 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.js +10 -25
- package/lib/esm/client/addon/register.js +42 -66
- package/lib/esm/client/addon/utils.js +1 -1
- package/lib/esm/client/addon/withCreevey.js +157 -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 +127 -198
- 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/docker.js +2 -2
- 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 +1 -3
- package/lib/esm/server/loaders/webpack/compile.js +31 -24
- package/lib/esm/server/loaders/webpack/creevey-loader.js +9 -4
- package/lib/esm/server/loaders/webpack/dummy-hmr.js +2 -6
- 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 +2 -2
- package/lib/esm/server/messages.js +3 -5
- package/lib/esm/server/selenium/browser.js +20 -28
- package/lib/esm/server/selenium/selenoid.js +4 -6
- package/lib/esm/server/stories.js +9 -20
- package/lib/esm/server/storybook/entry.js +4 -2
- package/lib/esm/server/storybook/helpers.js +7 -15
- package/lib/esm/server/storybook/providers/browser.js +4 -5
- package/lib/esm/server/storybook/providers/nodejs.js +3 -3
- package/lib/esm/server/update.js +1 -5
- package/lib/esm/server/utils.js +5 -9
- 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/readyForCapture.d.ts +6 -6
- package/lib/types/client/addon/register.d.ts +3 -3
- package/lib/types/client/addon/utils.d.ts +2 -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 +18 -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 +20 -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 +490 -489
- package/package.json +115 -102
- package/preset.js +9 -9
- package/types/babel__register.d.ts +1 -1
- package/types/chai.d.ts +12 -12
- package/types/event-source-polyfill.d.ts +6 -6
- package/types/mdx.d.ts +3 -2
- package/types/mocha.d.ts +20 -20
- package/types/png.d.ts +4 -4
- 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,43 @@ var _shared = require("../../shared");
|
|
18
20
|
|
19
21
|
var _helpers = require("../shared/helpers");
|
20
22
|
|
21
|
-
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function
|
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
|
+
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); }
|
36
24
|
|
37
|
-
function
|
25
|
+
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; }
|
38
26
|
|
39
|
-
|
40
|
-
|
41
|
-
function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
|
42
|
-
|
43
|
-
if ((typeof process === "undefined" ? "undefined" : _typeof(process)) != 'object' || typeof process.version != 'string') {
|
27
|
+
if (typeof process != 'object' || typeof process.version != 'string') {
|
44
28
|
// NOTE If you don't use babel-polyfill or any other polyfills that add EventSource for IE11
|
45
29
|
// You don't get hot reload in IE11. So put polyfill for that to better UX
|
46
30
|
// Don't load in nodejs environment
|
47
31
|
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
|
48
|
-
|
49
|
-
|
32
|
+
const {
|
33
|
+
NativeEventSource,
|
34
|
+
EventSourcePolyfill
|
35
|
+
} = polyfill; // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
|
50
36
|
|
51
37
|
window.EventSource = NativeEventSource || EventSourcePolyfill;
|
52
38
|
}
|
53
39
|
|
54
|
-
|
40
|
+
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";
|
55
41
|
|
56
|
-
function resetCurrentStory(
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
while (1) {
|
64
|
-
switch (_context4.prev = _context4.next) {
|
65
|
-
case 0:
|
66
|
-
setTimeout(function () {
|
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);
|
42
|
+
async function resetCurrentStory(channel) {
|
43
|
+
setTimeout(() => channel.emit(Events.SET_CURRENT_STORY, {
|
44
|
+
storyId: true,
|
45
|
+
name: '',
|
46
|
+
kind: ''
|
47
|
+
}), 0);
|
48
|
+
return new Promise(resolve => channel.once(Events.STORY_MISSING, resolve));
|
85
49
|
}
|
86
50
|
|
87
51
|
function catchRenderError(channel) {
|
88
|
-
|
89
|
-
|
90
|
-
return rejectCallback = reject;
|
91
|
-
});
|
52
|
+
let rejectCallback;
|
53
|
+
const promise = new Promise((_resolve, reject) => rejectCallback = reject);
|
92
54
|
|
93
55
|
function errorHandler(_ref) {
|
94
|
-
|
95
|
-
|
56
|
+
let {
|
57
|
+
title,
|
58
|
+
description
|
59
|
+
} = _ref;
|
96
60
|
rejectCallback({
|
97
61
|
message: title,
|
98
62
|
stack: description
|
@@ -116,10 +80,8 @@ function catchRenderError(channel) {
|
|
116
80
|
}
|
117
81
|
|
118
82
|
function waitForStoryRendered(channel) {
|
119
|
-
|
120
|
-
|
121
|
-
return resolveCallback = resolve;
|
122
|
-
});
|
83
|
+
let resolveCallback;
|
84
|
+
const promise = new Promise(resolve => resolveCallback = resolve);
|
123
85
|
|
124
86
|
function renderHandler() {
|
125
87
|
resolveCallback();
|
@@ -137,13 +99,11 @@ function waitForStoryRendered(channel) {
|
|
137
99
|
|
138
100
|
function waitForFontsLoaded() {
|
139
101
|
if (!document.fonts) return;
|
140
|
-
|
141
|
-
return font.status == 'loading';
|
142
|
-
});
|
102
|
+
const areFontsLoading = Array.from(document.fonts).some(font => font.status == 'loading');
|
143
103
|
|
144
104
|
if (areFontsLoading) {
|
145
|
-
return new Promise(
|
146
|
-
|
105
|
+
return new Promise(resolve => {
|
106
|
+
const fontsLoadedHandler = () => {
|
147
107
|
document.fonts.removeEventListener('loadingdone', fontsLoadedHandler);
|
148
108
|
resolve();
|
149
109
|
};
|
@@ -154,247 +114,137 @@ function waitForFontsLoaded() {
|
|
154
114
|
}
|
155
115
|
|
156
116
|
function waitForCaptureCall() {
|
157
|
-
return new Promise(
|
158
|
-
return captureResolver = resolve;
|
159
|
-
});
|
117
|
+
return new Promise(resolve => captureResolver = resolve);
|
160
118
|
}
|
161
119
|
|
162
120
|
function initCreeveyState() {
|
163
121
|
var _window$localStorage$;
|
164
122
|
|
165
|
-
|
123
|
+
const prevState = JSON.parse((_window$localStorage$ = window.localStorage.getItem('Creevey_Tests')) !== null && _window$localStorage$ !== void 0 ? _window$localStorage$ : '{}');
|
166
124
|
if (prevState.creeveyHost) window.__CREEVEY_SERVER_HOST__ = prevState.creeveyHost;
|
167
125
|
if (prevState.creeveyPort) window.__CREEVEY_SERVER_PORT__ = prevState.creeveyPort;
|
168
126
|
if (prevState.setStoriesCounter) setStoriesCounter = prevState.setStoriesCounter;
|
169
127
|
if (prevState.isTestBrowser) isTestBrowser = prevState.isTestBrowser;
|
170
|
-
window.addEventListener('beforeunload',
|
128
|
+
window.addEventListener('beforeunload', () => {
|
171
129
|
window.localStorage.setItem('Creevey_Tests', JSON.stringify({
|
172
130
|
creeveyHost: window.__CREEVEY_SERVER_HOST__,
|
173
131
|
creeveyPort: window.__CREEVEY_SERVER_PORT__,
|
174
|
-
setStoriesCounter
|
175
|
-
isTestBrowser
|
132
|
+
setStoriesCounter,
|
133
|
+
isTestBrowser
|
176
134
|
}));
|
177
135
|
});
|
178
136
|
}
|
179
137
|
|
180
|
-
|
181
|
-
|
182
|
-
|
183
|
-
|
184
|
-
|
138
|
+
let isTestBrowser = false;
|
139
|
+
let captureResolver;
|
140
|
+
let waitForCreevey;
|
141
|
+
let creeveyReady;
|
142
|
+
let setStoriesCounter = 0;
|
185
143
|
|
186
144
|
function withCreevey() {
|
187
|
-
|
188
|
-
|
145
|
+
let currentStory = '';
|
146
|
+
let isAnimationDisabled = false;
|
189
147
|
initCreeveyState();
|
190
148
|
|
191
149
|
function disableAnimation() {
|
192
150
|
isAnimationDisabled = true;
|
193
|
-
|
194
|
-
|
151
|
+
const style = document.createElement('style');
|
152
|
+
const textNode = document.createTextNode(disableAnimationsStyles);
|
195
153
|
style.setAttribute('type', 'text/css');
|
196
154
|
style.appendChild(textNode);
|
197
155
|
document.head.appendChild(style);
|
198
156
|
}
|
199
157
|
|
200
|
-
function getStories() {
|
201
|
-
|
202
|
-
|
203
|
-
|
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
|
-
|
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
|
-
}
|
158
|
+
async function getStories() {
|
159
|
+
var _window$__STORYBOOK_S;
|
160
|
+
|
161
|
+
const storiesPromise = new Promise(resolve => _addons.addons.getChannel().once(Events.SET_STORIES, data => resolve((0, _shared.serializeRawStories)((0, _shared.denormalizeStoryParameters)(data)))));
|
162
|
+
const store = (_window$__STORYBOOK_S = window.__STORYBOOK_STORY_STORE__) !== null && _window$__STORYBOOK_S !== void 0 ? _window$__STORYBOOK_S : {}; // @ts-expect-error `pushToManager` exists only in Storybook 6.0 - 6.3
|
163
|
+
|
164
|
+
if (store.pushToManager) {
|
165
|
+
// @ts-expect-error `pushToManager` exists only in Storybook 6.0 - 6.3
|
166
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-call
|
167
|
+
store.pushToManager();
|
168
|
+
} else if (store.cacheAllCSFFiles) {
|
169
|
+
await store.cacheAllCSFFiles();
|
170
|
+
|
171
|
+
_addons.addons.getChannel().emit(Events.SET_STORIES, store.getSetStoriesPayload());
|
172
|
+
} else return;
|
173
|
+
|
174
|
+
_addons.addons.getChannel().on(Events.SET_STORIES, data => {
|
175
|
+
// TODO Figure out how to get only updated stories
|
176
|
+
// TODO Subscribe on hmr? like use dummy-hmr
|
177
|
+
setStoriesCounter += 1;
|
178
|
+
const stories = (0, _shared.serializeRawStories)((0, _shared.denormalizeStoryParameters)(data));
|
179
|
+
const storiesByFiles = new Map();
|
180
|
+
Object.values(stories).forEach(story => {
|
181
|
+
const storiesFromFile = storiesByFiles.get(story.parameters.fileName);
|
182
|
+
if (storiesFromFile) storiesFromFile.push(story);else storiesByFiles.set(story.parameters.fileName, [story]);
|
183
|
+
});
|
184
|
+
void fetch("http://".concat((0, _helpers.getConnectionUrl)(), "/stories"), {
|
185
|
+
method: 'POST',
|
186
|
+
headers: {
|
187
|
+
'Content-Type': 'application/json'
|
188
|
+
},
|
189
|
+
body: JSON.stringify({
|
190
|
+
setStoriesCounter,
|
191
|
+
stories: [...storiesByFiles.entries()]
|
192
|
+
})
|
193
|
+
});
|
194
|
+
});
|
283
195
|
|
284
|
-
|
285
|
-
return _selectStory.apply(this, arguments);
|
196
|
+
return storiesPromise;
|
286
197
|
}
|
287
198
|
|
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);
|
199
|
+
async function selectStory(storyId, kind, name, shouldWaitForReady, callback) {
|
200
|
+
if (!isAnimationDisabled) disableAnimation();
|
201
|
+
isTestBrowser = true;
|
202
|
+
|
203
|
+
const channel = _addons.addons.getChannel();
|
204
|
+
|
205
|
+
const waitForReady = shouldWaitForReady ? new Promise(resolve => window.__CREEVEY_SET_READY_FOR_CAPTURE__ = resolve) : Promise.resolve();
|
206
|
+
if (storyId == currentStory) await resetCurrentStory(channel);else currentStory = storyId;
|
207
|
+
let isCaptureCalled = false;
|
208
|
+
const renderPromise = waitForStoryRendered(channel);
|
209
|
+
const errorPromise = catchRenderError(channel);
|
210
|
+
const capturePromise = waitForCaptureCall().then(() => isCaptureCalled = true);
|
211
|
+
setTimeout(() => channel.emit(Events.SET_CURRENT_STORY, {
|
212
|
+
storyId,
|
213
|
+
name,
|
214
|
+
kind
|
215
|
+
}), 0);
|
216
|
+
|
217
|
+
try {
|
218
|
+
await Promise.race([(async () => {
|
219
|
+
await Promise.race([renderPromise, capturePromise]);
|
220
|
+
await waitForFontsLoaded();
|
221
|
+
await waitForReady;
|
222
|
+
})(), errorPromise]);
|
223
|
+
callback([null, isCaptureCalled]);
|
224
|
+
} catch (reason) {
|
225
|
+
var _reason$stack;
|
226
|
+
|
227
|
+
// NOTE Event `STORY_THREW_EXCEPTION` triggered only in react and vue frameworks and return Error instance
|
228
|
+
// NOTE Event `STORY_ERRORED` return error-like object without `name` field
|
229
|
+
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;
|
230
|
+
callback([errorMessage]);
|
231
|
+
} finally {
|
232
|
+
renderPromise.cancel();
|
233
|
+
errorPromise.cancel();
|
234
|
+
}
|
385
235
|
}
|
386
236
|
|
387
237
|
function updateGlobals(globals) {
|
388
238
|
_addons.addons.getChannel().emit(Events.UPDATE_GLOBALS, {
|
389
|
-
globals
|
239
|
+
globals
|
390
240
|
});
|
391
241
|
}
|
392
242
|
|
393
243
|
function insertIgnoreStyles(ignoreSelectors) {
|
394
|
-
|
244
|
+
const stylesElement = document.createElement('style');
|
395
245
|
stylesElement.setAttribute('type', 'text/css');
|
396
246
|
document.head.appendChild(stylesElement);
|
397
|
-
ignoreSelectors.forEach(
|
247
|
+
ignoreSelectors.forEach(selector => {
|
398
248
|
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
249
|
});
|
400
250
|
return stylesElement;
|
@@ -408,17 +258,17 @@ function withCreevey() {
|
|
408
258
|
|
409
259
|
function hasPlayCompletedYet(callback) {
|
410
260
|
creeveyReady();
|
411
|
-
|
412
|
-
|
261
|
+
let isCaptureCalled = false;
|
262
|
+
let isPlayCompleted = false;
|
413
263
|
|
414
|
-
|
264
|
+
const channel = _addons.addons.getChannel();
|
415
265
|
|
416
|
-
void waitForStoryRendered(channel).then(
|
266
|
+
void waitForStoryRendered(channel).then(() => {
|
417
267
|
if (isCaptureCalled) return;
|
418
268
|
isPlayCompleted = true;
|
419
269
|
callback(true);
|
420
270
|
});
|
421
|
-
void waitForCaptureCall().then(
|
271
|
+
void waitForCaptureCall().then(() => {
|
422
272
|
if (isPlayCompleted) return;
|
423
273
|
isCaptureCalled = true;
|
424
274
|
callback(false);
|
@@ -431,49 +281,50 @@ function withCreevey() {
|
|
431
281
|
window.__CREEVEY_INSERT_IGNORE_STYLES__ = insertIgnoreStyles;
|
432
282
|
window.__CREEVEY_REMOVE_IGNORE_STYLES__ = removeIgnoreStyles;
|
433
283
|
window.__CREEVEY_HAS_PLAY_COMPLETED_YET__ = hasPlayCompletedYet;
|
434
|
-
window.__CREEVEY_SET_READY_FOR_CAPTURE__ = _types.noop;
|
435
|
-
// [...container.querySelectorAll(query)].filter((e) => e instanceof HTMLElement) as HTMLElement[];
|
436
|
-
// const getMultipleError = (_: Element | null, query: string): string => `Found multiple elements by query: ${query}`;
|
437
|
-
// const getMissingError = (_: Element | null, query: string): string => `Unable to find an element by query: ${query}`;
|
438
|
-
// const [queryByQuery, getAllByQuery, getByQuery, findAllByQuery, findByQuery] = buildQueries(
|
439
|
-
// queryAllByQuery,
|
440
|
-
// getMultipleError,
|
441
|
-
// getMissingError,
|
442
|
-
// );
|
443
|
-
// const queries = {
|
444
|
-
// queryByQuery,
|
445
|
-
// getAllByQuery,
|
446
|
-
// getByQuery,
|
447
|
-
// findAllByQuery,
|
448
|
-
// findByQuery,
|
449
|
-
// };
|
284
|
+
window.__CREEVEY_SET_READY_FOR_CAPTURE__ = _types.noop;
|
450
285
|
|
286
|
+
const queryAllByQuery = (container, query) => [...container.querySelectorAll(query)].filter(e => e instanceof HTMLElement);
|
287
|
+
|
288
|
+
const getMultipleError = (_, query) => "Found multiple elements by query: ".concat(query);
|
289
|
+
|
290
|
+
const getMissingError = (_, query) => "Unable to find an element by query: ".concat(query);
|
291
|
+
|
292
|
+
const [queryByQuery, getAllByQuery, getByQuery, findAllByQuery, findByQuery] = (0, _testingLibrary.buildQueries)(queryAllByQuery, getMultipleError, getMissingError);
|
293
|
+
const queries = {
|
294
|
+
queryByQuery,
|
295
|
+
getAllByQuery,
|
296
|
+
getByQuery,
|
297
|
+
findAllByQuery,
|
298
|
+
findByQuery
|
299
|
+
};
|
451
300
|
return (0, _addons.makeDecorator)({
|
452
301
|
name: 'withCreevey',
|
453
302
|
parameterName: 'creevey',
|
454
|
-
wrapper:
|
303
|
+
wrapper: (getStory, context) => {
|
455
304
|
var _ref2;
|
456
305
|
|
457
306
|
// TODO Define proper types, like captureElement is a promise
|
458
|
-
|
459
|
-
|
460
|
-
|
307
|
+
const {
|
308
|
+
captureElement
|
309
|
+
} = context.parameters.creevey = (_ref2 = context.parameters.creevey) !== null && _ref2 !== void 0 ? _ref2 : {};
|
461
310
|
Object.defineProperty(context.parameters.creevey, 'captureElement', {
|
462
|
-
get
|
311
|
+
get() {
|
463
312
|
switch (true) {
|
464
313
|
case captureElement === undefined:
|
465
314
|
return Promise.resolve(context.canvasElement);
|
466
315
|
|
467
316
|
case captureElement === null:
|
468
317
|
return Promise.resolve(document.documentElement);
|
469
|
-
|
470
|
-
|
318
|
+
|
319
|
+
case typeof captureElement == 'string':
|
320
|
+
return (0, _testingLibrary.within)(context.canvasElement, queries).findByQuery(captureElement);
|
471
321
|
|
472
322
|
case typeof captureElement == 'function':
|
473
323
|
// TODO Define type for it
|
474
324
|
return Promise.resolve(captureElement(context));
|
475
325
|
}
|
476
326
|
},
|
327
|
+
|
477
328
|
enumerable: true,
|
478
329
|
configurable: true
|
479
330
|
});
|
@@ -482,50 +333,19 @@ function withCreevey() {
|
|
482
333
|
});
|
483
334
|
}
|
484
335
|
|
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);
|
336
|
+
async function capture(options) {
|
337
|
+
if (!isTestBrowser) return;
|
338
|
+
captureResolver();
|
339
|
+
waitForCreevey = new Promise(resolve => creeveyReady = resolve);
|
340
|
+
await fetch("http://".concat((0, _helpers.getConnectionUrl)(), "/capture"), {
|
341
|
+
method: 'POST',
|
342
|
+
headers: {
|
343
|
+
'Content-Type': 'application/json'
|
344
|
+
},
|
345
|
+
body: JSON.stringify({
|
346
|
+
workerId: window.__CREEVEY_WORKER_ID__,
|
347
|
+
options
|
348
|
+
})
|
349
|
+
});
|
350
|
+
await waitForCreevey;
|
531
351
|
}
|