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
@@ -4,409 +4,189 @@ Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
5
5
|
});
|
6
6
|
exports.CreeveyManager = void 0;
|
7
|
-
|
8
7
|
var _coreEvents = require("@storybook/core-events");
|
9
|
-
|
10
8
|
var _shared = require("../../shared");
|
11
|
-
|
12
9
|
var _types = require("../../types");
|
13
|
-
|
14
10
|
var _creeveyClientApi = require("../shared/creeveyClientApi");
|
15
|
-
|
16
11
|
var _helpers = require("../shared/helpers");
|
17
|
-
|
18
12
|
var _register = require("./register");
|
19
|
-
|
20
13
|
var _utils = require("./utils");
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
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
|
-
_defineProperty(this, "changeTestListeners", []);
|
79
|
-
|
80
|
-
_defineProperty(this, "initAll", /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee() {
|
81
|
-
return regeneratorRuntime.wrap(function _callee$(_context) {
|
82
|
-
while (1) {
|
83
|
-
switch (_context.prev = _context.next) {
|
84
|
-
case 0:
|
85
|
-
_this.storybookApi.on(_coreEvents.STORY_RENDERED, _this.onStoryRendered);
|
86
|
-
|
87
|
-
_this.storybookApi.on(_coreEvents.SET_STORIES, _this.onSetStories);
|
88
|
-
|
89
|
-
_context.next = 4;
|
90
|
-
return (0, _creeveyClientApi.initCreeveyClientApi)();
|
91
|
-
|
92
|
-
case 4:
|
93
|
-
_this.creeveyApi = _context.sent;
|
94
|
-
|
95
|
-
_this.creeveyApi.onUpdate(_this.handleCreeveyUpdate);
|
96
|
-
|
97
|
-
_context.next = 8;
|
98
|
-
return _this.creeveyApi.status;
|
99
|
-
|
100
|
-
case 8:
|
101
|
-
_this.status = _context.sent;
|
102
|
-
|
103
|
-
case 9:
|
104
|
-
case "end":
|
105
|
-
return _context.stop();
|
106
|
-
}
|
14
|
+
class CreeveyManager {
|
15
|
+
storyId = '';
|
16
|
+
activeBrowser = '';
|
17
|
+
selectedTestId = '';
|
18
|
+
status = {
|
19
|
+
isRunning: false,
|
20
|
+
tests: {},
|
21
|
+
browsers: []
|
22
|
+
};
|
23
|
+
creeveyApi = null;
|
24
|
+
stories = {};
|
25
|
+
updateStatusListeners = [];
|
26
|
+
changeTestListeners = [];
|
27
|
+
constructor(storybookApi) {
|
28
|
+
this.storybookApi = storybookApi;
|
29
|
+
this.storybookApi = storybookApi;
|
30
|
+
}
|
31
|
+
initAll = async () => {
|
32
|
+
this.storybookApi.on(_coreEvents.STORY_RENDERED, this.onStoryRendered);
|
33
|
+
this.storybookApi.on(_coreEvents.SET_STORIES, this.onSetStories);
|
34
|
+
this.creeveyApi = await (0, _creeveyClientApi.initCreeveyClientApi)();
|
35
|
+
this.creeveyApi.onUpdate(this.handleCreeveyUpdate);
|
36
|
+
this.status = await this.creeveyApi.status;
|
37
|
+
};
|
38
|
+
onUpdateStatus(listener) {
|
39
|
+
this.updateStatusListeners.push(listener);
|
40
|
+
return () => void (this.updateStatusListeners = this.updateStatusListeners.filter(x => x != listener));
|
41
|
+
}
|
42
|
+
onChangeTest(listener) {
|
43
|
+
this.changeTestListeners.push(listener);
|
44
|
+
return () => void (this.changeTestListeners = this.changeTestListeners.filter(x => x != listener));
|
45
|
+
}
|
46
|
+
handleCreeveyUpdate = update => {
|
47
|
+
const {
|
48
|
+
tests,
|
49
|
+
removedTests = [],
|
50
|
+
isRunning
|
51
|
+
} = update;
|
52
|
+
if ((0, _types.isDefined)(isRunning)) {
|
53
|
+
this.status.isRunning = isRunning;
|
54
|
+
}
|
55
|
+
if ((0, _types.isDefined)(tests)) {
|
56
|
+
const prevTests = this.status.tests;
|
57
|
+
const prevStories = this.stories || {};
|
58
|
+
Object.values(tests).filter(_types.isDefined).forEach(update => {
|
59
|
+
const {
|
60
|
+
id,
|
61
|
+
skip,
|
62
|
+
status,
|
63
|
+
results,
|
64
|
+
approved,
|
65
|
+
storyId
|
66
|
+
} = update;
|
67
|
+
const test = prevTests[id];
|
68
|
+
if (!test) {
|
69
|
+
return prevTests[id] = update;
|
107
70
|
}
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
if ((0, _types.isDefined)(isRunning)) {
|
118
|
-
_this.status.isRunning = isRunning;
|
119
|
-
}
|
120
|
-
|
121
|
-
if ((0, _types.isDefined)(tests)) {
|
122
|
-
var prevTests = _this.status.tests;
|
123
|
-
var prevStories = _this.stories || {};
|
124
|
-
Object.values(tests).filter(_types.isDefined).forEach(function (update) {
|
125
|
-
var _test$results;
|
126
|
-
|
127
|
-
var id = update.id,
|
128
|
-
skip = update.skip,
|
129
|
-
status = update.status,
|
130
|
-
results = update.results,
|
131
|
-
approved = update.approved,
|
132
|
-
storyId = update.storyId;
|
133
|
-
var test = prevTests[id];
|
134
|
-
|
135
|
-
if (!test) {
|
136
|
-
return prevTests[id] = update;
|
137
|
-
}
|
138
|
-
|
139
|
-
if ((0, _types.isDefined)(skip)) test.skip = skip;
|
140
|
-
|
141
|
-
if ((0, _types.isDefined)(status)) {
|
142
|
-
test.status = status;
|
143
|
-
|
144
|
-
if ((0, _types.isDefined)(storyId) && (0, _types.isDefined)(prevStories[storyId])) {
|
145
|
-
var story = prevStories[storyId];
|
146
|
-
|
147
|
-
var storyStatus = _this.getStoryTests(storyId);
|
148
|
-
|
149
|
-
var oldStatus = storyStatus.map(function (x) {
|
150
|
-
return x.id === id ? status : x.status;
|
151
|
-
}).reduce(function (oldStatus, newStatus) {
|
152
|
-
return (0, _helpers.calcStatus)(oldStatus, newStatus);
|
153
|
-
}, undefined);
|
154
|
-
story.name = _this.addStatusToStoryName(story.name, (0, _helpers.calcStatus)(oldStatus, status), skip || false);
|
155
|
-
}
|
156
|
-
}
|
157
|
-
|
158
|
-
if ((0, _types.isDefined)(results)) test.results ? (_test$results = test.results).push.apply(_test$results, _toConsumableArray(results)) : test.results = results;
|
159
|
-
|
160
|
-
if ((0, _types.isDefined)(approved)) {
|
161
|
-
Object.entries(approved).forEach(function (_ref2) {
|
162
|
-
var _ref3 = _slicedToArray(_ref2, 2),
|
163
|
-
image = _ref3[0],
|
164
|
-
retry = _ref3[1];
|
165
|
-
|
166
|
-
return retry !== undefined && test && ((test.approved = (test === null || test === void 0 ? void 0 : test.approved) || {})[image] = retry);
|
167
|
-
});
|
71
|
+
if ((0, _types.isDefined)(skip)) test.skip = skip;
|
72
|
+
if ((0, _types.isDefined)(status)) {
|
73
|
+
test.status = status;
|
74
|
+
if ((0, _types.isDefined)(storyId) && (0, _types.isDefined)(prevStories[storyId])) {
|
75
|
+
const story = prevStories[storyId];
|
76
|
+
const storyStatus = this.getStoryTests(storyId);
|
77
|
+
const oldStatus = storyStatus.map(x => x.id === id ? status : x.status).reduce((oldStatus, newStatus) => (0, _helpers.calcStatus)(oldStatus, newStatus), undefined);
|
78
|
+
story.name = this.addStatusToStoryName(story.name, (0, _helpers.calcStatus)(oldStatus, status), skip || false);
|
168
79
|
}
|
169
|
-
}
|
170
|
-
|
171
|
-
|
172
|
-
|
173
|
-
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
_this.setPanelsTitle();
|
178
|
-
|
179
|
-
void _this.storybookApi.setStories(_this.stories);
|
180
|
-
}
|
181
|
-
|
182
|
-
_this.updateStatusListeners.forEach(function (x) {
|
183
|
-
return x(update);
|
184
|
-
});
|
185
|
-
});
|
186
|
-
|
187
|
-
_defineProperty(this, "getCurrentTest", function () {
|
188
|
-
return _this.status.tests[_this.selectedTestId];
|
189
|
-
});
|
190
|
-
|
191
|
-
_defineProperty(this, "onStoryRendered", function (storyId) {
|
192
|
-
if (_this.storyId === '') void _this.addStatusesToSideBar();
|
193
|
-
|
194
|
-
if (_this.storyId !== storyId) {
|
195
|
-
var _this$getTestsByStory, _this$getTestsByStory2;
|
196
|
-
|
197
|
-
_this.storyId = storyId;
|
198
|
-
_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 : '';
|
199
|
-
|
200
|
-
_this.setPanelsTitle();
|
201
|
-
|
202
|
-
_this.changeTestListeners.forEach(function (x) {
|
203
|
-
return x(_this.selectedTestId);
|
204
|
-
});
|
205
|
-
}
|
206
|
-
});
|
207
|
-
|
208
|
-
_defineProperty(this, "onStart", function () {
|
209
|
-
var _this$creeveyApi;
|
210
|
-
|
211
|
-
(_this$creeveyApi = _this.creeveyApi) === null || _this$creeveyApi === void 0 ? void 0 : _this$creeveyApi.start([_this.selectedTestId]);
|
212
|
-
});
|
213
|
-
|
214
|
-
_defineProperty(this, "onStop", function () {
|
215
|
-
var _this$creeveyApi2;
|
216
|
-
|
217
|
-
(_this$creeveyApi2 = _this.creeveyApi) === null || _this$creeveyApi2 === void 0 ? void 0 : _this$creeveyApi2.stop();
|
218
|
-
});
|
219
|
-
|
220
|
-
_defineProperty(this, "onImageApprove", function (id, retry, image) {
|
221
|
-
var _this$creeveyApi3;
|
222
|
-
|
223
|
-
return (_this$creeveyApi3 = _this.creeveyApi) === null || _this$creeveyApi3 === void 0 ? void 0 : _this$creeveyApi3.approve(id, retry, image);
|
224
|
-
});
|
225
|
-
|
226
|
-
_defineProperty(this, "onStartAllStoryTests", function () {
|
227
|
-
var _this$creeveyApi4;
|
228
|
-
|
229
|
-
var ids = Object.values(_this.status.tests).filter(_types.isDefined).filter(function (x) {
|
230
|
-
return x.storyId === _this.storyId;
|
231
|
-
}).map(function (x) {
|
232
|
-
return x.id;
|
233
|
-
});
|
234
|
-
(_this$creeveyApi4 = _this.creeveyApi) === null || _this$creeveyApi4 === void 0 ? void 0 : _this$creeveyApi4.start(ids);
|
235
|
-
});
|
236
|
-
|
237
|
-
_defineProperty(this, "onStartAllTests", function () {
|
238
|
-
var _this$creeveyApi5;
|
239
|
-
|
240
|
-
var ids = Object.values(_this.status.tests).filter(_types.isDefined).map(function (x) {
|
241
|
-
return x.id;
|
242
|
-
});
|
243
|
-
(_this$creeveyApi5 = _this.creeveyApi) === null || _this$creeveyApi5 === void 0 ? void 0 : _this$creeveyApi5.start(ids);
|
244
|
-
});
|
245
|
-
|
246
|
-
_defineProperty(this, "onSetStories", function (data) {
|
247
|
-
var stories = data.v ? (0, _shared.denormalizeStoryParameters)(data) : data.stories;
|
248
|
-
_this.stories = stories;
|
249
|
-
});
|
250
|
-
|
251
|
-
_defineProperty(this, "setActiveBrowser", function (browser) {
|
252
|
-
var _this$getTestsByStory3, _this$getTestsByStory4;
|
253
|
-
|
254
|
-
_this.activeBrowser = browser;
|
255
|
-
_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 : '';
|
256
|
-
|
257
|
-
_this.changeTestListeners.forEach(function (x) {
|
258
|
-
return x(_this.selectedTestId);
|
80
|
+
}
|
81
|
+
if ((0, _types.isDefined)(results)) test.results ? test.results.push(...results) : test.results = results;
|
82
|
+
if ((0, _types.isDefined)(approved)) {
|
83
|
+
Object.entries(approved).forEach(_ref => {
|
84
|
+
let [image, retry] = _ref;
|
85
|
+
return retry !== undefined && test && ((test.approved = test?.approved || {})[image] = retry);
|
86
|
+
});
|
87
|
+
}
|
259
88
|
});
|
260
|
-
|
261
|
-
|
262
|
-
|
263
|
-
|
264
|
-
|
265
|
-
_this.changeTestListeners.forEach(function (x) {
|
266
|
-
return x(_this.selectedTestId);
|
89
|
+
removedTests.forEach(_ref2 => {
|
90
|
+
let {
|
91
|
+
id
|
92
|
+
} = _ref2;
|
93
|
+
return delete prevTests[id];
|
267
94
|
});
|
268
|
-
|
269
|
-
|
270
|
-
|
271
|
-
|
272
|
-
|
273
|
-
return (result === null || result === void 0 ? void 0 : result.storyId) === storyId;
|
274
|
-
}).filter(_types.isDefined);
|
275
|
-
});
|
276
|
-
|
277
|
-
_defineProperty(this, "getBrowsers", function () {
|
278
|
-
return _this.status.browsers;
|
279
|
-
});
|
280
|
-
|
281
|
-
_defineProperty(this, "getTestsByStoryIdAndBrowser", function (browser) {
|
282
|
-
return Object.values(_this.status.tests).filter(function (x) {
|
283
|
-
return (x === null || x === void 0 ? void 0 : x.browser) === browser && x.storyId === _this.storyId;
|
284
|
-
}).filter(_types.isDefined);
|
285
|
-
});
|
286
|
-
|
287
|
-
_defineProperty(this, "getTabTitle", function (browser) {
|
288
|
-
var tests = _this.getTestsByStoryIdAndBrowser(browser);
|
289
|
-
|
290
|
-
var browserStatus = tests.map(function (x) {
|
291
|
-
return x && x.status;
|
292
|
-
}).reduce(function (oldStatus, newStatus) {
|
293
|
-
return (0, _helpers.calcStatus)(oldStatus, newStatus);
|
294
|
-
}, undefined);
|
295
|
-
var browserSkip = tests.length > 0 ? tests.every(function (x) {
|
296
|
-
return x && x.skip;
|
297
|
-
}) : false;
|
298
|
-
var emojiStatus = (0, _utils.getEmojiByTestStatus)(browserStatus, browserSkip);
|
299
|
-
return "".concat(emojiStatus ? "".concat(emojiStatus, " ") : '', "Creevey/").concat(browser);
|
300
|
-
});
|
301
|
-
|
302
|
-
_defineProperty(this, "setPanelsTitle", function () {
|
303
|
-
var _this$storybookApi;
|
304
|
-
|
305
|
-
var panels = (_this$storybookApi = _this.storybookApi) === null || _this$storybookApi === void 0 ? void 0 : _this$storybookApi.getPanels();
|
306
|
-
if (!panels) return;
|
307
|
-
var firstPanelBrowser = _this.activeBrowser;
|
308
|
-
|
309
|
-
for (var p in panels) {
|
310
|
-
var _panel$id;
|
311
|
-
|
312
|
-
var panel = panels[p];
|
313
|
-
|
314
|
-
if (((_panel$id = panel.id) === null || _panel$id === void 0 ? void 0 : _panel$id.indexOf(_register.ADDON_ID)) === 0 && panel.paramKey) {
|
315
|
-
panel.title = _this.getTabTitle(panel.paramKey);
|
316
|
-
if (!firstPanelBrowser) firstPanelBrowser = panel.paramKey;
|
317
|
-
}
|
318
|
-
}
|
319
|
-
|
320
|
-
_this.storybookApi.setSelectedPanel("".concat(_register.ADDON_ID, "/panel/").concat(firstPanelBrowser));
|
321
|
-
});
|
322
|
-
|
323
|
-
this.storybookApi = storybookApi;
|
324
|
-
}
|
325
|
-
|
326
|
-
_createClass(CreeveyManager, [{
|
327
|
-
key: "onUpdateStatus",
|
328
|
-
value: function onUpdateStatus(listener) {
|
329
|
-
var _this2 = this;
|
330
|
-
|
331
|
-
this.updateStatusListeners.push(listener);
|
332
|
-
return function () {
|
333
|
-
return void (_this2.updateStatusListeners = _this2.updateStatusListeners.filter(function (x) {
|
334
|
-
return x != listener;
|
335
|
-
}));
|
336
|
-
};
|
95
|
+
this.status.tests = prevTests;
|
96
|
+
this.stories = prevStories;
|
97
|
+
this.setPanelsTitle();
|
98
|
+
// TODO Check setStories method in 6.x and migrate properly
|
99
|
+
this.storybookApi.emit(_coreEvents.SET_STORIES, this.stories);
|
337
100
|
}
|
338
|
-
|
339
|
-
|
340
|
-
|
341
|
-
|
342
|
-
|
343
|
-
|
344
|
-
|
345
|
-
|
346
|
-
|
347
|
-
|
348
|
-
|
101
|
+
this.updateStatusListeners.forEach(x => x(update));
|
102
|
+
};
|
103
|
+
getCurrentTest = () => {
|
104
|
+
return this.status.tests[this.selectedTestId];
|
105
|
+
};
|
106
|
+
onStoryRendered = storyId => {
|
107
|
+
if (this.storyId === '') this.addStatusesToSideBar();
|
108
|
+
if (this.storyId !== storyId) {
|
109
|
+
this.storyId = storyId;
|
110
|
+
this.selectedTestId = this.getTestsByStoryIdAndBrowser(this.activeBrowser)[0]?.id ?? '';
|
111
|
+
this.setPanelsTitle();
|
112
|
+
this.changeTestListeners.forEach(x => x(this.selectedTestId));
|
349
113
|
}
|
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
|
-
|
382
|
-
|
383
|
-
|
384
|
-
|
385
|
-
|
386
|
-
|
387
|
-
|
388
|
-
|
389
|
-
|
390
|
-
|
391
|
-
|
392
|
-
|
393
|
-
|
394
|
-
|
395
|
-
|
114
|
+
};
|
115
|
+
onStart = () => {
|
116
|
+
this.creeveyApi?.start([this.selectedTestId]);
|
117
|
+
};
|
118
|
+
onStop = () => {
|
119
|
+
this.creeveyApi?.stop();
|
120
|
+
};
|
121
|
+
onImageApprove = (id, retry, image) => this.creeveyApi?.approve(id, retry, image);
|
122
|
+
onStartAllStoryTests = () => {
|
123
|
+
const ids = Object.values(this.status.tests).filter(_types.isDefined).filter(x => x.storyId === this.storyId).map(x => x.id);
|
124
|
+
this.creeveyApi?.start(ids);
|
125
|
+
};
|
126
|
+
onStartAllTests = () => {
|
127
|
+
const ids = Object.values(this.status.tests).filter(_types.isDefined).map(x => x.id);
|
128
|
+
this.creeveyApi?.start(ids);
|
129
|
+
};
|
130
|
+
onSetStories = data => {
|
131
|
+
const stories = data.v ? (0, _shared.denormalizeStoryParameters)(data) : data.stories;
|
132
|
+
this.stories = stories;
|
133
|
+
};
|
134
|
+
setActiveBrowser = browser => {
|
135
|
+
this.activeBrowser = browser;
|
136
|
+
this.selectedTestId = this.getTestsByStoryIdAndBrowser(this.activeBrowser)[0]?.id ?? '';
|
137
|
+
this.changeTestListeners.forEach(x => x(this.selectedTestId));
|
138
|
+
};
|
139
|
+
setSelectedTestId = testId => {
|
140
|
+
this.selectedTestId = testId;
|
141
|
+
this.changeTestListeners.forEach(x => x(this.selectedTestId));
|
142
|
+
};
|
143
|
+
getStoryTests = storyId => {
|
144
|
+
if (!this.status || !this.status.tests) return [];
|
145
|
+
return Object.values(this.status.tests).filter(result => result?.storyId === storyId).filter(_types.isDefined);
|
146
|
+
};
|
147
|
+
getBrowsers = () => {
|
148
|
+
return this.status.browsers;
|
149
|
+
};
|
150
|
+
getTestsByStoryIdAndBrowser = browser => {
|
151
|
+
return Object.values(this.status.tests).filter(x => x?.browser === browser && x.storyId === this.storyId).filter(_types.isDefined);
|
152
|
+
};
|
153
|
+
getTabTitle = browser => {
|
154
|
+
const tests = this.getTestsByStoryIdAndBrowser(browser);
|
155
|
+
const browserStatus = tests.map(x => x && x.status).reduce((oldStatus, newStatus) => (0, _helpers.calcStatus)(oldStatus, newStatus), undefined);
|
156
|
+
const browserSkip = tests.length > 0 ? tests.every(x => x && x.skip) : false;
|
157
|
+
const emojiStatus = (0, _utils.getEmojiByTestStatus)(browserStatus, browserSkip);
|
158
|
+
return `${emojiStatus ? `${emojiStatus} ` : ''}Creevey/${browser}`;
|
159
|
+
};
|
160
|
+
setPanelsTitle = () => {
|
161
|
+
const panels = this.storybookApi?.getPanels();
|
162
|
+
if (!panels) return;
|
163
|
+
let firstPanelBrowser = this.activeBrowser;
|
164
|
+
for (const p in panels) {
|
165
|
+
const panel = panels[p];
|
166
|
+
if (panel.id?.indexOf(_register.ADDON_ID) === 0 && panel.paramKey) {
|
167
|
+
panel.title = this.getTabTitle(panel.paramKey);
|
168
|
+
if (!firstPanelBrowser) firstPanelBrowser = panel.paramKey;
|
396
169
|
}
|
397
|
-
|
398
|
-
return addStatusesToSideBar;
|
399
|
-
}()
|
400
|
-
}, {
|
401
|
-
key: "addStatusToStoryName",
|
402
|
-
value: function addStatusToStoryName(name, status, skip) {
|
403
|
-
name = name.replace(/^(❌|✔|🟡|🕗|⏸) /, '');
|
404
|
-
var emojiStatus = (0, _utils.getEmojiByTestStatus)(status, skip);
|
405
|
-
return "".concat(emojiStatus ? "".concat(emojiStatus, " ") : '', " ").concat(name);
|
406
170
|
}
|
407
|
-
|
408
|
-
|
409
|
-
|
410
|
-
|
411
|
-
|
171
|
+
this.storybookApi.setSelectedPanel(`${_register.ADDON_ID}/panel/${firstPanelBrowser}`);
|
172
|
+
};
|
173
|
+
addStatusesToSideBar() {
|
174
|
+
if (!Object.keys(this.stories).length) return;
|
175
|
+
const stories = this.stories;
|
176
|
+
Object.keys(this.stories).forEach(storyId => {
|
177
|
+
const storyStatus = this.getStoryTests(storyId);
|
178
|
+
const status = storyStatus.map(x => x.status).reduce((oldStatus, newStatus) => (0, _helpers.calcStatus)(oldStatus, newStatus), undefined);
|
179
|
+
const skip = storyStatus.length > 0 ? storyStatus.every(x => x.skip) : false;
|
180
|
+
this.stories[storyId].name = this.addStatusToStoryName(stories[storyId].name, status, skip);
|
181
|
+
});
|
182
|
+
|
183
|
+
// TODO Check setStories method in 6.x and migrate properly
|
184
|
+
this.storybookApi.emit(_coreEvents.SET_STORIES, this.stories);
|
185
|
+
}
|
186
|
+
addStatusToStoryName(name, status, skip) {
|
187
|
+
name = name.replace(/^(❌|✔|🟡|🕗|⏸) /, '');
|
188
|
+
const emojiStatus = (0, _utils.getEmojiByTestStatus)(status, skip);
|
189
|
+
return `${emojiStatus ? `${emojiStatus} ` : ''} ${name}`;
|
190
|
+
}
|
191
|
+
}
|
412
192
|
exports.CreeveyManager = CreeveyManager;
|