creevey 0.9.0-beta.13 → 0.9.0-beta.14

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.
Files changed (216) hide show
  1. package/.yarn/install-state.gz +0 -0
  2. package/.yarnrc.yml +1 -0
  3. package/lib/cjs/cli.js +1 -0
  4. package/lib/cjs/client/addon/Manager.js +151 -223
  5. package/lib/cjs/client/addon/components/Addon.js +2 -9
  6. package/lib/cjs/client/addon/components/Icons.js +1 -7
  7. package/lib/cjs/client/addon/components/Panel.js +5 -18
  8. package/lib/cjs/client/addon/components/TestSelect.js +12 -25
  9. package/lib/cjs/client/addon/components/Tools.js +17 -28
  10. package/lib/cjs/client/addon/decorator.js +1 -4
  11. package/lib/cjs/client/addon/index.js +0 -4
  12. package/lib/cjs/client/addon/preset.js +3 -12
  13. package/lib/cjs/client/addon/preview.js +1 -4
  14. package/lib/cjs/client/addon/readyForCapture.js +1 -4
  15. package/lib/cjs/client/addon/register.js +11 -26
  16. package/lib/cjs/client/addon/utils.js +1 -9
  17. package/lib/cjs/client/addon/withCreevey.js +55 -134
  18. package/lib/cjs/client/shared/components/ImagesView/BlendView.js +5 -17
  19. package/lib/cjs/client/shared/components/ImagesView/ImagesView.js +8 -24
  20. package/lib/cjs/client/shared/components/ImagesView/SideBySideView.js +7 -23
  21. package/lib/cjs/client/shared/components/ImagesView/SlideView.js +7 -22
  22. package/lib/cjs/client/shared/components/ImagesView/SwapView.js +5 -17
  23. package/lib/cjs/client/shared/components/ImagesView/index.js +0 -5
  24. package/lib/cjs/client/shared/components/PageFooter/PageFooter.js +1 -8
  25. package/lib/cjs/client/shared/components/PageFooter/Paging.js +2 -19
  26. package/lib/cjs/client/shared/components/PageHeader/ImagePreview.js +21 -17
  27. package/lib/cjs/client/shared/components/PageHeader/PageHeader.js +5 -24
  28. package/lib/cjs/client/shared/components/ResultsPage.js +9 -37
  29. package/lib/cjs/client/shared/creeveyClientApi.js +3 -13
  30. package/lib/cjs/client/shared/helpers.js +21 -75
  31. package/lib/cjs/client/shared/viewMode.js +2 -6
  32. package/lib/cjs/client/web/192.js +1 -0
  33. package/lib/cjs/client/web/632.js +43 -0
  34. package/lib/cjs/client/web/794.js +1 -0
  35. package/lib/cjs/client/web/main.js +78 -1
  36. package/lib/cjs/client/web/main.js.LICENSE.txt +0 -15
  37. package/lib/cjs/creevey.js +5 -21
  38. package/lib/cjs/index.js +0 -15
  39. package/lib/cjs/server/config.js +13 -33
  40. package/lib/cjs/server/docker.js +5 -27
  41. package/lib/cjs/server/index.js +8 -33
  42. package/lib/cjs/server/logger.js +5 -19
  43. package/lib/cjs/server/master/api.js +1 -14
  44. package/lib/cjs/server/master/index.js +15 -46
  45. package/lib/cjs/server/master/master.js +6 -21
  46. package/lib/cjs/server/master/pool.js +2 -37
  47. package/lib/cjs/server/master/runner.js +15 -42
  48. package/lib/cjs/server/master/server.js +5 -27
  49. package/lib/cjs/server/messages.js +7 -53
  50. package/lib/cjs/server/selenium/browser.js +51 -136
  51. package/lib/cjs/server/selenium/index.js +0 -4
  52. package/lib/cjs/server/selenium/selenoid.js +7 -33
  53. package/lib/cjs/server/stories.js +25 -30
  54. package/lib/cjs/server/storybook/providers/browser.js +5 -18
  55. package/lib/cjs/server/storybook/providers/hybrid.js +9 -29
  56. package/lib/cjs/server/testsFiles/parser.js +3 -19
  57. package/lib/cjs/server/testsFiles/register.js +7 -9
  58. package/lib/cjs/server/update.js +3 -20
  59. package/lib/cjs/server/utils.js +9 -41
  60. package/lib/cjs/server/worker/chai-image.js +1 -27
  61. package/lib/cjs/server/worker/helpers.js +2 -12
  62. package/lib/cjs/server/worker/index.js +1 -3
  63. package/lib/cjs/server/worker/reporter.js +8 -24
  64. package/lib/cjs/server/worker/worker.js +5 -49
  65. package/lib/cjs/shared/index.js +22 -36
  66. package/lib/cjs/shared/serializeRegExp.js +0 -8
  67. package/lib/cjs/types.js +4 -14
  68. package/lib/esm/cli.js +1 -1
  69. package/lib/esm/client/addon/Manager.js +151 -214
  70. package/lib/esm/client/addon/components/Panel.js +4 -6
  71. package/lib/esm/client/addon/components/TestSelect.js +11 -17
  72. package/lib/esm/client/addon/components/Tools.js +15 -14
  73. package/lib/esm/client/addon/preset.js +2 -8
  74. package/lib/esm/client/addon/readyForCapture.js +1 -3
  75. package/lib/esm/client/addon/register.js +6 -8
  76. package/lib/esm/client/addon/utils.js +0 -5
  77. package/lib/esm/client/addon/withCreevey.js +54 -116
  78. package/lib/esm/client/shared/components/ImagesView/BlendView.js +1 -1
  79. package/lib/esm/client/shared/components/ImagesView/ImagesView.js +6 -8
  80. package/lib/esm/client/shared/components/ImagesView/SideBySideView.js +3 -4
  81. package/lib/esm/client/shared/components/ImagesView/SlideView.js +3 -3
  82. package/lib/esm/client/shared/components/ImagesView/SwapView.js +1 -1
  83. package/lib/esm/client/shared/components/PageFooter/Paging.js +1 -11
  84. package/lib/esm/client/shared/components/PageHeader/ImagePreview.js +18 -7
  85. package/lib/esm/client/shared/components/PageHeader/PageHeader.js +3 -8
  86. package/lib/esm/client/shared/components/ResultsPage.js +6 -15
  87. package/lib/esm/client/shared/creeveyClientApi.js +3 -10
  88. package/lib/esm/client/shared/helpers.js +21 -47
  89. package/lib/esm/client/web/192.js +1 -0
  90. package/lib/esm/client/web/632.js +43 -0
  91. package/lib/esm/client/web/794.js +1 -0
  92. package/lib/esm/client/web/index.html +19 -0
  93. package/lib/esm/client/web/main.js +79 -0
  94. package/lib/esm/client/web/main.js.LICENSE.txt +34 -0
  95. package/lib/esm/creevey.js +4 -8
  96. package/lib/esm/index.js +0 -1
  97. package/lib/esm/server/config.js +7 -14
  98. package/lib/esm/server/docker.js +4 -12
  99. package/lib/esm/server/index.js +7 -21
  100. package/lib/esm/server/logger.js +0 -1
  101. package/lib/esm/server/master/api.js +0 -9
  102. package/lib/esm/server/master/index.js +15 -32
  103. package/lib/esm/server/master/master.js +2 -7
  104. package/lib/esm/server/master/pool.js +0 -23
  105. package/lib/esm/server/master/runner.js +14 -27
  106. package/lib/esm/server/master/server.js +4 -9
  107. package/lib/esm/server/messages.js +6 -38
  108. package/lib/esm/server/selenium/browser.js +50 -114
  109. package/lib/esm/server/selenium/selenoid.js +6 -17
  110. package/lib/esm/server/stories.js +24 -20
  111. package/lib/esm/server/storybook/providers/browser.js +4 -8
  112. package/lib/esm/server/storybook/providers/hybrid.js +6 -14
  113. package/lib/esm/server/testsFiles/parser.js +0 -6
  114. package/lib/esm/server/testsFiles/register.js +5 -2
  115. package/lib/esm/server/update.js +0 -8
  116. package/lib/esm/server/utils.js +3 -11
  117. package/lib/esm/server/worker/chai-image.js +0 -21
  118. package/lib/esm/server/worker/helpers.js +2 -9
  119. package/lib/esm/server/worker/reporter.js +7 -10
  120. package/lib/esm/server/worker/worker.js +4 -25
  121. package/lib/esm/shared/index.js +24 -25
  122. package/lib/esm/types.js +4 -1
  123. package/lib/types/client/addon/Manager.d.ts +1 -1
  124. package/lib/types/client/addon/components/Addon.d.ts +1 -0
  125. package/lib/types/client/addon/components/Icons.d.ts +1 -0
  126. package/lib/types/client/addon/components/Panel.d.ts +1 -0
  127. package/lib/types/client/addon/components/TestSelect.d.ts +1 -0
  128. package/lib/types/client/addon/components/Tools.d.ts +1 -0
  129. package/lib/types/client/addon/decorator.d.ts +1 -1
  130. package/lib/types/client/addon/preset.d.ts +2 -2
  131. package/lib/types/client/addon/preview.d.ts +1 -1
  132. package/lib/types/client/addon/withCreevey.d.ts +3 -2
  133. package/lib/types/client/shared/components/ImagesView/BlendView.d.ts +3 -1
  134. package/lib/types/client/shared/components/ImagesView/ImagesView.d.ts +1 -0
  135. package/lib/types/client/shared/components/ImagesView/SideBySideView.d.ts +3 -1
  136. package/lib/types/client/shared/components/ImagesView/SlideView.d.ts +3 -1
  137. package/lib/types/client/shared/components/ImagesView/SwapView.d.ts +3 -1
  138. package/lib/types/client/shared/components/PageFooter/PageFooter.d.ts +1 -0
  139. package/lib/types/client/shared/components/PageFooter/Paging.d.ts +1 -0
  140. package/lib/types/client/shared/components/PageHeader/ImagePreview.d.ts +3 -1
  141. package/lib/types/client/shared/components/PageHeader/PageHeader.d.ts +1 -0
  142. package/lib/types/client/shared/components/ResultsPage.d.ts +3 -1
  143. package/lib/types/client/web/CreeveyApp.d.ts +1 -0
  144. package/lib/types/client/web/CreeveyLoader.d.ts +2 -1
  145. package/lib/types/client/web/CreeveyView/SideBar/Checkbox.d.ts +4 -1
  146. package/lib/types/client/web/CreeveyView/SideBar/Search.d.ts +1 -0
  147. package/lib/types/client/web/CreeveyView/SideBar/SideBarHeader.d.ts +1 -0
  148. package/lib/types/client/web/CreeveyView/SideBar/SuiteLink.d.ts +19 -14
  149. package/lib/types/client/web/CreeveyView/SideBar/TestLink.d.ts +1 -0
  150. package/lib/types/client/web/CreeveyView/SideBar/TestStatusIcon.d.ts +3 -1
  151. package/lib/types/client/web/CreeveyView/SideBar/TestsStatus.d.ts +3 -1
  152. package/lib/types/client/web/CreeveyView/SideBar/Toggle.d.ts +1 -0
  153. package/lib/types/shared/index.d.ts +1 -1
  154. package/lib/types/types.d.ts +7 -28
  155. package/package.json +60 -78
  156. package/lib/cjs/client/addon/preset.ie11.js +0 -74
  157. package/lib/cjs/client/addon/preset.sb7.js +0 -19
  158. package/lib/cjs/client/web/142.js +0 -2
  159. package/lib/cjs/client/web/142.js.LICENSE.txt +0 -12
  160. package/lib/cjs/client/web/32.js +0 -1
  161. package/lib/cjs/client/web/551.js +0 -1
  162. package/lib/cjs/client/web/566.js +0 -2
  163. package/lib/cjs/client/web/566.js.LICENSE.txt +0 -31
  164. package/lib/cjs/client/web/691.js +0 -2
  165. package/lib/cjs/client/web/691.js.LICENSE.txt +0 -8
  166. package/lib/cjs/client/web/725.js +0 -1
  167. package/lib/cjs/server/extract.js +0 -46
  168. package/lib/cjs/server/loaders/babel/creevey-plugin.js +0 -86
  169. package/lib/cjs/server/loaders/babel/helpers.js +0 -469
  170. package/lib/cjs/server/loaders/babel/register.js +0 -124
  171. package/lib/cjs/server/loaders/hooks/mdx.js +0 -30
  172. package/lib/cjs/server/loaders/hooks/svelte.js +0 -65
  173. package/lib/cjs/server/loaders/webpack/compile.js +0 -269
  174. package/lib/cjs/server/loaders/webpack/creevey-loader.js +0 -172
  175. package/lib/cjs/server/loaders/webpack/dummy-hmr.js +0 -39
  176. package/lib/cjs/server/loaders/webpack/mdx-loader.js +0 -72
  177. package/lib/cjs/server/loaders/webpack/start.js +0 -41
  178. package/lib/cjs/server/storybook/entry.js +0 -53
  179. package/lib/cjs/server/storybook/helpers.js +0 -158
  180. package/lib/cjs/server/storybook/providers/nodejs.js +0 -239
  181. package/lib/esm/client/addon/preset.ie11.js +0 -59
  182. package/lib/esm/client/addon/preset.sb7.js +0 -8
  183. package/lib/esm/server/extract.js +0 -32
  184. package/lib/esm/server/loaders/babel/creevey-plugin.js +0 -72
  185. package/lib/esm/server/loaders/babel/helpers.js +0 -452
  186. package/lib/esm/server/loaders/babel/register.js +0 -103
  187. package/lib/esm/server/loaders/hooks/mdx.js +0 -15
  188. package/lib/esm/server/loaders/hooks/svelte.js +0 -49
  189. package/lib/esm/server/loaders/webpack/compile.js +0 -246
  190. package/lib/esm/server/loaders/webpack/creevey-loader.js +0 -152
  191. package/lib/esm/server/loaders/webpack/dummy-hmr.js +0 -32
  192. package/lib/esm/server/loaders/webpack/mdx-loader.js +0 -58
  193. package/lib/esm/server/loaders/webpack/start.js +0 -27
  194. package/lib/esm/server/storybook/entry.js +0 -27
  195. package/lib/esm/server/storybook/helpers.js +0 -97
  196. package/lib/esm/server/storybook/providers/nodejs.js +0 -216
  197. package/lib/types/client/addon/preset.ie11.d.ts +0 -10
  198. package/lib/types/client/addon/preset.sb7.d.ts +0 -2
  199. package/lib/types/server/extract.d.ts +0 -2
  200. package/lib/types/server/loaders/babel/creevey-plugin.d.ts +0 -1
  201. package/lib/types/server/loaders/babel/helpers.d.ts +0 -19
  202. package/lib/types/server/loaders/babel/register.d.ts +0 -5
  203. package/lib/types/server/loaders/hooks/mdx.d.ts +0 -1
  204. package/lib/types/server/loaders/hooks/svelte.d.ts +0 -1
  205. package/lib/types/server/loaders/webpack/compile.d.ts +0 -2
  206. package/lib/types/server/loaders/webpack/creevey-loader.d.ts +0 -4
  207. package/lib/types/server/loaders/webpack/dummy-hmr.d.ts +0 -10
  208. package/lib/types/server/loaders/webpack/mdx-loader.d.ts +0 -6
  209. package/lib/types/server/loaders/webpack/start.d.ts +0 -1
  210. package/lib/types/server/storybook/entry.d.ts +0 -17
  211. package/lib/types/server/storybook/helpers.d.ts +0 -24
  212. package/lib/types/server/storybook/providers/nodejs.d.ts +0 -9
  213. package/preset/ie11.js +0 -5
  214. package/preset/index.js +0 -9
  215. package/preset/sb7.js +0 -5
  216. package/types/mdx.d.ts +0 -7
Binary file
package/.yarnrc.yml ADDED
@@ -0,0 +1 @@
1
+ nodeLinker: node-modules
package/lib/cjs/cli.js CHANGED
@@ -1,4 +1,5 @@
1
1
  #!/usr/bin/env node
2
+
2
3
  // eslint-disable-next-line node/shebang
3
4
  "use strict";
4
5
 
@@ -4,244 +4,173 @@ 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
- 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; }
23
-
24
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 = [];
25
27
  constructor(storybookApi) {
26
28
  this.storybookApi = storybookApi;
27
-
28
- _defineProperty(this, "storyId", '');
29
-
30
- _defineProperty(this, "activeBrowser", '');
31
-
32
- _defineProperty(this, "selectedTestId", '');
33
-
34
- _defineProperty(this, "status", {
35
- isRunning: false,
36
- tests: {},
37
- browsers: []
38
- });
39
-
40
- _defineProperty(this, "creeveyApi", null);
41
-
42
- _defineProperty(this, "stories", {});
43
-
44
- _defineProperty(this, "updateStatusListeners", []);
45
-
46
- _defineProperty(this, "changeTestListeners", []);
47
-
48
- _defineProperty(this, "initAll", async () => {
49
- this.storybookApi.on(_coreEvents.STORY_RENDERED, this.onStoryRendered);
50
- this.storybookApi.on(_coreEvents.SET_STORIES, this.onSetStories);
51
- this.creeveyApi = await (0, _creeveyClientApi.initCreeveyClientApi)();
52
- this.creeveyApi.onUpdate(this.handleCreeveyUpdate);
53
- this.status = await this.creeveyApi.status;
54
- });
55
-
56
- _defineProperty(this, "handleCreeveyUpdate", update => {
57
- const {
58
- tests,
59
- removedTests = [],
60
- isRunning
61
- } = update;
62
-
63
- if ((0, _types.isDefined)(isRunning)) {
64
- this.status.isRunning = isRunning;
65
- }
66
-
67
- if ((0, _types.isDefined)(tests)) {
68
- const prevTests = this.status.tests;
69
- const prevStories = this.stories || {};
70
- Object.values(tests).filter(_types.isDefined).forEach(update => {
71
- const {
72
- id,
73
- skip,
74
- status,
75
- results,
76
- approved,
77
- storyId
78
- } = update;
79
- const test = prevTests[id];
80
-
81
- if (!test) {
82
- return prevTests[id] = update;
83
- }
84
-
85
- if ((0, _types.isDefined)(skip)) test.skip = skip;
86
-
87
- if ((0, _types.isDefined)(status)) {
88
- test.status = status;
89
-
90
- if ((0, _types.isDefined)(storyId) && (0, _types.isDefined)(prevStories[storyId])) {
91
- const story = prevStories[storyId];
92
- const storyStatus = this.getStoryTests(storyId);
93
- const oldStatus = storyStatus.map(x => x.id === id ? status : x.status).reduce((oldStatus, newStatus) => (0, _helpers.calcStatus)(oldStatus, newStatus), undefined);
94
- story.name = this.addStatusToStoryName(story.name, (0, _helpers.calcStatus)(oldStatus, status), skip || false);
95
- }
96
- }
97
-
98
- if ((0, _types.isDefined)(results)) test.results ? test.results.push(...results) : test.results = results;
99
-
100
- if ((0, _types.isDefined)(approved)) {
101
- Object.entries(approved).forEach(_ref => {
102
- let [image, retry] = _ref;
103
- return retry !== undefined && test && ((test.approved = (test === null || test === void 0 ? void 0 : test.approved) || {})[image] = retry);
104
- });
105
- }
106
- });
107
- removedTests.forEach(_ref2 => {
108
- let {
109
- id
110
- } = _ref2;
111
- return delete prevTests[id];
112
- });
113
- this.status.tests = prevTests;
114
- this.stories = prevStories;
115
- this.setPanelsTitle();
116
- void this.storybookApi.setStories(this.stories);
117
- }
118
-
119
- this.updateStatusListeners.forEach(x => x(update));
120
- });
121
-
122
- _defineProperty(this, "getCurrentTest", () => {
123
- return this.status.tests[this.selectedTestId];
124
- });
125
-
126
- _defineProperty(this, "onStoryRendered", storyId => {
127
- if (this.storyId === '') void this.addStatusesToSideBar();
128
-
129
- if (this.storyId !== storyId) {
130
- var _this$getTestsByStory, _this$getTestsByStory2;
131
-
132
- this.storyId = storyId;
133
- 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 : '';
134
- this.setPanelsTitle();
135
- this.changeTestListeners.forEach(x => x(this.selectedTestId));
136
- }
137
- });
138
-
139
- _defineProperty(this, "onStart", () => {
140
- var _this$creeveyApi;
141
-
142
- (_this$creeveyApi = this.creeveyApi) === null || _this$creeveyApi === void 0 ? void 0 : _this$creeveyApi.start([this.selectedTestId]);
143
- });
144
-
145
- _defineProperty(this, "onStop", () => {
146
- var _this$creeveyApi2;
147
-
148
- (_this$creeveyApi2 = this.creeveyApi) === null || _this$creeveyApi2 === void 0 ? void 0 : _this$creeveyApi2.stop();
149
- });
150
-
151
- _defineProperty(this, "onImageApprove", (id, retry, image) => {
152
- var _this$creeveyApi3;
153
-
154
- return (_this$creeveyApi3 = this.creeveyApi) === null || _this$creeveyApi3 === void 0 ? void 0 : _this$creeveyApi3.approve(id, retry, image);
155
- });
156
-
157
- _defineProperty(this, "onStartAllStoryTests", () => {
158
- var _this$creeveyApi4;
159
-
160
- const ids = Object.values(this.status.tests).filter(_types.isDefined).filter(x => x.storyId === this.storyId).map(x => x.id);
161
- (_this$creeveyApi4 = this.creeveyApi) === null || _this$creeveyApi4 === void 0 ? void 0 : _this$creeveyApi4.start(ids);
162
- });
163
-
164
- _defineProperty(this, "onStartAllTests", () => {
165
- var _this$creeveyApi5;
166
-
167
- const ids = Object.values(this.status.tests).filter(_types.isDefined).map(x => x.id);
168
- (_this$creeveyApi5 = this.creeveyApi) === null || _this$creeveyApi5 === void 0 ? void 0 : _this$creeveyApi5.start(ids);
169
- });
170
-
171
- _defineProperty(this, "onSetStories", data => {
172
- const stories = data.v ? (0, _shared.denormalizeStoryParameters)(data) : data.stories;
173
- this.stories = stories;
174
- });
175
-
176
- _defineProperty(this, "setActiveBrowser", browser => {
177
- var _this$getTestsByStory3, _this$getTestsByStory4;
178
-
179
- this.activeBrowser = browser;
180
- 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 : '';
181
- this.changeTestListeners.forEach(x => x(this.selectedTestId));
182
- });
183
-
184
- _defineProperty(this, "setSelectedTestId", testId => {
185
- this.selectedTestId = testId;
186
- this.changeTestListeners.forEach(x => x(this.selectedTestId));
187
- });
188
-
189
- _defineProperty(this, "getStoryTests", storyId => {
190
- if (!this.status || !this.status.tests) return [];
191
- return Object.values(this.status.tests).filter(result => (result === null || result === void 0 ? void 0 : result.storyId) === storyId).filter(_types.isDefined);
192
- });
193
-
194
- _defineProperty(this, "getBrowsers", () => {
195
- return this.status.browsers;
196
- });
197
-
198
- _defineProperty(this, "getTestsByStoryIdAndBrowser", browser => {
199
- return Object.values(this.status.tests).filter(x => (x === null || x === void 0 ? void 0 : x.browser) === browser && x.storyId === this.storyId).filter(_types.isDefined);
200
- });
201
-
202
- _defineProperty(this, "getTabTitle", browser => {
203
- const tests = this.getTestsByStoryIdAndBrowser(browser);
204
- const browserStatus = tests.map(x => x && x.status).reduce((oldStatus, newStatus) => (0, _helpers.calcStatus)(oldStatus, newStatus), undefined);
205
- const browserSkip = tests.length > 0 ? tests.every(x => x && x.skip) : false;
206
- const emojiStatus = (0, _utils.getEmojiByTestStatus)(browserStatus, browserSkip);
207
- return "".concat(emojiStatus ? "".concat(emojiStatus, " ") : '', "Creevey/").concat(browser);
208
- });
209
-
210
- _defineProperty(this, "setPanelsTitle", () => {
211
- var _this$storybookApi;
212
-
213
- const panels = (_this$storybookApi = this.storybookApi) === null || _this$storybookApi === void 0 ? void 0 : _this$storybookApi.getPanels();
214
- if (!panels) return;
215
- let firstPanelBrowser = this.activeBrowser;
216
-
217
- for (const p in panels) {
218
- var _panel$id;
219
-
220
- const panel = panels[p];
221
-
222
- if (((_panel$id = panel.id) === null || _panel$id === void 0 ? void 0 : _panel$id.indexOf(_register.ADDON_ID)) === 0 && panel.paramKey) {
223
- panel.title = this.getTabTitle(panel.paramKey);
224
- if (!firstPanelBrowser) firstPanelBrowser = panel.paramKey;
225
- }
226
- }
227
-
228
- this.storybookApi.setSelectedPanel("".concat(_register.ADDON_ID, "/panel/").concat(firstPanelBrowser));
229
- });
230
-
231
29
  this.storybookApi = storybookApi;
232
30
  }
233
-
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
+ };
234
38
  onUpdateStatus(listener) {
235
39
  this.updateStatusListeners.push(listener);
236
40
  return () => void (this.updateStatusListeners = this.updateStatusListeners.filter(x => x != listener));
237
41
  }
238
-
239
42
  onChangeTest(listener) {
240
43
  this.changeTestListeners.push(listener);
241
44
  return () => void (this.changeTestListeners = this.changeTestListeners.filter(x => x != listener));
242
45
  }
243
-
244
- async addStatusesToSideBar() {
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;
70
+ }
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);
79
+ }
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
+ }
88
+ });
89
+ removedTests.forEach(_ref2 => {
90
+ let {
91
+ id
92
+ } = _ref2;
93
+ return delete prevTests[id];
94
+ });
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);
100
+ }
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));
113
+ }
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;
169
+ }
170
+ }
171
+ this.storybookApi.setSelectedPanel(`${_register.ADDON_ID}/panel/${firstPanelBrowser}`);
172
+ };
173
+ addStatusesToSideBar() {
245
174
  if (!Object.keys(this.stories).length) return;
246
175
  const stories = this.stories;
247
176
  Object.keys(this.stories).forEach(storyId => {
@@ -250,15 +179,14 @@ class CreeveyManager {
250
179
  const skip = storyStatus.length > 0 ? storyStatus.every(x => x.skip) : false;
251
180
  this.stories[storyId].name = this.addStatusToStoryName(stories[storyId].name, status, skip);
252
181
  });
253
- await this.storybookApi.setStories(this.stories);
254
- }
255
182
 
183
+ // TODO Check setStories method in 6.x and migrate properly
184
+ this.storybookApi.emit(_coreEvents.SET_STORIES, this.stories);
185
+ }
256
186
  addStatusToStoryName(name, status, skip) {
257
187
  name = name.replace(/^(❌|✔|🟡|🕗|⏸) /, '');
258
188
  const emojiStatus = (0, _utils.getEmojiByTestStatus)(status, skip);
259
- return "".concat(emojiStatus ? "".concat(emojiStatus, " ") : '', " ").concat(name);
189
+ return `${emojiStatus ? `${emojiStatus} ` : ''} ${name}`;
260
190
  }
261
-
262
191
  }
263
-
264
192
  exports.CreeveyManager = CreeveyManager;
@@ -4,17 +4,11 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.Addon = void 0;
7
-
8
7
  var _components = require("@storybook/components");
9
-
10
8
  var _react = _interopRequireWildcard(require("react"));
11
-
12
9
  var _Panel = require("./Panel");
13
-
14
- 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); }
15
-
16
- 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; }
17
-
10
+ function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
11
+ function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
18
12
  const Addon = _ref => {
19
13
  let {
20
14
  active,
@@ -51,5 +45,4 @@ const Addon = _ref => {
51
45
  onImageApprove: manager.onImageApprove
52
46
  }) : /*#__PURE__*/_react.default.createElement(_components.Placeholder, null, "No test results") : null;
53
47
  };
54
-
55
48
  exports.Addon = Addon;
@@ -4,11 +4,8 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.NextIcon = exports.ForwardIcon = void 0;
7
-
8
7
  var _react = _interopRequireDefault(require("react"));
9
-
10
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
11
-
8
+ function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
12
9
  const NextIcon = _ref => {
13
10
  let {
14
11
  width,
@@ -24,9 +21,7 @@ const NextIcon = _ref => {
24
21
  fill: "currentColor"
25
22
  }));
26
23
  };
27
-
28
24
  exports.NextIcon = NextIcon;
29
-
30
25
  const ForwardIcon = _ref2 => {
31
26
  let {
32
27
  width,
@@ -42,5 +37,4 @@ const ForwardIcon = _ref2 => {
42
37
  d: "M460.9,246.8l-209-164.2c-7.8-6.1-19.2-0.6-19.2,9.2v328.4c0,9.8,11.4,15.3,19.2,9.2l209-164.2c5.1-4,6-11.4,2-16.5 C462.4,248,461.7,247.3,460.9,246.8L460.9,246.8z M228.2,246.8L19.2,82.5C11.4,76.4,0,82,0,91.8v328.4c0,9.8,11.4,15.3,19.2,9.2 l209-164.2c3-2.3,4.5-5.8,4.5-9.2C232.7,252.6,231.2,249.1,228.2,246.8z M507.3,64h-37.2c-2.5,0-4.7,2-4.7,4.4v375.3 c0,2.4,2.1,4.4,4.7,4.4h37.2c2.5,0,4.7-2,4.7-4.4V68.4C512,66,509.9,64,507.3,64z"
43
38
  }));
44
39
  };
45
-
46
40
  exports.ForwardIcon = ForwardIcon;
@@ -4,21 +4,13 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.Panel = void 0;
7
-
8
7
  var _react = _interopRequireDefault(require("react"));
9
-
10
8
  var _components = require("@storybook/components");
11
-
12
9
  var _ResultsPage = require("../../shared/components/ResultsPage");
13
-
14
10
  var _theming = require("@storybook/theming");
15
-
16
11
  var _helpers = require("../../shared/helpers");
17
-
18
12
  var _TestSelect = _interopRequireDefault(require("./TestSelect"));
19
-
20
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
21
-
13
+ function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
22
14
  const Wrapper = _theming.styled.div(_ref => {
23
15
  let {
24
16
  isRunning
@@ -28,20 +20,16 @@ const Wrapper = _theming.styled.div(_ref => {
28
20
  height: '100%'
29
21
  };
30
22
  });
31
-
32
23
  const TestSelectContainer = _theming.styled.div(_ref2 => {
33
24
  let {
34
25
  theme
35
26
  } = _ref2;
36
27
  return {
37
28
  padding: '8px',
38
- border: "1px solid ".concat(theme.appBorderColor)
29
+ border: `1px solid ${theme.appBorderColor}`
39
30
  };
40
31
  });
41
-
42
32
  const Panel = _ref3 => {
43
- var _result$results, _result$results$lengt, _result$results2;
44
-
45
33
  let {
46
34
  tests,
47
35
  selectedTestId,
@@ -49,16 +37,16 @@ const Panel = _ref3 => {
49
37
  onImageApprove
50
38
  } = _ref3;
51
39
  const result = tests.find(x => x.id === selectedTestId);
52
- const isRunning = (result === null || result === void 0 ? void 0 : result.status) === 'running';
40
+ const isRunning = result?.status === 'running';
53
41
  return /*#__PURE__*/_react.default.createElement("div", null, tests.length > 1 && /*#__PURE__*/_react.default.createElement(TestSelectContainer, null, /*#__PURE__*/_react.default.createElement(_TestSelect.default, {
54
42
  tests: tests,
55
43
  selectedTestId: selectedTestId,
56
44
  onChangeTest: onChangeTest
57
- })), isRunning && /*#__PURE__*/_react.default.createElement(_components.Loader, null), result !== null && result !== void 0 && (_result$results = result.results) !== null && _result$results !== void 0 && _result$results.length ? /*#__PURE__*/_react.default.createElement(Wrapper, {
45
+ })), isRunning && /*#__PURE__*/_react.default.createElement(_components.Loader, null), result?.results?.length ? /*#__PURE__*/_react.default.createElement(Wrapper, {
58
46
  isRunning: isRunning
59
47
  }, /*#__PURE__*/_react.default.createElement(_ResultsPage.ResultsPage, {
60
48
  height: '100%',
61
- key: "".concat(result.id, "_").concat((_result$results$lengt = (_result$results2 = result.results) === null || _result$results2 === void 0 ? void 0 : _result$results2.length) !== null && _result$results$lengt !== void 0 ? _result$results$lengt : 0) // TODO
49
+ key: `${result.id}_${result.results?.length ?? 0}` // TODO
62
50
  ,
63
51
  id: result.id,
64
52
  path: (0, _helpers.getTestPath)(result) // TODO Memo?
@@ -68,5 +56,4 @@ const Panel = _ref3 => {
68
56
  onImageApprove: onImageApprove
69
57
  })) : null);
70
58
  };
71
-
72
59
  exports.Panel = Panel;
@@ -4,17 +4,11 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.default = TestSelect;
7
-
8
7
  var _components = require("@storybook/components");
9
-
10
8
  var _theming = require("@storybook/theming");
11
-
12
9
  var _react = _interopRequireDefault(require("react"));
13
-
14
10
  var _utils = require("../utils");
15
-
16
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
17
-
11
+ function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
18
12
  const LinkIconContainer = _theming.styled.span(_ref => {
19
13
  let {
20
14
  theme
@@ -26,11 +20,8 @@ const LinkIconContainer = _theming.styled.span(_ref => {
26
20
  textAlign: 'center'
27
21
  };
28
22
  });
29
-
30
23
  function TestSelect(props) {
31
- var _props$tests$find$tes, _props$tests$find;
32
-
33
- const testName = (_props$tests$find$tes = (_props$tests$find = props.tests.find(x => x.id === props.selectedTestId)) === null || _props$tests$find === void 0 ? void 0 : _props$tests$find.testName) !== null && _props$tests$find$tes !== void 0 ? _props$tests$find$tes : '';
24
+ const testName = props.tests.find(x => x.id === props.selectedTestId)?.testName ?? '';
34
25
  return /*#__PURE__*/_react.default.createElement(_components.WithTooltip, {
35
26
  trigger: "click",
36
27
  placement: "bottom",
@@ -40,20 +31,16 @@ function TestSelect(props) {
40
31
  onHide
41
32
  } = _ref2;
42
33
  return /*#__PURE__*/_react.default.createElement(_components.TooltipLinkList, {
43
- links: props.tests.map(x => {
44
- var _x$testName;
45
-
46
- return {
47
- id: x.id,
48
- title: (_x$testName = x.testName) !== null && _x$testName !== void 0 ? _x$testName : '',
49
- active: props.selectedTestId === x.id,
50
- onClick: () => {
51
- props.onChangeTest(x.id);
52
- onHide();
53
- },
54
- left: /*#__PURE__*/_react.default.createElement(LinkIconContainer, null, (0, _utils.getEmojiByTestStatus)(x.status, x.skip))
55
- };
56
- })
34
+ links: props.tests.map(x => ({
35
+ id: x.id,
36
+ title: x.testName ?? '',
37
+ active: props.selectedTestId === x.id,
38
+ onClick: () => {
39
+ props.onChangeTest(x.id);
40
+ onHide();
41
+ },
42
+ left: /*#__PURE__*/_react.default.createElement(LinkIconContainer, null, (0, _utils.getEmojiByTestStatus)(x.status, x.skip))
43
+ }))
57
44
  });
58
45
  }
59
46
  }, /*#__PURE__*/_react.default.createElement(_components.Button, {