creevey 0.9.0-beta.2 → 0.9.0-beta.20
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/.yarn/install-state.gz +0 -0
- package/.yarnrc.yml +1 -0
- package/CHANGELOG.md +51 -0
- package/README.md +9 -1
- package/addon/README.md +3 -0
- package/addon/package.json +5 -0
- package/docs/config.md +29 -26
- package/jest.config.js +6 -0
- package/lib/cjs/cli.js +1 -0
- package/lib/cjs/client/addon/Manager.js +170 -390
- package/lib/cjs/client/addon/components/Addon.js +17 -45
- package/lib/cjs/client/addon/components/Icons.js +12 -14
- package/lib/cjs/client/addon/components/Panel.js +21 -30
- package/lib/cjs/client/addon/components/TestSelect.js +20 -31
- package/lib/cjs/client/addon/components/Tools.js +35 -65
- package/lib/cjs/client/addon/decorator.js +1 -4
- package/lib/cjs/client/addon/index.js +27 -0
- package/lib/cjs/client/addon/preset.js +3 -76
- package/lib/cjs/client/addon/preview.js +11 -0
- package/lib/cjs/client/addon/readyForCapture.js +1 -4
- package/lib/cjs/client/addon/register.js +43 -82
- package/lib/cjs/client/addon/utils.js +4 -8
- package/lib/cjs/client/addon/withCreevey.js +145 -404
- package/lib/cjs/client/shared/components/ImagesView/BlendView.js +25 -35
- package/lib/cjs/client/shared/components/ImagesView/ImagesView.js +29 -41
- package/lib/cjs/client/shared/components/ImagesView/SideBySideView.js +46 -83
- package/lib/cjs/client/shared/components/ImagesView/SlideView.js +39 -67
- package/lib/cjs/client/shared/components/ImagesView/SwapView.js +26 -57
- package/lib/cjs/client/shared/components/ImagesView/index.js +9 -14
- package/lib/cjs/client/shared/components/PageFooter/PageFooter.js +13 -16
- package/lib/cjs/client/shared/components/PageFooter/Paging.js +16 -37
- package/lib/cjs/client/shared/components/PageHeader/ImagePreview.js +42 -34
- package/lib/cjs/client/shared/components/PageHeader/PageHeader.js +40 -84
- package/lib/cjs/client/shared/components/ResultsPage.js +42 -99
- package/lib/cjs/client/shared/creeveyClientApi.js +56 -93
- package/lib/cjs/client/shared/helpers.js +149 -274
- package/lib/cjs/client/shared/viewMode.js +5 -9
- package/lib/cjs/client/web/192.js +1 -0
- package/lib/cjs/client/web/632.js +43 -0
- package/lib/cjs/client/web/794.js +1 -0
- package/lib/cjs/client/web/main.js +79 -38
- package/lib/cjs/client/web/main.js.LICENSE.txt +34 -0
- package/lib/cjs/creevey.js +15 -30
- package/lib/cjs/index.js +0 -15
- package/lib/cjs/server/config.js +16 -36
- package/lib/cjs/server/docker.js +8 -34
- package/lib/cjs/server/index.js +9 -34
- package/lib/cjs/server/logger.js +7 -20
- package/lib/cjs/server/master/api.js +1 -14
- package/lib/cjs/server/master/index.js +25 -49
- package/lib/cjs/server/master/master.js +6 -21
- package/lib/cjs/server/master/pool.js +10 -53
- package/lib/cjs/server/master/runner.js +65 -105
- package/lib/cjs/server/master/server.js +10 -29
- package/lib/cjs/server/messages.js +14 -62
- package/lib/cjs/server/selenium/browser.js +149 -185
- package/lib/cjs/server/selenium/index.js +0 -4
- package/lib/cjs/server/selenium/selenoid.js +18 -44
- package/lib/cjs/server/stories.js +35 -57
- package/lib/cjs/server/storybook/providers/browser.js +15 -29
- package/lib/cjs/server/storybook/providers/hybrid.js +16 -37
- package/lib/cjs/server/telemetry.js +167 -0
- package/lib/cjs/server/testsFiles/parser.js +3 -19
- package/lib/cjs/server/testsFiles/register.js +8 -14
- package/lib/cjs/server/update.js +4 -25
- package/lib/cjs/server/utils.js +35 -76
- package/lib/cjs/server/worker/chai-image.js +1 -27
- package/lib/cjs/server/worker/helpers.js +2 -12
- package/lib/cjs/server/worker/index.js +1 -3
- package/lib/cjs/server/worker/reporter.js +16 -43
- package/lib/cjs/server/worker/worker.js +32 -72
- package/lib/cjs/shared/index.js +87 -0
- package/lib/cjs/shared/serializeRegExp.js +34 -0
- package/lib/cjs/types.js +11 -20
- package/lib/esm/cli.js +1 -1
- package/lib/esm/client/addon/Manager.js +170 -381
- 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 +20 -18
- package/lib/esm/client/addon/components/TestSelect.js +19 -23
- package/lib/esm/client/addon/components/Tools.js +33 -49
- 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 +2 -56
- package/lib/esm/client/addon/preview.js +5 -0
- package/lib/esm/client/addon/readyForCapture.js +1 -3
- package/lib/esm/client/addon/register.js +41 -67
- package/lib/esm/client/addon/utils.js +3 -7
- package/lib/esm/client/addon/withCreevey.js +142 -388
- package/lib/esm/client/shared/components/ImagesView/BlendView.js +22 -18
- package/lib/esm/client/shared/components/ImagesView/ImagesView.js +27 -25
- package/lib/esm/client/shared/components/ImagesView/SideBySideView.js +43 -63
- package/lib/esm/client/shared/components/ImagesView/SlideView.js +36 -47
- package/lib/esm/client/shared/components/ImagesView/SwapView.js +23 -40
- package/lib/esm/client/shared/components/PageFooter/PageFooter.js +12 -8
- package/lib/esm/client/shared/components/PageFooter/Paging.js +15 -29
- package/lib/esm/client/shared/components/PageHeader/ImagePreview.js +40 -25
- package/lib/esm/client/shared/components/PageHeader/PageHeader.js +38 -66
- package/lib/esm/client/shared/components/ResultsPage.js +39 -75
- package/lib/esm/client/shared/creeveyClientApi.js +56 -90
- package/lib/esm/client/shared/helpers.js +133 -230
- package/lib/esm/client/shared/viewMode.js +4 -4
- package/lib/esm/client/web/192.js +1 -0
- package/lib/esm/client/web/632.js +43 -0
- package/lib/esm/client/web/794.js +1 -0
- package/lib/esm/client/web/index.html +19 -0
- package/lib/esm/client/web/main.js +79 -0
- package/lib/esm/client/web/main.js.LICENSE.txt +34 -0
- package/lib/esm/creevey.js +13 -16
- package/lib/esm/index.js +1 -4
- package/lib/esm/server/config.js +9 -16
- package/lib/esm/server/docker.js +6 -14
- package/lib/esm/server/index.js +8 -22
- package/lib/esm/server/logger.js +0 -1
- package/lib/esm/server/master/api.js +0 -9
- package/lib/esm/server/master/index.js +25 -35
- package/lib/esm/server/master/master.js +2 -7
- package/lib/esm/server/master/pool.js +8 -41
- package/lib/esm/server/master/runner.js +64 -90
- package/lib/esm/server/master/server.js +9 -11
- package/lib/esm/server/messages.js +8 -42
- package/lib/esm/server/selenium/browser.js +147 -163
- package/lib/esm/server/selenium/selenoid.js +16 -27
- package/lib/esm/server/stories.js +34 -46
- package/lib/esm/server/storybook/providers/browser.js +12 -17
- package/lib/esm/server/storybook/providers/hybrid.js +11 -22
- package/lib/esm/server/telemetry.js +160 -0
- package/lib/esm/server/testsFiles/parser.js +0 -6
- package/lib/esm/server/testsFiles/register.js +6 -7
- package/lib/esm/server/update.js +1 -13
- package/lib/esm/server/utils.js +20 -41
- package/lib/esm/server/worker/chai-image.js +0 -21
- package/lib/esm/server/worker/helpers.js +2 -9
- package/lib/esm/server/worker/reporter.js +15 -29
- package/lib/esm/server/worker/worker.js +31 -48
- package/lib/esm/shared/index.js +77 -0
- package/lib/esm/shared/serializeRegExp.js +24 -0
- package/lib/esm/types.js +5 -1
- package/lib/types/client/addon/Manager.d.ts +3 -3
- package/lib/types/client/addon/components/Addon.d.ts +1 -0
- package/lib/types/client/addon/components/Icons.d.ts +1 -0
- package/lib/types/client/addon/components/Panel.d.ts +1 -0
- package/lib/types/client/addon/components/Tools.d.ts +1 -0
- 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 +2 -24
- package/lib/types/client/addon/preview.d.ts +4 -0
- package/lib/types/client/addon/utils.d.ts +1 -0
- package/lib/types/client/addon/withCreevey.d.ts +4 -3
- package/lib/types/client/shared/components/ImagesView/BlendView.d.ts +3 -1
- package/lib/types/client/shared/components/ImagesView/SideBySideView.d.ts +3 -1
- package/lib/types/client/shared/components/ImagesView/SlideView.d.ts +3 -1
- package/lib/types/client/shared/components/ImagesView/SwapView.d.ts +3 -1
- package/lib/types/client/shared/components/PageHeader/ImagePreview.d.ts +3 -1
- package/lib/types/client/shared/components/ResultsPage.d.ts +3 -1
- package/lib/types/client/web/CreeveyLoader.d.ts +1 -1
- package/lib/types/client/web/CreeveyView/SideBar/Checkbox.d.ts +6 -3
- package/lib/types/client/web/CreeveyView/SideBar/Search.d.ts +1 -0
- package/lib/types/client/web/CreeveyView/SideBar/SuiteLink.d.ts +19 -14
- package/lib/types/client/web/CreeveyView/SideBar/TestStatusIcon.d.ts +3 -1
- package/lib/types/client/web/CreeveyView/SideBar/TestsStatus.d.ts +3 -1
- package/lib/types/client/web/CreeveyView/SideBar/Toggle.d.ts +1 -0
- package/lib/types/client/web/KeyboardEventsContext.d.ts +4 -2
- package/lib/types/index.d.ts +4 -1
- package/lib/types/server/logger.d.ts +6 -2
- package/lib/types/server/messages.d.ts +14 -12
- package/lib/types/server/selenium/browser.d.ts +5 -3
- package/lib/types/server/storybook/providers/browser.d.ts +2 -4
- package/lib/types/server/storybook/providers/hybrid.d.ts +2 -4
- package/lib/types/server/telemetry.d.ts +2 -0
- package/lib/types/server/utils.d.ts +5 -1
- package/lib/types/shared/index.d.ts +7 -0
- package/lib/types/shared/serializeRegExp.d.ts +9 -0
- package/lib/types/types.d.ts +29 -36
- package/package.json +132 -133
- package/types/global.d.ts +5 -0
- package/lib/cjs/client/web/1.js +0 -13
- package/lib/cjs/client/web/2.js +0 -1
- package/lib/cjs/server/extract.js +0 -50
- package/lib/cjs/server/loaders/babel/creevey-plugin.js +0 -88
- package/lib/cjs/server/loaders/babel/helpers.js +0 -479
- package/lib/cjs/server/loaders/babel/register.js +0 -126
- package/lib/cjs/server/loaders/hooks/mdx.js +0 -30
- package/lib/cjs/server/loaders/hooks/svelte.js +0 -65
- package/lib/cjs/server/loaders/webpack/compile.js +0 -286
- package/lib/cjs/server/loaders/webpack/creevey-loader.js +0 -174
- package/lib/cjs/server/loaders/webpack/dummy-hmr.js +0 -44
- package/lib/cjs/server/loaders/webpack/mdx-loader.js +0 -72
- package/lib/cjs/server/loaders/webpack/start.js +0 -41
- package/lib/cjs/server/storybook/entry.js +0 -68
- package/lib/cjs/server/storybook/helpers.js +0 -165
- package/lib/cjs/server/storybook/providers/nodejs.js +0 -239
- package/lib/cjs/shared.js +0 -124
- package/lib/esm/server/extract.js +0 -34
- package/lib/esm/server/loaders/babel/creevey-plugin.js +0 -74
- package/lib/esm/server/loaders/babel/helpers.js +0 -462
- package/lib/esm/server/loaders/babel/register.js +0 -105
- package/lib/esm/server/loaders/hooks/mdx.js +0 -15
- package/lib/esm/server/loaders/hooks/svelte.js +0 -49
- package/lib/esm/server/loaders/webpack/compile.js +0 -263
- package/lib/esm/server/loaders/webpack/creevey-loader.js +0 -153
- package/lib/esm/server/loaders/webpack/dummy-hmr.js +0 -36
- package/lib/esm/server/loaders/webpack/mdx-loader.js +0 -58
- package/lib/esm/server/loaders/webpack/start.js +0 -27
- package/lib/esm/server/storybook/entry.js +0 -44
- package/lib/esm/server/storybook/helpers.js +0 -106
- package/lib/esm/server/storybook/providers/nodejs.js +0 -217
- package/lib/esm/shared.js +0 -93
- package/lib/types/server/extract.d.ts +0 -2
- package/lib/types/server/loaders/babel/creevey-plugin.d.ts +0 -1
- package/lib/types/server/loaders/babel/helpers.d.ts +0 -19
- package/lib/types/server/loaders/babel/register.d.ts +0 -5
- package/lib/types/server/loaders/hooks/mdx.d.ts +0 -1
- package/lib/types/server/loaders/hooks/svelte.d.ts +0 -1
- package/lib/types/server/loaders/webpack/compile.d.ts +0 -2
- package/lib/types/server/loaders/webpack/creevey-loader.d.ts +0 -2
- package/lib/types/server/loaders/webpack/dummy-hmr.d.ts +0 -10
- package/lib/types/server/loaders/webpack/mdx-loader.d.ts +0 -6
- package/lib/types/server/loaders/webpack/start.d.ts +0 -1
- package/lib/types/server/storybook/entry.d.ts +0 -18
- package/lib/types/server/storybook/helpers.d.ts +0 -24
- package/lib/types/server/storybook/providers/nodejs.d.ts +0 -9
- package/lib/types/shared.d.ts +0 -16
- package/preset.js +0 -9
- package/storybook-static/stories.json +0 -21
- package/types/mdx.d.ts +0 -6
@@ -1,35 +1,3 @@
|
|
1
|
-
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
2
|
-
|
3
|
-
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
4
|
-
|
5
|
-
function _iterableToArrayLimit(arr, i) { var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"]; if (_i == null) return; var _arr = []; var _n = true; var _d = false; var _s, _e; try { for (_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; }
|
6
|
-
|
7
|
-
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
8
|
-
|
9
|
-
function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
|
10
|
-
|
11
|
-
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."); }
|
12
|
-
|
13
|
-
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); }
|
14
|
-
|
15
|
-
function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
|
16
|
-
|
17
|
-
function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
|
18
|
-
|
19
|
-
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; }
|
20
|
-
|
21
|
-
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
|
22
|
-
|
23
|
-
function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
|
24
|
-
|
25
|
-
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
26
|
-
|
27
|
-
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
|
28
|
-
|
29
|
-
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
|
30
|
-
|
31
|
-
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
32
|
-
|
33
1
|
import { SET_STORIES, STORY_RENDERED } from '@storybook/core-events';
|
34
2
|
import { denormalizeStoryParameters } from '../../shared';
|
35
3
|
import { isDefined } from '../../types';
|
@@ -37,360 +5,181 @@ import { initCreeveyClientApi } from '../shared/creeveyClientApi';
|
|
37
5
|
import { calcStatus } from '../shared/helpers';
|
38
6
|
import { ADDON_ID } from './register';
|
39
7
|
import { getEmojiByTestStatus } from './utils';
|
40
|
-
export
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
8
|
+
export class CreeveyManager {
|
9
|
+
storyId = '';
|
10
|
+
activeBrowser = '';
|
11
|
+
selectedTestId = '';
|
12
|
+
status = {
|
13
|
+
isRunning: false,
|
14
|
+
tests: {},
|
15
|
+
browsers: []
|
16
|
+
};
|
17
|
+
creeveyApi = null;
|
18
|
+
stories = {};
|
19
|
+
updateStatusListeners = [];
|
20
|
+
changeTestListeners = [];
|
21
|
+
constructor(storybookApi) {
|
22
|
+
this.storybookApi = storybookApi;
|
23
|
+
this.storybookApi = storybookApi;
|
24
|
+
}
|
25
|
+
initAll = async () => {
|
26
|
+
this.storybookApi.on(STORY_RENDERED, this.onStoryRendered);
|
27
|
+
this.storybookApi.on(SET_STORIES, this.onSetStories);
|
28
|
+
this.creeveyApi = await initCreeveyClientApi();
|
29
|
+
this.creeveyApi.onUpdate(this.handleCreeveyUpdate);
|
30
|
+
this.status = await this.creeveyApi.status;
|
31
|
+
};
|
32
|
+
onUpdateStatus(listener) {
|
33
|
+
this.updateStatusListeners.push(listener);
|
34
|
+
return () => void (this.updateStatusListeners = this.updateStatusListeners.filter(x => x != listener));
|
35
|
+
}
|
36
|
+
onChangeTest(listener) {
|
37
|
+
this.changeTestListeners.push(listener);
|
38
|
+
return () => void (this.changeTestListeners = this.changeTestListeners.filter(x => x != listener));
|
39
|
+
}
|
40
|
+
handleCreeveyUpdate = update => {
|
41
|
+
const {
|
42
|
+
tests,
|
43
|
+
removedTests = [],
|
44
|
+
isRunning
|
45
|
+
} = update;
|
46
|
+
if (isDefined(isRunning)) {
|
47
|
+
this.status.isRunning = isRunning;
|
48
|
+
}
|
49
|
+
if (isDefined(tests)) {
|
50
|
+
const prevTests = this.status.tests;
|
51
|
+
const prevStories = this.stories || {};
|
52
|
+
Object.values(tests).filter(isDefined).forEach(update => {
|
53
|
+
const {
|
54
|
+
id,
|
55
|
+
skip,
|
56
|
+
status,
|
57
|
+
results,
|
58
|
+
approved,
|
59
|
+
storyId
|
60
|
+
} = update;
|
61
|
+
const test = prevTests[id];
|
62
|
+
if (!test) {
|
63
|
+
return prevTests[id] = update;
|
93
64
|
}
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
if (isDefined(isRunning)) {
|
104
|
-
_this.status.isRunning = isRunning;
|
105
|
-
}
|
106
|
-
|
107
|
-
if (isDefined(tests)) {
|
108
|
-
var prevTests = _this.status.tests;
|
109
|
-
var prevStories = _this.stories || {};
|
110
|
-
Object.values(tests).filter(isDefined).forEach(function (update) {
|
111
|
-
var _test$results;
|
112
|
-
|
113
|
-
var id = update.id,
|
114
|
-
skip = update.skip,
|
115
|
-
status = update.status,
|
116
|
-
results = update.results,
|
117
|
-
approved = update.approved,
|
118
|
-
storyId = update.storyId;
|
119
|
-
var test = prevTests[id];
|
120
|
-
|
121
|
-
if (!test) {
|
122
|
-
return prevTests[id] = update;
|
123
|
-
}
|
124
|
-
|
125
|
-
if (isDefined(skip)) test.skip = skip;
|
126
|
-
|
127
|
-
if (isDefined(status)) {
|
128
|
-
test.status = status;
|
129
|
-
|
130
|
-
if (isDefined(storyId) && isDefined(prevStories[storyId])) {
|
131
|
-
var story = prevStories[storyId];
|
132
|
-
|
133
|
-
var storyStatus = _this.getStoryTests(storyId);
|
134
|
-
|
135
|
-
var oldStatus = storyStatus.map(function (x) {
|
136
|
-
return x.id === id ? status : x.status;
|
137
|
-
}).reduce(function (oldStatus, newStatus) {
|
138
|
-
return calcStatus(oldStatus, newStatus);
|
139
|
-
}, undefined);
|
140
|
-
story.name = _this.addStatusToStoryName(story.name, calcStatus(oldStatus, status), skip || false);
|
141
|
-
}
|
65
|
+
if (isDefined(skip)) test.skip = skip;
|
66
|
+
if (isDefined(status)) {
|
67
|
+
test.status = status;
|
68
|
+
if (isDefined(storyId) && isDefined(prevStories[storyId])) {
|
69
|
+
const story = prevStories[storyId];
|
70
|
+
const storyStatus = this.getStoryTests(storyId);
|
71
|
+
const oldStatus = storyStatus.map(x => x.id === id ? status : x.status).reduce((oldStatus, newStatus) => calcStatus(oldStatus, newStatus), undefined);
|
72
|
+
story.name = this.addStatusToStoryName(story.name, calcStatus(oldStatus, status), skip || false);
|
142
73
|
}
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
return retry !== undefined && test && ((test.approved = (test === null || test === void 0 ? void 0 : test.approved) || {})[image] = retry);
|
153
|
-
});
|
154
|
-
}
|
155
|
-
});
|
156
|
-
removedTests.forEach(function (_ref4) {
|
157
|
-
var id = _ref4.id;
|
158
|
-
return delete prevTests[id];
|
159
|
-
});
|
160
|
-
_this.status.tests = prevTests;
|
161
|
-
_this.stories = prevStories;
|
162
|
-
|
163
|
-
_this.setPanelsTitle();
|
164
|
-
|
165
|
-
void _this.storybookApi.setStories(_this.stories);
|
166
|
-
}
|
167
|
-
|
168
|
-
_this.updateStatusListeners.forEach(function (x) {
|
169
|
-
return x(update);
|
170
|
-
});
|
171
|
-
});
|
172
|
-
|
173
|
-
_defineProperty(this, "getCurrentTest", function () {
|
174
|
-
return _this.status.tests[_this.selectedTestId];
|
175
|
-
});
|
176
|
-
|
177
|
-
_defineProperty(this, "onStoryRendered", function (storyId) {
|
178
|
-
if (_this.storyId === '') void _this.addStatusesToSideBar();
|
179
|
-
|
180
|
-
if (_this.storyId !== storyId) {
|
181
|
-
var _this$getTestsByStory, _this$getTestsByStory2;
|
182
|
-
|
183
|
-
_this.storyId = storyId;
|
184
|
-
_this.selectedTestId = (_this$getTestsByStory = (_this$getTestsByStory2 = _this.getTestsByStoryIdAndBrowser(_this.activeBrowser)[0]) === null || _this$getTestsByStory2 === void 0 ? void 0 : _this$getTestsByStory2.id) !== null && _this$getTestsByStory !== void 0 ? _this$getTestsByStory : '';
|
185
|
-
|
186
|
-
_this.setPanelsTitle();
|
187
|
-
|
188
|
-
_this.changeTestListeners.forEach(function (x) {
|
189
|
-
return x(_this.selectedTestId);
|
190
|
-
});
|
191
|
-
}
|
192
|
-
});
|
193
|
-
|
194
|
-
_defineProperty(this, "onStart", function () {
|
195
|
-
var _this$creeveyApi;
|
196
|
-
|
197
|
-
(_this$creeveyApi = _this.creeveyApi) === null || _this$creeveyApi === void 0 ? void 0 : _this$creeveyApi.start([_this.selectedTestId]);
|
198
|
-
});
|
199
|
-
|
200
|
-
_defineProperty(this, "onStop", function () {
|
201
|
-
var _this$creeveyApi2;
|
202
|
-
|
203
|
-
(_this$creeveyApi2 = _this.creeveyApi) === null || _this$creeveyApi2 === void 0 ? void 0 : _this$creeveyApi2.stop();
|
204
|
-
});
|
205
|
-
|
206
|
-
_defineProperty(this, "onImageApprove", function (id, retry, image) {
|
207
|
-
var _this$creeveyApi3;
|
208
|
-
|
209
|
-
return (_this$creeveyApi3 = _this.creeveyApi) === null || _this$creeveyApi3 === void 0 ? void 0 : _this$creeveyApi3.approve(id, retry, image);
|
210
|
-
});
|
211
|
-
|
212
|
-
_defineProperty(this, "onStartAllStoryTests", function () {
|
213
|
-
var _this$creeveyApi4;
|
214
|
-
|
215
|
-
var ids = Object.values(_this.status.tests).filter(isDefined).filter(function (x) {
|
216
|
-
return x.storyId === _this.storyId;
|
217
|
-
}).map(function (x) {
|
218
|
-
return x.id;
|
219
|
-
});
|
220
|
-
(_this$creeveyApi4 = _this.creeveyApi) === null || _this$creeveyApi4 === void 0 ? void 0 : _this$creeveyApi4.start(ids);
|
221
|
-
});
|
222
|
-
|
223
|
-
_defineProperty(this, "onStartAllTests", function () {
|
224
|
-
var _this$creeveyApi5;
|
225
|
-
|
226
|
-
var ids = Object.values(_this.status.tests).filter(isDefined).map(function (x) {
|
227
|
-
return x.id;
|
228
|
-
});
|
229
|
-
(_this$creeveyApi5 = _this.creeveyApi) === null || _this$creeveyApi5 === void 0 ? void 0 : _this$creeveyApi5.start(ids);
|
230
|
-
});
|
231
|
-
|
232
|
-
_defineProperty(this, "onSetStories", function (data) {
|
233
|
-
var stories = data.v ? denormalizeStoryParameters(data) : data.stories;
|
234
|
-
_this.stories = stories;
|
235
|
-
});
|
236
|
-
|
237
|
-
_defineProperty(this, "setActiveBrowser", function (browser) {
|
238
|
-
var _this$getTestsByStory3, _this$getTestsByStory4;
|
239
|
-
|
240
|
-
_this.activeBrowser = browser;
|
241
|
-
_this.selectedTestId = (_this$getTestsByStory3 = (_this$getTestsByStory4 = _this.getTestsByStoryIdAndBrowser(_this.activeBrowser)[0]) === null || _this$getTestsByStory4 === void 0 ? void 0 : _this$getTestsByStory4.id) !== null && _this$getTestsByStory3 !== void 0 ? _this$getTestsByStory3 : '';
|
242
|
-
|
243
|
-
_this.changeTestListeners.forEach(function (x) {
|
244
|
-
return x(_this.selectedTestId);
|
74
|
+
}
|
75
|
+
if (isDefined(results)) test.results ? test.results.push(...results) : test.results = results;
|
76
|
+
if (isDefined(approved)) {
|
77
|
+
Object.entries(approved).forEach(_ref => {
|
78
|
+
let [image, retry] = _ref;
|
79
|
+
return retry !== undefined && test && ((test.approved = test?.approved || {})[image] = retry);
|
80
|
+
});
|
81
|
+
}
|
245
82
|
});
|
246
|
-
|
247
|
-
|
248
|
-
|
249
|
-
|
250
|
-
|
251
|
-
_this.changeTestListeners.forEach(function (x) {
|
252
|
-
return x(_this.selectedTestId);
|
83
|
+
removedTests.forEach(_ref2 => {
|
84
|
+
let {
|
85
|
+
id
|
86
|
+
} = _ref2;
|
87
|
+
return delete prevTests[id];
|
253
88
|
});
|
254
|
-
|
255
|
-
|
256
|
-
|
257
|
-
|
258
|
-
|
259
|
-
return (result === null || result === void 0 ? void 0 : result.storyId) === storyId;
|
260
|
-
}).filter(isDefined);
|
261
|
-
});
|
262
|
-
|
263
|
-
_defineProperty(this, "getBrowsers", function () {
|
264
|
-
return _this.status.browsers;
|
265
|
-
});
|
266
|
-
|
267
|
-
_defineProperty(this, "getTestsByStoryIdAndBrowser", function (browser) {
|
268
|
-
return Object.values(_this.status.tests).filter(function (x) {
|
269
|
-
return (x === null || x === void 0 ? void 0 : x.browser) === browser && x.storyId === _this.storyId;
|
270
|
-
}).filter(isDefined);
|
271
|
-
});
|
272
|
-
|
273
|
-
_defineProperty(this, "getTabTitle", function (browser) {
|
274
|
-
var tests = _this.getTestsByStoryIdAndBrowser(browser);
|
275
|
-
|
276
|
-
var browserStatus = tests.map(function (x) {
|
277
|
-
return x && x.status;
|
278
|
-
}).reduce(function (oldStatus, newStatus) {
|
279
|
-
return calcStatus(oldStatus, newStatus);
|
280
|
-
}, undefined);
|
281
|
-
var browserSkip = tests.length > 0 ? tests.every(function (x) {
|
282
|
-
return x && x.skip;
|
283
|
-
}) : false;
|
284
|
-
var emojiStatus = getEmojiByTestStatus(browserStatus, browserSkip);
|
285
|
-
return "".concat(emojiStatus ? "".concat(emojiStatus, " ") : '', "Creevey/").concat(browser);
|
286
|
-
});
|
287
|
-
|
288
|
-
_defineProperty(this, "setPanelsTitle", function () {
|
289
|
-
var _this$storybookApi;
|
290
|
-
|
291
|
-
var panels = (_this$storybookApi = _this.storybookApi) === null || _this$storybookApi === void 0 ? void 0 : _this$storybookApi.getPanels();
|
292
|
-
if (!panels) return;
|
293
|
-
var firstPanelBrowser = _this.activeBrowser;
|
294
|
-
|
295
|
-
for (var p in panels) {
|
296
|
-
var _panel$id;
|
297
|
-
|
298
|
-
var panel = panels[p];
|
299
|
-
|
300
|
-
if (((_panel$id = panel.id) === null || _panel$id === void 0 ? void 0 : _panel$id.indexOf(ADDON_ID)) === 0 && panel.paramKey) {
|
301
|
-
panel.title = _this.getTabTitle(panel.paramKey);
|
302
|
-
if (!firstPanelBrowser) firstPanelBrowser = panel.paramKey;
|
303
|
-
}
|
304
|
-
}
|
305
|
-
|
306
|
-
_this.storybookApi.setSelectedPanel("".concat(ADDON_ID, "/panel/").concat(firstPanelBrowser));
|
307
|
-
});
|
308
|
-
|
309
|
-
this.storybookApi = storybookApi;
|
310
|
-
}
|
311
|
-
|
312
|
-
_createClass(CreeveyManager, [{
|
313
|
-
key: "onUpdateStatus",
|
314
|
-
value: function onUpdateStatus(listener) {
|
315
|
-
var _this2 = this;
|
316
|
-
|
317
|
-
this.updateStatusListeners.push(listener);
|
318
|
-
return function () {
|
319
|
-
return void (_this2.updateStatusListeners = _this2.updateStatusListeners.filter(function (x) {
|
320
|
-
return x != listener;
|
321
|
-
}));
|
322
|
-
};
|
89
|
+
this.status.tests = prevTests;
|
90
|
+
this.stories = prevStories;
|
91
|
+
this.setPanelsTitle();
|
92
|
+
// TODO Check setStories method in 6.x and migrate properly
|
93
|
+
this.storybookApi.emit(SET_STORIES, this.stories);
|
323
94
|
}
|
324
|
-
|
325
|
-
|
326
|
-
|
327
|
-
|
328
|
-
|
329
|
-
|
330
|
-
|
331
|
-
|
332
|
-
|
333
|
-
|
334
|
-
|
95
|
+
this.updateStatusListeners.forEach(x => x(update));
|
96
|
+
};
|
97
|
+
getCurrentTest = () => {
|
98
|
+
return this.status.tests[this.selectedTestId];
|
99
|
+
};
|
100
|
+
onStoryRendered = storyId => {
|
101
|
+
if (this.storyId === '') this.addStatusesToSideBar();
|
102
|
+
if (this.storyId !== storyId) {
|
103
|
+
this.storyId = storyId;
|
104
|
+
this.selectedTestId = this.getTestsByStoryIdAndBrowser(this.activeBrowser)[0]?.id ?? '';
|
105
|
+
this.setPanelsTitle();
|
106
|
+
this.changeTestListeners.forEach(x => x(this.selectedTestId));
|
335
107
|
}
|
336
|
-
}
|
337
|
-
|
338
|
-
|
339
|
-
|
340
|
-
|
341
|
-
|
342
|
-
|
343
|
-
|
344
|
-
|
345
|
-
|
346
|
-
|
347
|
-
|
348
|
-
|
349
|
-
|
350
|
-
|
351
|
-
|
352
|
-
|
353
|
-
|
354
|
-
|
355
|
-
|
356
|
-
|
357
|
-
|
358
|
-
|
359
|
-
|
360
|
-
|
361
|
-
|
362
|
-
|
363
|
-
|
364
|
-
|
365
|
-
|
366
|
-
|
367
|
-
|
368
|
-
|
369
|
-
|
370
|
-
|
371
|
-
|
372
|
-
|
373
|
-
|
374
|
-
|
375
|
-
|
376
|
-
|
377
|
-
|
378
|
-
|
379
|
-
|
380
|
-
|
381
|
-
|
108
|
+
};
|
109
|
+
onStart = () => {
|
110
|
+
this.creeveyApi?.start([this.selectedTestId]);
|
111
|
+
};
|
112
|
+
onStop = () => {
|
113
|
+
this.creeveyApi?.stop();
|
114
|
+
};
|
115
|
+
onImageApprove = (id, retry, image) => this.creeveyApi?.approve(id, retry, image);
|
116
|
+
onStartAllStoryTests = () => {
|
117
|
+
const ids = Object.values(this.status.tests).filter(isDefined).filter(x => x.storyId === this.storyId).map(x => x.id);
|
118
|
+
this.creeveyApi?.start(ids);
|
119
|
+
};
|
120
|
+
onStartAllTests = () => {
|
121
|
+
const ids = Object.values(this.status.tests).filter(isDefined).map(x => x.id);
|
122
|
+
this.creeveyApi?.start(ids);
|
123
|
+
};
|
124
|
+
onSetStories = data => {
|
125
|
+
const stories = data.v ? denormalizeStoryParameters(data) : data.stories;
|
126
|
+
this.stories = stories;
|
127
|
+
};
|
128
|
+
setActiveBrowser = browser => {
|
129
|
+
this.activeBrowser = browser;
|
130
|
+
this.selectedTestId = this.getTestsByStoryIdAndBrowser(this.activeBrowser)[0]?.id ?? '';
|
131
|
+
this.changeTestListeners.forEach(x => x(this.selectedTestId));
|
132
|
+
};
|
133
|
+
setSelectedTestId = testId => {
|
134
|
+
this.selectedTestId = testId;
|
135
|
+
this.changeTestListeners.forEach(x => x(this.selectedTestId));
|
136
|
+
};
|
137
|
+
getStoryTests = storyId => {
|
138
|
+
if (!this.status || !this.status.tests) return [];
|
139
|
+
return Object.values(this.status.tests).filter(result => result?.storyId === storyId).filter(isDefined);
|
140
|
+
};
|
141
|
+
getBrowsers = () => {
|
142
|
+
return this.status.browsers;
|
143
|
+
};
|
144
|
+
getTestsByStoryIdAndBrowser = browser => {
|
145
|
+
return Object.values(this.status.tests).filter(x => x?.browser === browser && x.storyId === this.storyId).filter(isDefined);
|
146
|
+
};
|
147
|
+
getTabTitle = browser => {
|
148
|
+
const tests = this.getTestsByStoryIdAndBrowser(browser);
|
149
|
+
const browserStatus = tests.map(x => x && x.status).reduce((oldStatus, newStatus) => calcStatus(oldStatus, newStatus), undefined);
|
150
|
+
const browserSkip = tests.length > 0 ? tests.every(x => x && x.skip) : false;
|
151
|
+
const emojiStatus = getEmojiByTestStatus(browserStatus, browserSkip);
|
152
|
+
return `${emojiStatus ? `${emojiStatus} ` : ''}Creevey/${browser}`;
|
153
|
+
};
|
154
|
+
setPanelsTitle = () => {
|
155
|
+
const panels = this.storybookApi?.getPanels();
|
156
|
+
if (!panels) return;
|
157
|
+
let firstPanelBrowser = this.activeBrowser;
|
158
|
+
for (const p in panels) {
|
159
|
+
const panel = panels[p];
|
160
|
+
if (panel.id?.indexOf(ADDON_ID) === 0 && panel.paramKey) {
|
161
|
+
panel.title = this.getTabTitle(panel.paramKey);
|
162
|
+
if (!firstPanelBrowser) firstPanelBrowser = panel.paramKey;
|
382
163
|
}
|
383
|
-
|
384
|
-
return addStatusesToSideBar;
|
385
|
-
}()
|
386
|
-
}, {
|
387
|
-
key: "addStatusToStoryName",
|
388
|
-
value: function addStatusToStoryName(name, status, skip) {
|
389
|
-
name = name.replace(/^(❌|✔|🟡|🕗|⏸) /, '');
|
390
|
-
var emojiStatus = getEmojiByTestStatus(status, skip);
|
391
|
-
return "".concat(emojiStatus ? "".concat(emojiStatus, " ") : '', " ").concat(name);
|
392
164
|
}
|
393
|
-
|
394
|
-
|
395
|
-
|
396
|
-
|
165
|
+
this.storybookApi.setSelectedPanel(`${ADDON_ID}/panel/${firstPanelBrowser}`);
|
166
|
+
};
|
167
|
+
addStatusesToSideBar() {
|
168
|
+
if (!Object.keys(this.stories).length) return;
|
169
|
+
const stories = this.stories;
|
170
|
+
Object.keys(this.stories).forEach(storyId => {
|
171
|
+
const storyStatus = this.getStoryTests(storyId);
|
172
|
+
const status = storyStatus.map(x => x.status).reduce((oldStatus, newStatus) => calcStatus(oldStatus, newStatus), undefined);
|
173
|
+
const skip = storyStatus.length > 0 ? storyStatus.every(x => x.skip) : false;
|
174
|
+
this.stories[storyId].name = this.addStatusToStoryName(stories[storyId].name, status, skip);
|
175
|
+
});
|
176
|
+
|
177
|
+
// TODO Check setStories method in 6.x and migrate properly
|
178
|
+
this.storybookApi.emit(SET_STORIES, this.stories);
|
179
|
+
}
|
180
|
+
addStatusToStoryName(name, status, skip) {
|
181
|
+
name = name.replace(/^(❌|✔|🟡|🕗|⏸) /, '');
|
182
|
+
const emojiStatus = getEmojiByTestStatus(status, skip);
|
183
|
+
return `${emojiStatus ? `${emojiStatus} ` : ''} ${name}`;
|
184
|
+
}
|
185
|
+
}
|
@@ -1,50 +1,31 @@
|
|
1
|
-
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
2
|
-
|
3
|
-
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
4
|
-
|
5
|
-
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); }
|
6
|
-
|
7
|
-
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; }
|
8
|
-
|
9
|
-
function _iterableToArrayLimit(arr, i) { var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"]; if (_i == null) return; var _arr = []; var _n = true; var _d = false; var _s, _e; try { for (_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; }
|
10
|
-
|
11
|
-
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
12
|
-
|
13
1
|
import { Placeholder } from '@storybook/components';
|
14
2
|
import React, { useEffect, useState } from 'react';
|
15
3
|
import { Panel } from './Panel';
|
16
|
-
export
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
var _useState3 = useState(manager.selectedTestId),
|
27
|
-
_useState4 = _slicedToArray(_useState3, 2),
|
28
|
-
selectedTestId = _useState4[0],
|
29
|
-
setSelectedTestId = _useState4[1];
|
30
|
-
|
31
|
-
useEffect(function () {
|
4
|
+
export const Addon = _ref => {
|
5
|
+
let {
|
6
|
+
active,
|
7
|
+
browser,
|
8
|
+
manager
|
9
|
+
} = _ref;
|
10
|
+
const [tests, setTests] = useState([]);
|
11
|
+
const [selectedTestId, setSelectedTestId] = useState(manager.selectedTestId);
|
12
|
+
useEffect(() => {
|
32
13
|
if (active) {
|
33
14
|
manager.setActiveBrowser(browser);
|
34
|
-
|
15
|
+
const browserTests = manager.getTestsByStoryIdAndBrowser(manager.activeBrowser);
|
35
16
|
setTests(browserTests);
|
36
17
|
}
|
37
18
|
}, [active, browser, manager]);
|
38
|
-
useEffect(
|
39
|
-
|
19
|
+
useEffect(() => {
|
20
|
+
const unsubscribe = manager.onChangeTest(testId => {
|
40
21
|
setSelectedTestId(testId);
|
41
|
-
|
22
|
+
const status = manager.getTestsByStoryIdAndBrowser(manager.activeBrowser);
|
42
23
|
setTests(status);
|
43
24
|
});
|
44
25
|
return unsubscribe;
|
45
26
|
}, [manager]);
|
46
|
-
useEffect(
|
47
|
-
|
27
|
+
useEffect(() => {
|
28
|
+
const unsubscribe = manager.onUpdateStatus(() => {
|
48
29
|
setTests(manager.getTestsByStoryIdAndBrowser(manager.activeBrowser));
|
49
30
|
});
|
50
31
|
return unsubscribe;
|