creevey 0.8.1-beta.0 → 0.8.1-sb7.0

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 (242) hide show
  1. package/CHANGELOG.md +8 -0
  2. package/package.json +22 -19
  3. package/lib/cjs/cli.js +0 -5
  4. package/lib/cjs/client/addon/Manager.js +0 -264
  5. package/lib/cjs/client/addon/components/Addon.js +0 -55
  6. package/lib/cjs/client/addon/components/Icons.js +0 -46
  7. package/lib/cjs/client/addon/components/Panel.js +0 -72
  8. package/lib/cjs/client/addon/components/TestSelect.js +0 -65
  9. package/lib/cjs/client/addon/components/Tools.js +0 -95
  10. package/lib/cjs/client/addon/decorator.js +0 -11
  11. package/lib/cjs/client/addon/index.js +0 -31
  12. package/lib/cjs/client/addon/preset.ie11.js +0 -74
  13. package/lib/cjs/client/addon/preset.js +0 -62
  14. package/lib/cjs/client/addon/readyForCapture.js +0 -12
  15. package/lib/cjs/client/addon/register.js +0 -72
  16. package/lib/cjs/client/addon/utils.js +0 -42
  17. package/lib/cjs/client/addon/withCreevey.js +0 -350
  18. package/lib/cjs/client/shared/components/ImagesView/BlendView.js +0 -87
  19. package/lib/cjs/client/shared/components/ImagesView/ImagesView.js +0 -92
  20. package/lib/cjs/client/shared/components/ImagesView/SideBySideView.js +0 -154
  21. package/lib/cjs/client/shared/components/ImagesView/SlideView.js +0 -166
  22. package/lib/cjs/client/shared/components/ImagesView/SwapView.js +0 -91
  23. package/lib/cjs/client/shared/components/ImagesView/index.js +0 -45
  24. package/lib/cjs/client/shared/components/PageFooter/PageFooter.js +0 -50
  25. package/lib/cjs/client/shared/components/PageFooter/Paging.js +0 -94
  26. package/lib/cjs/client/shared/components/PageHeader/ImagePreview.js +0 -82
  27. package/lib/cjs/client/shared/components/PageHeader/PageHeader.js +0 -119
  28. package/lib/cjs/client/shared/components/ResultsPage.js +0 -143
  29. package/lib/cjs/client/shared/creeveyClientApi.js +0 -76
  30. package/lib/cjs/client/shared/helpers.js +0 -411
  31. package/lib/cjs/client/shared/viewMode.js +0 -17
  32. package/lib/cjs/client/web/142.js +0 -2
  33. package/lib/cjs/client/web/142.js.LICENSE.txt +0 -12
  34. package/lib/cjs/client/web/32.js +0 -1
  35. package/lib/cjs/client/web/551.js +0 -1
  36. package/lib/cjs/client/web/566.js +0 -2
  37. package/lib/cjs/client/web/566.js.LICENSE.txt +0 -31
  38. package/lib/cjs/client/web/691.js +0 -2
  39. package/lib/cjs/client/web/691.js.LICENSE.txt +0 -8
  40. package/lib/cjs/client/web/725.js +0 -1
  41. package/lib/cjs/client/web/index.html +0 -19
  42. package/lib/cjs/client/web/main.js +0 -2
  43. package/lib/cjs/client/web/main.js.LICENSE.txt +0 -49
  44. package/lib/cjs/creevey.js +0 -69
  45. package/lib/cjs/index.js +0 -39
  46. package/lib/cjs/server/config.js +0 -93
  47. package/lib/cjs/server/docker.js +0 -146
  48. package/lib/cjs/server/extract.js +0 -46
  49. package/lib/cjs/server/index.js +0 -83
  50. package/lib/cjs/server/loaders/babel/creevey-plugin.js +0 -86
  51. package/lib/cjs/server/loaders/babel/helpers.js +0 -469
  52. package/lib/cjs/server/loaders/babel/register.js +0 -124
  53. package/lib/cjs/server/loaders/hooks/mdx.js +0 -30
  54. package/lib/cjs/server/loaders/hooks/svelte.js +0 -65
  55. package/lib/cjs/server/loaders/webpack/compile.js +0 -269
  56. package/lib/cjs/server/loaders/webpack/creevey-loader.js +0 -172
  57. package/lib/cjs/server/loaders/webpack/dummy-hmr.js +0 -39
  58. package/lib/cjs/server/loaders/webpack/mdx-loader.js +0 -72
  59. package/lib/cjs/server/loaders/webpack/start.js +0 -41
  60. package/lib/cjs/server/logger.js +0 -48
  61. package/lib/cjs/server/master/api.js +0 -71
  62. package/lib/cjs/server/master/index.js +0 -152
  63. package/lib/cjs/server/master/master.js +0 -57
  64. package/lib/cjs/server/master/pool.js +0 -197
  65. package/lib/cjs/server/master/runner.js +0 -281
  66. package/lib/cjs/server/master/server.js +0 -131
  67. package/lib/cjs/server/messages.js +0 -264
  68. package/lib/cjs/server/selenium/browser.js +0 -656
  69. package/lib/cjs/server/selenium/index.js +0 -31
  70. package/lib/cjs/server/selenium/selenoid.js +0 -172
  71. package/lib/cjs/server/stories.js +0 -153
  72. package/lib/cjs/server/storybook/entry.js +0 -53
  73. package/lib/cjs/server/storybook/helpers.js +0 -158
  74. package/lib/cjs/server/storybook/providers/browser.js +0 -74
  75. package/lib/cjs/server/storybook/providers/nodejs.js +0 -237
  76. package/lib/cjs/server/update.js +0 -79
  77. package/lib/cjs/server/utils.js +0 -169
  78. package/lib/cjs/server/worker/chai-image.js +0 -142
  79. package/lib/cjs/server/worker/helpers.js +0 -69
  80. package/lib/cjs/server/worker/index.js +0 -15
  81. package/lib/cjs/server/worker/reporter.js +0 -108
  82. package/lib/cjs/server/worker/worker.js +0 -268
  83. package/lib/cjs/shared/index.js +0 -101
  84. package/lib/cjs/shared/serializeRegExp.js +0 -42
  85. package/lib/cjs/types.js +0 -74
  86. package/lib/esm/cli.js +0 -4
  87. package/lib/esm/client/addon/Manager.js +0 -248
  88. package/lib/esm/client/addon/components/Addon.js +0 -39
  89. package/lib/esm/client/addon/components/Icons.js +0 -31
  90. package/lib/esm/client/addon/components/Panel.js +0 -53
  91. package/lib/esm/client/addon/components/TestSelect.js +0 -51
  92. package/lib/esm/client/addon/components/Tools.js +0 -74
  93. package/lib/esm/client/addon/decorator.js +0 -2
  94. package/lib/esm/client/addon/index.js +0 -2
  95. package/lib/esm/client/addon/preset.ie11.js +0 -59
  96. package/lib/esm/client/addon/preset.js +0 -41
  97. package/lib/esm/client/addon/readyForCapture.js +0 -5
  98. package/lib/esm/client/addon/register.js +0 -51
  99. package/lib/esm/client/addon/utils.js +0 -32
  100. package/lib/esm/client/addon/withCreevey.js +0 -323
  101. package/lib/esm/client/shared/components/ImagesView/BlendView.js +0 -67
  102. package/lib/esm/client/shared/components/ImagesView/ImagesView.js +0 -69
  103. package/lib/esm/client/shared/components/ImagesView/SideBySideView.js +0 -131
  104. package/lib/esm/client/shared/components/ImagesView/SlideView.js +0 -143
  105. package/lib/esm/client/shared/components/ImagesView/SwapView.js +0 -71
  106. package/lib/esm/client/shared/components/ImagesView/index.js +0 -5
  107. package/lib/esm/client/shared/components/PageFooter/PageFooter.js +0 -36
  108. package/lib/esm/client/shared/components/PageFooter/Paging.js +0 -80
  109. package/lib/esm/client/shared/components/PageHeader/ImagePreview.js +0 -68
  110. package/lib/esm/client/shared/components/PageHeader/PageHeader.js +0 -97
  111. package/lib/esm/client/shared/components/ResultsPage.js +0 -115
  112. package/lib/esm/client/shared/creeveyClientApi.js +0 -67
  113. package/lib/esm/client/shared/helpers.js +0 -353
  114. package/lib/esm/client/shared/viewMode.js +0 -6
  115. package/lib/esm/creevey.js +0 -54
  116. package/lib/esm/index.js +0 -3
  117. package/lib/esm/server/config.js +0 -70
  118. package/lib/esm/server/docker.js +0 -123
  119. package/lib/esm/server/extract.js +0 -32
  120. package/lib/esm/server/index.js +0 -64
  121. package/lib/esm/server/loaders/babel/creevey-plugin.js +0 -72
  122. package/lib/esm/server/loaders/babel/helpers.js +0 -452
  123. package/lib/esm/server/loaders/babel/register.js +0 -103
  124. package/lib/esm/server/loaders/hooks/mdx.js +0 -15
  125. package/lib/esm/server/loaders/hooks/svelte.js +0 -49
  126. package/lib/esm/server/loaders/webpack/compile.js +0 -246
  127. package/lib/esm/server/loaders/webpack/creevey-loader.js +0 -152
  128. package/lib/esm/server/loaders/webpack/dummy-hmr.js +0 -32
  129. package/lib/esm/server/loaders/webpack/mdx-loader.js +0 -58
  130. package/lib/esm/server/loaders/webpack/start.js +0 -27
  131. package/lib/esm/server/logger.js +0 -20
  132. package/lib/esm/server/master/api.js +0 -60
  133. package/lib/esm/server/master/index.js +0 -131
  134. package/lib/esm/server/master/master.js +0 -38
  135. package/lib/esm/server/master/pool.js +0 -176
  136. package/lib/esm/server/master/runner.js +0 -259
  137. package/lib/esm/server/master/server.js +0 -107
  138. package/lib/esm/server/messages.js +0 -232
  139. package/lib/esm/server/selenium/browser.js +0 -623
  140. package/lib/esm/server/selenium/index.js +0 -2
  141. package/lib/esm/server/selenium/selenoid.js +0 -149
  142. package/lib/esm/server/stories.js +0 -135
  143. package/lib/esm/server/storybook/entry.js +0 -27
  144. package/lib/esm/server/storybook/helpers.js +0 -97
  145. package/lib/esm/server/storybook/providers/browser.js +0 -60
  146. package/lib/esm/server/storybook/providers/nodejs.js +0 -216
  147. package/lib/esm/server/update.js +0 -61
  148. package/lib/esm/server/utils.js +0 -128
  149. package/lib/esm/server/worker/chai-image.js +0 -130
  150. package/lib/esm/server/worker/helpers.js +0 -60
  151. package/lib/esm/server/worker/index.js +0 -1
  152. package/lib/esm/server/worker/reporter.js +0 -86
  153. package/lib/esm/server/worker/worker.js +0 -238
  154. package/lib/esm/shared/index.js +0 -78
  155. package/lib/esm/shared/serializeRegExp.js +0 -24
  156. package/lib/esm/types.js +0 -43
  157. package/lib/types/cli.d.ts +0 -1
  158. package/lib/types/client/addon/Manager.d.ts +0 -37
  159. package/lib/types/client/addon/components/Addon.d.ts +0 -8
  160. package/lib/types/client/addon/components/Icons.d.ts +0 -7
  161. package/lib/types/client/addon/components/Panel.d.ts +0 -9
  162. package/lib/types/client/addon/components/TestSelect.d.ts +0 -8
  163. package/lib/types/client/addon/components/Tools.d.ts +0 -6
  164. package/lib/types/client/addon/decorator.d.ts +0 -1
  165. package/lib/types/client/addon/index.d.ts +0 -2
  166. package/lib/types/client/addon/preset.d.ts +0 -23
  167. package/lib/types/client/addon/preset.ie11.d.ts +0 -10
  168. package/lib/types/client/addon/readyForCapture.d.ts +0 -6
  169. package/lib/types/client/addon/register.d.ts +0 -3
  170. package/lib/types/client/addon/utils.d.ts +0 -3
  171. package/lib/types/client/addon/withCreevey.d.ts +0 -24
  172. package/lib/types/client/shared/components/ImagesView/BlendView.d.ts +0 -3
  173. package/lib/types/client/shared/components/ImagesView/ImagesView.d.ts +0 -24
  174. package/lib/types/client/shared/components/ImagesView/SideBySideView.d.ts +0 -3
  175. package/lib/types/client/shared/components/ImagesView/SlideView.d.ts +0 -3
  176. package/lib/types/client/shared/components/ImagesView/SwapView.d.ts +0 -3
  177. package/lib/types/client/shared/components/ImagesView/index.d.ts +0 -5
  178. package/lib/types/client/shared/components/PageFooter/PageFooter.d.ts +0 -8
  179. package/lib/types/client/shared/components/PageFooter/Paging.d.ts +0 -7
  180. package/lib/types/client/shared/components/PageHeader/ImagePreview.d.ts +0 -12
  181. package/lib/types/client/shared/components/PageHeader/PageHeader.d.ts +0 -16
  182. package/lib/types/client/shared/components/ResultsPage.d.ts +0 -18
  183. package/lib/types/client/shared/creeveyClientApi.d.ts +0 -9
  184. package/lib/types/client/shared/helpers.d.ts +0 -46
  185. package/lib/types/client/shared/viewMode.d.ts +0 -4
  186. package/lib/types/client/web/CreeveyApp.d.ts +0 -11
  187. package/lib/types/client/web/CreeveyContext.d.ts +0 -11
  188. package/lib/types/client/web/CreeveyLoader.d.ts +0 -2
  189. package/lib/types/client/web/CreeveyView/SideBar/Checkbox.d.ts +0 -19
  190. package/lib/types/client/web/CreeveyView/SideBar/Search.d.ts +0 -6
  191. package/lib/types/client/web/CreeveyView/SideBar/SideBar.d.ts +0 -14
  192. package/lib/types/client/web/CreeveyView/SideBar/SideBarHeader.d.ts +0 -12
  193. package/lib/types/client/web/CreeveyView/SideBar/SuiteLink.d.ts +0 -33
  194. package/lib/types/client/web/CreeveyView/SideBar/TestLink.d.ts +0 -7
  195. package/lib/types/client/web/CreeveyView/SideBar/TestStatusIcon.d.ts +0 -10
  196. package/lib/types/client/web/CreeveyView/SideBar/TestsStatus.d.ts +0 -9
  197. package/lib/types/client/web/CreeveyView/SideBar/Toggle.d.ts +0 -6
  198. package/lib/types/client/web/CreeveyView/SideBar/index.d.ts +0 -1
  199. package/lib/types/client/web/KeyboardEventsContext.d.ts +0 -13
  200. package/lib/types/client/web/index.d.ts +0 -4
  201. package/lib/types/creevey.d.ts +0 -1
  202. package/lib/types/index.d.ts +0 -2
  203. package/lib/types/server/config.d.ts +0 -4
  204. package/lib/types/server/docker.d.ts +0 -7
  205. package/lib/types/server/extract.d.ts +0 -2
  206. package/lib/types/server/index.d.ts +0 -2
  207. package/lib/types/server/loaders/babel/creevey-plugin.d.ts +0 -1
  208. package/lib/types/server/loaders/babel/helpers.d.ts +0 -19
  209. package/lib/types/server/loaders/babel/register.d.ts +0 -5
  210. package/lib/types/server/loaders/hooks/mdx.d.ts +0 -1
  211. package/lib/types/server/loaders/hooks/svelte.d.ts +0 -1
  212. package/lib/types/server/loaders/webpack/compile.d.ts +0 -2
  213. package/lib/types/server/loaders/webpack/creevey-loader.d.ts +0 -4
  214. package/lib/types/server/loaders/webpack/dummy-hmr.d.ts +0 -10
  215. package/lib/types/server/loaders/webpack/mdx-loader.d.ts +0 -6
  216. package/lib/types/server/loaders/webpack/start.d.ts +0 -1
  217. package/lib/types/server/logger.d.ts +0 -10
  218. package/lib/types/server/master/api.d.ts +0 -7
  219. package/lib/types/server/master/index.d.ts +0 -3
  220. package/lib/types/server/master/master.d.ts +0 -7
  221. package/lib/types/server/master/pool.d.ts +0 -31
  222. package/lib/types/server/master/runner.d.ts +0 -26
  223. package/lib/types/server/master/server.d.ts +0 -2
  224. package/lib/types/server/messages.d.ts +0 -29
  225. package/lib/types/server/selenium/browser.d.ts +0 -17
  226. package/lib/types/server/selenium/index.d.ts +0 -2
  227. package/lib/types/server/selenium/selenoid.d.ts +0 -3
  228. package/lib/types/server/stories.d.ts +0 -8
  229. package/lib/types/server/storybook/entry.d.ts +0 -17
  230. package/lib/types/server/storybook/helpers.d.ts +0 -24
  231. package/lib/types/server/storybook/providers/browser.d.ts +0 -4
  232. package/lib/types/server/storybook/providers/nodejs.d.ts +0 -9
  233. package/lib/types/server/update.d.ts +0 -2
  234. package/lib/types/server/utils.d.ts +0 -23
  235. package/lib/types/server/worker/chai-image.d.ts +0 -6
  236. package/lib/types/server/worker/helpers.d.ts +0 -8
  237. package/lib/types/server/worker/index.d.ts +0 -1
  238. package/lib/types/server/worker/reporter.d.ts +0 -8
  239. package/lib/types/server/worker/worker.d.ts +0 -4
  240. package/lib/types/shared/index.d.ts +0 -7
  241. package/lib/types/shared/serializeRegExp.d.ts +0 -9
  242. package/lib/types/types.d.ts +0 -486
@@ -1,248 +0,0 @@
1
- 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; }
2
-
3
- import { SET_STORIES, STORY_RENDERED } from '@storybook/core-events';
4
- import { denormalizeStoryParameters } from '../../shared';
5
- import { isDefined } from '../../types';
6
- import { initCreeveyClientApi } from '../shared/creeveyClientApi';
7
- import { calcStatus } from '../shared/helpers';
8
- import { ADDON_ID } from './register';
9
- import { getEmojiByTestStatus } from './utils';
10
- export class CreeveyManager {
11
- constructor(storybookApi) {
12
- this.storybookApi = storybookApi;
13
-
14
- _defineProperty(this, "storyId", '');
15
-
16
- _defineProperty(this, "activeBrowser", '');
17
-
18
- _defineProperty(this, "selectedTestId", '');
19
-
20
- _defineProperty(this, "status", {
21
- isRunning: false,
22
- tests: {},
23
- browsers: []
24
- });
25
-
26
- _defineProperty(this, "creeveyApi", null);
27
-
28
- _defineProperty(this, "stories", {});
29
-
30
- _defineProperty(this, "updateStatusListeners", []);
31
-
32
- _defineProperty(this, "changeTestListeners", []);
33
-
34
- _defineProperty(this, "initAll", async () => {
35
- this.storybookApi.on(STORY_RENDERED, this.onStoryRendered);
36
- this.storybookApi.on(SET_STORIES, this.onSetStories);
37
- this.creeveyApi = await initCreeveyClientApi();
38
- this.creeveyApi.onUpdate(this.handleCreeveyUpdate);
39
- this.status = await this.creeveyApi.status;
40
- });
41
-
42
- _defineProperty(this, "handleCreeveyUpdate", update => {
43
- const {
44
- tests,
45
- removedTests = [],
46
- isRunning
47
- } = update;
48
-
49
- if (isDefined(isRunning)) {
50
- this.status.isRunning = isRunning;
51
- }
52
-
53
- if (isDefined(tests)) {
54
- const prevTests = this.status.tests;
55
- const prevStories = this.stories || {};
56
- Object.values(tests).filter(isDefined).forEach(update => {
57
- const {
58
- id,
59
- skip,
60
- status,
61
- results,
62
- approved,
63
- storyId
64
- } = update;
65
- const test = prevTests[id];
66
-
67
- if (!test) {
68
- return prevTests[id] = update;
69
- }
70
-
71
- if (isDefined(skip)) test.skip = skip;
72
-
73
- if (isDefined(status)) {
74
- test.status = status;
75
-
76
- if (isDefined(storyId) && isDefined(prevStories[storyId])) {
77
- const story = prevStories[storyId];
78
- const storyStatus = this.getStoryTests(storyId);
79
- const oldStatus = storyStatus.map(x => x.id === id ? status : x.status).reduce((oldStatus, newStatus) => calcStatus(oldStatus, newStatus), undefined);
80
- story.name = this.addStatusToStoryName(story.name, calcStatus(oldStatus, status), skip || false);
81
- }
82
- }
83
-
84
- if (isDefined(results)) test.results ? test.results.push(...results) : test.results = results;
85
-
86
- if (isDefined(approved)) {
87
- Object.entries(approved).forEach(_ref => {
88
- let [image, retry] = _ref;
89
- return retry !== undefined && test && ((test.approved = (test === null || test === void 0 ? void 0 : test.approved) || {})[image] = retry);
90
- });
91
- }
92
- });
93
- removedTests.forEach(_ref2 => {
94
- let {
95
- id
96
- } = _ref2;
97
- return delete prevTests[id];
98
- });
99
- this.status.tests = prevTests;
100
- this.stories = prevStories;
101
- this.setPanelsTitle();
102
- void this.storybookApi.setStories(this.stories);
103
- }
104
-
105
- this.updateStatusListeners.forEach(x => x(update));
106
- });
107
-
108
- _defineProperty(this, "getCurrentTest", () => {
109
- return this.status.tests[this.selectedTestId];
110
- });
111
-
112
- _defineProperty(this, "onStoryRendered", storyId => {
113
- if (this.storyId === '') void this.addStatusesToSideBar();
114
-
115
- if (this.storyId !== storyId) {
116
- var _this$getTestsByStory, _this$getTestsByStory2;
117
-
118
- this.storyId = storyId;
119
- 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 : '';
120
- this.setPanelsTitle();
121
- this.changeTestListeners.forEach(x => x(this.selectedTestId));
122
- }
123
- });
124
-
125
- _defineProperty(this, "onStart", () => {
126
- var _this$creeveyApi;
127
-
128
- (_this$creeveyApi = this.creeveyApi) === null || _this$creeveyApi === void 0 ? void 0 : _this$creeveyApi.start([this.selectedTestId]);
129
- });
130
-
131
- _defineProperty(this, "onStop", () => {
132
- var _this$creeveyApi2;
133
-
134
- (_this$creeveyApi2 = this.creeveyApi) === null || _this$creeveyApi2 === void 0 ? void 0 : _this$creeveyApi2.stop();
135
- });
136
-
137
- _defineProperty(this, "onImageApprove", (id, retry, image) => {
138
- var _this$creeveyApi3;
139
-
140
- return (_this$creeveyApi3 = this.creeveyApi) === null || _this$creeveyApi3 === void 0 ? void 0 : _this$creeveyApi3.approve(id, retry, image);
141
- });
142
-
143
- _defineProperty(this, "onStartAllStoryTests", () => {
144
- var _this$creeveyApi4;
145
-
146
- const ids = Object.values(this.status.tests).filter(isDefined).filter(x => x.storyId === this.storyId).map(x => x.id);
147
- (_this$creeveyApi4 = this.creeveyApi) === null || _this$creeveyApi4 === void 0 ? void 0 : _this$creeveyApi4.start(ids);
148
- });
149
-
150
- _defineProperty(this, "onStartAllTests", () => {
151
- var _this$creeveyApi5;
152
-
153
- const ids = Object.values(this.status.tests).filter(isDefined).map(x => x.id);
154
- (_this$creeveyApi5 = this.creeveyApi) === null || _this$creeveyApi5 === void 0 ? void 0 : _this$creeveyApi5.start(ids);
155
- });
156
-
157
- _defineProperty(this, "onSetStories", data => {
158
- const stories = data.v ? denormalizeStoryParameters(data) : data.stories;
159
- this.stories = stories;
160
- });
161
-
162
- _defineProperty(this, "setActiveBrowser", browser => {
163
- var _this$getTestsByStory3, _this$getTestsByStory4;
164
-
165
- this.activeBrowser = browser;
166
- 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 : '';
167
- this.changeTestListeners.forEach(x => x(this.selectedTestId));
168
- });
169
-
170
- _defineProperty(this, "setSelectedTestId", testId => {
171
- this.selectedTestId = testId;
172
- this.changeTestListeners.forEach(x => x(this.selectedTestId));
173
- });
174
-
175
- _defineProperty(this, "getStoryTests", storyId => {
176
- if (!this.status || !this.status.tests) return [];
177
- return Object.values(this.status.tests).filter(result => (result === null || result === void 0 ? void 0 : result.storyId) === storyId).filter(isDefined);
178
- });
179
-
180
- _defineProperty(this, "getBrowsers", () => {
181
- return this.status.browsers;
182
- });
183
-
184
- _defineProperty(this, "getTestsByStoryIdAndBrowser", browser => {
185
- return Object.values(this.status.tests).filter(x => (x === null || x === void 0 ? void 0 : x.browser) === browser && x.storyId === this.storyId).filter(isDefined);
186
- });
187
-
188
- _defineProperty(this, "getTabTitle", browser => {
189
- const tests = this.getTestsByStoryIdAndBrowser(browser);
190
- const browserStatus = tests.map(x => x && x.status).reduce((oldStatus, newStatus) => calcStatus(oldStatus, newStatus), undefined);
191
- const browserSkip = tests.length > 0 ? tests.every(x => x && x.skip) : false;
192
- const emojiStatus = getEmojiByTestStatus(browserStatus, browserSkip);
193
- return "".concat(emojiStatus ? "".concat(emojiStatus, " ") : '', "Creevey/").concat(browser);
194
- });
195
-
196
- _defineProperty(this, "setPanelsTitle", () => {
197
- var _this$storybookApi;
198
-
199
- const panels = (_this$storybookApi = this.storybookApi) === null || _this$storybookApi === void 0 ? void 0 : _this$storybookApi.getPanels();
200
- if (!panels) return;
201
- let firstPanelBrowser = this.activeBrowser;
202
-
203
- for (const p in panels) {
204
- var _panel$id;
205
-
206
- const panel = panels[p];
207
-
208
- if (((_panel$id = panel.id) === null || _panel$id === void 0 ? void 0 : _panel$id.indexOf(ADDON_ID)) === 0 && panel.paramKey) {
209
- panel.title = this.getTabTitle(panel.paramKey);
210
- if (!firstPanelBrowser) firstPanelBrowser = panel.paramKey;
211
- }
212
- }
213
-
214
- this.storybookApi.setSelectedPanel("".concat(ADDON_ID, "/panel/").concat(firstPanelBrowser));
215
- });
216
-
217
- this.storybookApi = storybookApi;
218
- }
219
-
220
- onUpdateStatus(listener) {
221
- this.updateStatusListeners.push(listener);
222
- return () => void (this.updateStatusListeners = this.updateStatusListeners.filter(x => x != listener));
223
- }
224
-
225
- onChangeTest(listener) {
226
- this.changeTestListeners.push(listener);
227
- return () => void (this.changeTestListeners = this.changeTestListeners.filter(x => x != listener));
228
- }
229
-
230
- async addStatusesToSideBar() {
231
- if (!Object.keys(this.stories).length) return;
232
- const stories = this.stories;
233
- Object.keys(this.stories).forEach(storyId => {
234
- const storyStatus = this.getStoryTests(storyId);
235
- const status = storyStatus.map(x => x.status).reduce((oldStatus, newStatus) => calcStatus(oldStatus, newStatus), undefined);
236
- const skip = storyStatus.length > 0 ? storyStatus.every(x => x.skip) : false;
237
- this.stories[storyId].name = this.addStatusToStoryName(stories[storyId].name, status, skip);
238
- });
239
- await this.storybookApi.setStories(this.stories);
240
- }
241
-
242
- addStatusToStoryName(name, status, skip) {
243
- name = name.replace(/^(❌|✔|🟡|🕗|⏸) /, '');
244
- const emojiStatus = getEmojiByTestStatus(status, skip);
245
- return "".concat(emojiStatus ? "".concat(emojiStatus, " ") : '', " ").concat(name);
246
- }
247
-
248
- }
@@ -1,39 +0,0 @@
1
- import { Placeholder } from '@storybook/components';
2
- import React, { useEffect, useState } from 'react';
3
- import { Panel } from './Panel';
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(() => {
13
- if (active) {
14
- manager.setActiveBrowser(browser);
15
- const browserTests = manager.getTestsByStoryIdAndBrowser(manager.activeBrowser);
16
- setTests(browserTests);
17
- }
18
- }, [active, browser, manager]);
19
- useEffect(() => {
20
- const unsubscribe = manager.onChangeTest(testId => {
21
- setSelectedTestId(testId);
22
- const status = manager.getTestsByStoryIdAndBrowser(manager.activeBrowser);
23
- setTests(status);
24
- });
25
- return unsubscribe;
26
- }, [manager]);
27
- useEffect(() => {
28
- const unsubscribe = manager.onUpdateStatus(() => {
29
- setTests(manager.getTestsByStoryIdAndBrowser(manager.activeBrowser));
30
- });
31
- return unsubscribe;
32
- }, [manager, browser]);
33
- return active ? tests.length ? /*#__PURE__*/React.createElement(Panel, {
34
- tests: tests,
35
- selectedTestId: selectedTestId,
36
- onChangeTest: manager.setSelectedTestId,
37
- onImageApprove: manager.onImageApprove
38
- }) : /*#__PURE__*/React.createElement(Placeholder, null, "No test results") : null;
39
- };
@@ -1,31 +0,0 @@
1
- import React from 'react';
2
- export const NextIcon = _ref => {
3
- let {
4
- width,
5
- height
6
- } = _ref;
7
- return /*#__PURE__*/React.createElement("svg", {
8
- version: "1.1",
9
- width: width,
10
- height: height,
11
- viewBox: "0 0 306 306"
12
- }, /*#__PURE__*/React.createElement("path", {
13
- d: "M0,306l216.75-153L0,0V306z M255,0v306h51V0H255z",
14
- fill: "currentColor"
15
- }));
16
- };
17
- export const ForwardIcon = _ref2 => {
18
- let {
19
- width,
20
- height
21
- } = _ref2;
22
- return /*#__PURE__*/React.createElement("svg", {
23
- version: "1.1",
24
- width: width,
25
- height: height,
26
- viewBox: "0 0 512 512"
27
- }, /*#__PURE__*/React.createElement("path", {
28
- fill: "currentColor",
29
- 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"
30
- }));
31
- };
@@ -1,53 +0,0 @@
1
- import React from 'react';
2
- import { Loader } from '@storybook/components';
3
- import { ResultsPage } from '../../shared/components/ResultsPage';
4
- import { styled } from '@storybook/theming';
5
- import { getTestPath } from '../../shared/helpers';
6
- import TestSelect from './TestSelect';
7
- const Wrapper = styled.div(_ref => {
8
- let {
9
- isRunning
10
- } = _ref;
11
- return {
12
- opacity: isRunning ? 0.5 : 1,
13
- height: '100%'
14
- };
15
- });
16
- const TestSelectContainer = styled.div(_ref2 => {
17
- let {
18
- theme
19
- } = _ref2;
20
- return {
21
- padding: '8px',
22
- border: "1px solid ".concat(theme.appBorderColor)
23
- };
24
- });
25
- export const Panel = _ref3 => {
26
- var _result$results, _result$results$lengt, _result$results2;
27
-
28
- let {
29
- tests,
30
- selectedTestId,
31
- onChangeTest,
32
- onImageApprove
33
- } = _ref3;
34
- const result = tests.find(x => x.id === selectedTestId);
35
- const isRunning = (result === null || result === void 0 ? void 0 : result.status) === 'running';
36
- return /*#__PURE__*/React.createElement("div", null, tests.length > 1 && /*#__PURE__*/React.createElement(TestSelectContainer, null, /*#__PURE__*/React.createElement(TestSelect, {
37
- tests: tests,
38
- selectedTestId: selectedTestId,
39
- onChangeTest: onChangeTest
40
- })), isRunning && /*#__PURE__*/React.createElement(Loader, null), result !== null && result !== void 0 && (_result$results = result.results) !== null && _result$results !== void 0 && _result$results.length ? /*#__PURE__*/React.createElement(Wrapper, {
41
- isRunning: isRunning
42
- }, /*#__PURE__*/React.createElement(ResultsPage, {
43
- height: '100%',
44
- 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
45
- ,
46
- id: result.id,
47
- path: getTestPath(result) // TODO Memo?
48
- ,
49
- results: result.results,
50
- approved: result.approved,
51
- onImageApprove: onImageApprove
52
- })) : null);
53
- };
@@ -1,51 +0,0 @@
1
- import { Button, Icons, TooltipLinkList, WithTooltip } from '@storybook/components';
2
- import { styled } from '@storybook/theming';
3
- import React from 'react';
4
- import { getEmojiByTestStatus } from '../utils';
5
- const LinkIconContainer = styled.span(_ref => {
6
- let {
7
- theme
8
- } = _ref;
9
- return {
10
- display: 'inline-block',
11
- width: '20px',
12
- color: theme.color.defaultText,
13
- textAlign: 'center'
14
- };
15
- });
16
- export default function TestSelect(props) {
17
- var _props$tests$find$tes, _props$tests$find;
18
-
19
- 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 : '';
20
- return /*#__PURE__*/React.createElement(WithTooltip, {
21
- trigger: "click",
22
- placement: "bottom",
23
- closeOnClick: true,
24
- tooltip: _ref2 => {
25
- let {
26
- onHide
27
- } = _ref2;
28
- return /*#__PURE__*/React.createElement(TooltipLinkList, {
29
- links: props.tests.map(x => {
30
- var _x$testName;
31
-
32
- return {
33
- id: x.id,
34
- title: (_x$testName = x.testName) !== null && _x$testName !== void 0 ? _x$testName : '',
35
- active: props.selectedTestId === x.id,
36
- onClick: () => {
37
- props.onChangeTest(x.id);
38
- onHide();
39
- },
40
- left: /*#__PURE__*/React.createElement(LinkIconContainer, null, getEmojiByTestStatus(x.status, x.skip))
41
- };
42
- })
43
- });
44
- }
45
- }, /*#__PURE__*/React.createElement(Button, {
46
- outline: true,
47
- small: true
48
- }, /*#__PURE__*/React.createElement(Icons, {
49
- icon: "menu"
50
- }), testName));
51
- }
@@ -1,74 +0,0 @@
1
- import React, { Fragment, useState, useEffect } from 'react';
2
- import { IconButton, Icons, Separator } from '@storybook/components';
3
- import { ForwardIcon, NextIcon } from './Icons';
4
- import { stringify } from 'qs';
5
- import { styled } from '@storybook/theming';
6
- import { isDefined } from '../../../types';
7
- import { getTestPath, useForceUpdate } from '../../shared/helpers';
8
- const Button = styled(IconButton)({
9
- '&:disabled': {
10
- opacity: 0.5,
11
- cursor: 'default'
12
- },
13
- '&:disabled:hover': {
14
- color: 'inherit'
15
- }
16
- });
17
- export const Tools = _ref => {
18
- let {
19
- manager
20
- } = _ref;
21
- const [buttonClicked, setButtonClicked] = useState();
22
- const [isRunning, setRunning] = useState(manager.status.isRunning);
23
- const forceUpdate = useForceUpdate();
24
- const test = manager.getCurrentTest();
25
- useEffect(() => {
26
- const unsubscribe = manager.onChangeTest(() => {
27
- forceUpdate();
28
- });
29
- return unsubscribe;
30
- }, [manager, forceUpdate]);
31
- useEffect(() => {
32
- const unsubscribe = manager.onUpdateStatus(_ref2 => {
33
- let {
34
- isRunning
35
- } = _ref2;
36
- if (isDefined(isRunning)) setRunning(isRunning);
37
- });
38
- return unsubscribe;
39
- }, [manager]);
40
- if (!test) return null;
41
-
42
- function renderButton(type, title, onClick, icon) {
43
- const handleClick = () => {
44
- setButtonClicked(type);
45
- onClick();
46
- };
47
-
48
- const disabled = isRunning && buttonClicked != null && buttonClicked !== type;
49
- return /*#__PURE__*/React.createElement(Button, {
50
- onClick: () => {
51
- isRunning ? manager.onStop() : handleClick();
52
- },
53
- title: disabled ? '' : title,
54
- disabled: disabled
55
- }, buttonClicked === type && isRunning ? /*#__PURE__*/React.createElement(Icons, {
56
- icon: 'stop'
57
- }) : icon);
58
- }
59
-
60
- return /*#__PURE__*/React.createElement(Fragment, null, /*#__PURE__*/React.createElement(IconButton, {
61
- href: "http://localhost:".concat(__CREEVEY_CLIENT_PORT__ || __CREEVEY_SERVER_PORT__, "/?").concat(stringify({
62
- testPath: getTestPath(test)
63
- })),
64
- target: "_blank",
65
- title: "Show in Creevey UI"
66
- }, /*#__PURE__*/React.createElement(Icons, {
67
- icon: "sharealt"
68
- })), /*#__PURE__*/React.createElement(Separator, null), renderButton('RunAll', 'Run all', manager.onStartAllTests, /*#__PURE__*/React.createElement(ForwardIcon, null)), renderButton('RunStoryTests', 'Run all story tests', manager.onStartAllStoryTests, /*#__PURE__*/React.createElement(NextIcon, {
69
- width: 15,
70
- height: 11
71
- })), renderButton('RunTest', 'Run', manager.onStart, /*#__PURE__*/React.createElement(Icons, {
72
- icon: "play"
73
- })));
74
- };
@@ -1,2 +0,0 @@
1
- import { withCreevey } from './withCreevey';
2
- export const decorators = [withCreevey()];
@@ -1,2 +0,0 @@
1
- export * from './withCreevey';
2
- export * from './readyForCapture';
@@ -1,59 +0,0 @@
1
- const ie11Preset = ['@babel/preset-env', {
2
- targets: {
3
- ie: '11'
4
- }
5
- }];
6
- export const babel = config => {
7
- const {
8
- presets = []
9
- } = config;
10
- return { ...config,
11
- presets: [...(presets || []), ie11Preset]
12
- };
13
- };
14
- const nodeModulesThatNeedToBeParsedBecauseTheyExposeES6 = ['creevey', '@testing-library'];
15
- const include = new RegExp("[\\\\/](".concat(nodeModulesThatNeedToBeParsedBecauseTheyExposeES6.join('|'), ")"));
16
- const es6Loader = {
17
- test: /\.js$/,
18
- use: [{
19
- loader: require.resolve('babel-loader'),
20
- options: {
21
- presets: [ie11Preset]
22
- }
23
- }],
24
- include
25
- };
26
- export const managerWebpack = function () {
27
- var _webpackConfig$module, _webpackConfig$module2;
28
-
29
- let webpackConfig = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
30
- return { ...webpackConfig,
31
- module: { ...webpackConfig.module,
32
- rules: [...((_webpackConfig$module = (_webpackConfig$module2 = webpackConfig.module) === null || _webpackConfig$module2 === void 0 ? void 0 : _webpackConfig$module2.rules) !== null && _webpackConfig$module !== void 0 ? _webpackConfig$module : []), es6Loader]
33
- }
34
- };
35
- };
36
- export const webpack = function () {
37
- var _webpackConfig$module3, _webpackConfig$module4;
38
-
39
- let webpackConfig = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
40
- const {
41
- entry
42
- } = webpackConfig;
43
- const polyfills = [require.resolve('whatwg-fetch')];
44
-
45
- if (Array.isArray(entry)) {
46
- polyfills.forEach(polyfill => {
47
- if (!entry.includes(polyfill)) {
48
- entry.unshift(polyfill);
49
- }
50
- });
51
- }
52
-
53
- return { ...webpackConfig,
54
- entry,
55
- module: { ...webpackConfig.module,
56
- rules: [...((_webpackConfig$module3 = (_webpackConfig$module4 = webpackConfig.module) === null || _webpackConfig$module4 === void 0 ? void 0 : _webpackConfig$module4.rules) !== null && _webpackConfig$module3 !== void 0 ? _webpackConfig$module3 : []), es6Loader]
57
- }
58
- };
59
- };
@@ -1,41 +0,0 @@
1
- import path from 'path';
2
- import { exec } from 'shelljs';
3
- import { DefinePlugin as FallbackDefinePlugin } from 'webpack';
4
- import { resolveFromStorybookCoreServer } from '../../server/storybook/helpers';
5
- export function config() {
6
- let entry = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
7
- return [...entry, require.resolve('./decorator')];
8
- }
9
- export function managerEntries() {
10
- let entry = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
11
- return [...entry, require.resolve('./register')];
12
- }
13
- export function managerWebpack(config, options) {
14
- var _options$presets$appl, _options$presets;
15
-
16
- // TODO How to execute with non-webpack bundlers
17
- if (options.configType == 'PRODUCTION' && options.skipExtract != true) {
18
- const args = [];
19
- if (options.creeveyPreExtract) args.push("--require \"".concat(options.creeveyPreExtract, "\""));
20
- args.push(path.join(__dirname, '../../cli'));
21
- args.push("--extract \"".concat(options.outputDir, "\""));
22
- if (options.creeveyConfigPath) args.push("--config \"".concat(options.creeveyConfigPath, "\""));
23
- exec("node ".concat(args.join(' ')), {
24
- async: true
25
- });
26
- }
27
-
28
- return ((_options$presets$appl = (_options$presets = options.presets) === null || _options$presets === void 0 ? void 0 : _options$presets.apply('webpackInstance')) !== null && _options$presets$appl !== void 0 ? _options$presets$appl : Promise.resolve(undefined)).then(webpack => webpack !== null && webpack !== void 0 ? webpack : import(resolveFromStorybookCoreServer('webpack'))).then(webpack => {
29
- var _config$plugins, _options$creeveyPort;
30
-
31
- const {
32
- DefinePlugin = FallbackDefinePlugin
33
- } = webpack !== null && webpack !== void 0 ? webpack : {};
34
- (_config$plugins = config.plugins) === null || _config$plugins === void 0 ? void 0 : _config$plugins.push(new DefinePlugin({
35
- __CREEVEY_SERVER_HOST__: options.creeveyHost,
36
- __CREEVEY_SERVER_PORT__: (_options$creeveyPort = options.creeveyPort) !== null && _options$creeveyPort !== void 0 ? _options$creeveyPort : 3000,
37
- __CREEVEY_CLIENT_PORT__: options.clientPort
38
- }));
39
- return config;
40
- });
41
- }
@@ -1,5 +0,0 @@
1
- export function readyForCapture() {
2
- var _window$__CREEVEY_SET, _window;
3
-
4
- (_window$__CREEVEY_SET = (_window = window).__CREEVEY_SET_READY_FOR_CAPTURE__) === null || _window$__CREEVEY_SET === void 0 ? void 0 : _window$__CREEVEY_SET.call(_window);
5
- }
@@ -1,51 +0,0 @@
1
- import { addons, types } from '@storybook/addons';
2
- import React from 'react';
3
- import { Addon } from './components/Addon';
4
- import { Tools } from './components/Tools';
5
- import { CreeveyManager } from './Manager';
6
- export const ADDON_ID = 'creevey';
7
- addons.register(ADDON_ID, api => {
8
- void registerCreeveyPanels(api);
9
- });
10
- export async function registerCreeveyPanels(storybookApi) {
11
- const manager = new CreeveyManager(storybookApi);
12
- addons.addPanel("".concat(ADDON_ID, "/panel/run"), {
13
- title: "Creevey/Run",
14
- match: _ref => {
15
- let {
16
- viewMode
17
- } = _ref;
18
- return !!(viewMode && /^story$/.exec(viewMode));
19
- },
20
- type: types.TOOL,
21
- // eslint-disable-next-line react/display-name
22
- render: () => /*#__PURE__*/React.createElement(Tools, {
23
- manager
24
- })
25
- });
26
- await manager.initAll();
27
- const browsers = manager.getBrowsers();
28
- browsers.forEach(browser => {
29
- const panelId = "".concat(ADDON_ID, "/panel/").concat(browser);
30
- const title = manager.getTabTitle(browser);
31
- addons.addPanel(panelId, {
32
- title,
33
- type: types.PANEL,
34
- paramKey: browser,
35
- // NOTE key = PANEL_ID needs to correct render button in addons panel
36
- // eslint-disable-next-line react/display-name
37
- render: _ref2 => {
38
- let {
39
- active,
40
- key
41
- } = _ref2;
42
- return /*#__PURE__*/React.createElement(Addon, {
43
- active,
44
- key,
45
- manager,
46
- browser
47
- });
48
- }
49
- });
50
- });
51
- }