creevey 0.8.1-sb7.1 → 0.8.1-sb7.3

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 (235) hide show
  1. package/lib/cjs/cli.js +5 -0
  2. package/lib/cjs/client/addon/Manager.js +264 -0
  3. package/lib/cjs/client/addon/components/Addon.js +55 -0
  4. package/lib/cjs/client/addon/components/Icons.js +46 -0
  5. package/lib/cjs/client/addon/components/Panel.js +72 -0
  6. package/lib/cjs/client/addon/components/TestSelect.js +65 -0
  7. package/lib/cjs/client/addon/components/Tools.js +97 -0
  8. package/lib/cjs/client/addon/decorator.js +11 -0
  9. package/lib/cjs/client/addon/index.js +31 -0
  10. package/lib/cjs/client/addon/preset.ie11.js +74 -0
  11. package/lib/cjs/client/addon/preset.js +62 -0
  12. package/lib/cjs/client/addon/readyForCapture.js +12 -0
  13. package/lib/cjs/client/addon/register.js +74 -0
  14. package/lib/cjs/client/addon/utils.js +42 -0
  15. package/lib/cjs/client/addon/withCreevey.js +351 -0
  16. package/lib/cjs/client/shared/components/ImagesView/BlendView.js +87 -0
  17. package/lib/cjs/client/shared/components/ImagesView/ImagesView.js +92 -0
  18. package/lib/cjs/client/shared/components/ImagesView/SideBySideView.js +154 -0
  19. package/lib/cjs/client/shared/components/ImagesView/SlideView.js +166 -0
  20. package/lib/cjs/client/shared/components/ImagesView/SwapView.js +91 -0
  21. package/lib/cjs/client/shared/components/ImagesView/index.js +45 -0
  22. package/lib/cjs/client/shared/components/PageFooter/PageFooter.js +50 -0
  23. package/lib/cjs/client/shared/components/PageFooter/Paging.js +94 -0
  24. package/lib/cjs/client/shared/components/PageHeader/ImagePreview.js +82 -0
  25. package/lib/cjs/client/shared/components/PageHeader/PageHeader.js +119 -0
  26. package/lib/cjs/client/shared/components/ResultsPage.js +143 -0
  27. package/lib/cjs/client/shared/creeveyClientApi.js +76 -0
  28. package/lib/cjs/client/shared/helpers.js +411 -0
  29. package/lib/cjs/client/shared/viewMode.js +17 -0
  30. package/lib/cjs/client/web/19.js +1 -0
  31. package/lib/cjs/client/web/632.js +43 -0
  32. package/lib/cjs/client/web/794.js +1 -0
  33. package/lib/cjs/client/web/index.html +19 -0
  34. package/lib/cjs/client/web/main.js +79 -0
  35. package/lib/cjs/client/web/main.js.LICENSE.txt +34 -0
  36. package/lib/cjs/creevey.js +69 -0
  37. package/lib/cjs/index.js +39 -0
  38. package/lib/cjs/server/config.js +93 -0
  39. package/lib/cjs/server/docker.js +146 -0
  40. package/lib/cjs/server/extract.js +46 -0
  41. package/lib/cjs/server/index.js +83 -0
  42. package/lib/cjs/server/loaders/babel/creevey-plugin.js +86 -0
  43. package/lib/cjs/server/loaders/babel/helpers.js +469 -0
  44. package/lib/cjs/server/loaders/babel/register.js +124 -0
  45. package/lib/cjs/server/loaders/hooks/mdx.js +30 -0
  46. package/lib/cjs/server/loaders/hooks/svelte.js +65 -0
  47. package/lib/cjs/server/loaders/webpack/compile.js +269 -0
  48. package/lib/cjs/server/loaders/webpack/creevey-loader.js +172 -0
  49. package/lib/cjs/server/loaders/webpack/dummy-hmr.js +39 -0
  50. package/lib/cjs/server/loaders/webpack/mdx-loader.js +72 -0
  51. package/lib/cjs/server/loaders/webpack/start.js +41 -0
  52. package/lib/cjs/server/logger.js +48 -0
  53. package/lib/cjs/server/master/api.js +71 -0
  54. package/lib/cjs/server/master/index.js +152 -0
  55. package/lib/cjs/server/master/master.js +57 -0
  56. package/lib/cjs/server/master/pool.js +197 -0
  57. package/lib/cjs/server/master/runner.js +281 -0
  58. package/lib/cjs/server/master/server.js +131 -0
  59. package/lib/cjs/server/messages.js +264 -0
  60. package/lib/cjs/server/selenium/browser.js +667 -0
  61. package/lib/cjs/server/selenium/index.js +31 -0
  62. package/lib/cjs/server/selenium/selenoid.js +172 -0
  63. package/lib/cjs/server/stories.js +155 -0
  64. package/lib/cjs/server/storybook/entry.js +55 -0
  65. package/lib/cjs/server/storybook/helpers.js +158 -0
  66. package/lib/cjs/server/storybook/providers/browser.js +76 -0
  67. package/lib/cjs/server/storybook/providers/nodejs.js +239 -0
  68. package/lib/cjs/server/update.js +79 -0
  69. package/lib/cjs/server/utils.js +169 -0
  70. package/lib/cjs/server/worker/chai-image.js +142 -0
  71. package/lib/cjs/server/worker/helpers.js +69 -0
  72. package/lib/cjs/server/worker/index.js +15 -0
  73. package/lib/cjs/server/worker/reporter.js +108 -0
  74. package/lib/cjs/server/worker/worker.js +268 -0
  75. package/lib/cjs/shared/index.js +103 -0
  76. package/lib/cjs/shared/serializeRegExp.js +42 -0
  77. package/lib/cjs/types.js +77 -0
  78. package/lib/esm/cli.js +4 -0
  79. package/lib/esm/client/addon/Manager.js +252 -0
  80. package/lib/esm/client/addon/components/Addon.js +39 -0
  81. package/lib/esm/client/addon/components/Icons.js +31 -0
  82. package/lib/esm/client/addon/components/Panel.js +53 -0
  83. package/lib/esm/client/addon/components/TestSelect.js +51 -0
  84. package/lib/esm/client/addon/components/Tools.js +76 -0
  85. package/lib/esm/client/addon/decorator.js +2 -0
  86. package/lib/esm/client/addon/index.js +2 -0
  87. package/lib/esm/client/addon/preset.ie11.js +59 -0
  88. package/lib/esm/client/addon/preset.js +41 -0
  89. package/lib/esm/client/addon/readyForCapture.js +5 -0
  90. package/lib/esm/client/addon/register.js +53 -0
  91. package/lib/esm/client/addon/utils.js +32 -0
  92. package/lib/esm/client/addon/withCreevey.js +326 -0
  93. package/lib/esm/client/shared/components/ImagesView/BlendView.js +67 -0
  94. package/lib/esm/client/shared/components/ImagesView/ImagesView.js +69 -0
  95. package/lib/esm/client/shared/components/ImagesView/SideBySideView.js +131 -0
  96. package/lib/esm/client/shared/components/ImagesView/SlideView.js +143 -0
  97. package/lib/esm/client/shared/components/ImagesView/SwapView.js +71 -0
  98. package/lib/esm/client/shared/components/ImagesView/index.js +5 -0
  99. package/lib/esm/client/shared/components/PageFooter/PageFooter.js +36 -0
  100. package/lib/esm/client/shared/components/PageFooter/Paging.js +80 -0
  101. package/lib/esm/client/shared/components/PageHeader/ImagePreview.js +68 -0
  102. package/lib/esm/client/shared/components/PageHeader/PageHeader.js +97 -0
  103. package/lib/esm/client/shared/components/ResultsPage.js +115 -0
  104. package/lib/esm/client/shared/creeveyClientApi.js +67 -0
  105. package/lib/esm/client/shared/helpers.js +353 -0
  106. package/lib/esm/client/shared/viewMode.js +6 -0
  107. package/lib/esm/creevey.js +54 -0
  108. package/lib/esm/index.js +3 -0
  109. package/lib/esm/server/config.js +70 -0
  110. package/lib/esm/server/docker.js +123 -0
  111. package/lib/esm/server/extract.js +32 -0
  112. package/lib/esm/server/index.js +64 -0
  113. package/lib/esm/server/loaders/babel/creevey-plugin.js +72 -0
  114. package/lib/esm/server/loaders/babel/helpers.js +452 -0
  115. package/lib/esm/server/loaders/babel/register.js +103 -0
  116. package/lib/esm/server/loaders/hooks/mdx.js +15 -0
  117. package/lib/esm/server/loaders/hooks/svelte.js +49 -0
  118. package/lib/esm/server/loaders/webpack/compile.js +246 -0
  119. package/lib/esm/server/loaders/webpack/creevey-loader.js +152 -0
  120. package/lib/esm/server/loaders/webpack/dummy-hmr.js +32 -0
  121. package/lib/esm/server/loaders/webpack/mdx-loader.js +58 -0
  122. package/lib/esm/server/loaders/webpack/start.js +27 -0
  123. package/lib/esm/server/logger.js +20 -0
  124. package/lib/esm/server/master/api.js +60 -0
  125. package/lib/esm/server/master/index.js +131 -0
  126. package/lib/esm/server/master/master.js +38 -0
  127. package/lib/esm/server/master/pool.js +176 -0
  128. package/lib/esm/server/master/runner.js +259 -0
  129. package/lib/esm/server/master/server.js +107 -0
  130. package/lib/esm/server/messages.js +232 -0
  131. package/lib/esm/server/selenium/browser.js +634 -0
  132. package/lib/esm/server/selenium/index.js +2 -0
  133. package/lib/esm/server/selenium/selenoid.js +149 -0
  134. package/lib/esm/server/stories.js +137 -0
  135. package/lib/esm/server/storybook/entry.js +29 -0
  136. package/lib/esm/server/storybook/helpers.js +99 -0
  137. package/lib/esm/server/storybook/providers/browser.js +60 -0
  138. package/lib/esm/server/storybook/providers/nodejs.js +219 -0
  139. package/lib/esm/server/update.js +61 -0
  140. package/lib/esm/server/utils.js +128 -0
  141. package/lib/esm/server/worker/chai-image.js +130 -0
  142. package/lib/esm/server/worker/helpers.js +60 -0
  143. package/lib/esm/server/worker/index.js +1 -0
  144. package/lib/esm/server/worker/reporter.js +86 -0
  145. package/lib/esm/server/worker/worker.js +238 -0
  146. package/lib/esm/shared/index.js +80 -0
  147. package/lib/esm/shared/serializeRegExp.js +24 -0
  148. package/lib/esm/types.js +46 -0
  149. package/lib/types/cli.d.ts +1 -0
  150. package/lib/types/client/addon/Manager.d.ts +37 -0
  151. package/lib/types/client/addon/components/Addon.d.ts +9 -0
  152. package/lib/types/client/addon/components/Icons.d.ts +8 -0
  153. package/lib/types/client/addon/components/Panel.d.ts +10 -0
  154. package/lib/types/client/addon/components/TestSelect.d.ts +9 -0
  155. package/lib/types/client/addon/components/Tools.d.ts +7 -0
  156. package/lib/types/client/addon/decorator.d.ts +1 -0
  157. package/lib/types/client/addon/index.d.ts +2 -0
  158. package/lib/types/client/addon/preset.d.ts +23 -0
  159. package/lib/types/client/addon/preset.ie11.d.ts +10 -0
  160. package/lib/types/client/addon/readyForCapture.d.ts +6 -0
  161. package/lib/types/client/addon/register.d.ts +3 -0
  162. package/lib/types/client/addon/utils.d.ts +3 -0
  163. package/lib/types/client/addon/withCreevey.d.ts +24 -0
  164. package/lib/types/client/shared/components/ImagesView/BlendView.d.ts +5 -0
  165. package/lib/types/client/shared/components/ImagesView/ImagesView.d.ts +25 -0
  166. package/lib/types/client/shared/components/ImagesView/SideBySideView.d.ts +5 -0
  167. package/lib/types/client/shared/components/ImagesView/SlideView.d.ts +5 -0
  168. package/lib/types/client/shared/components/ImagesView/SwapView.d.ts +5 -0
  169. package/lib/types/client/shared/components/ImagesView/index.d.ts +5 -0
  170. package/lib/types/client/shared/components/PageFooter/PageFooter.d.ts +9 -0
  171. package/lib/types/client/shared/components/PageFooter/Paging.d.ts +8 -0
  172. package/lib/types/client/shared/components/PageHeader/ImagePreview.d.ts +14 -0
  173. package/lib/types/client/shared/components/PageHeader/PageHeader.d.ts +17 -0
  174. package/lib/types/client/shared/components/ResultsPage.d.ts +20 -0
  175. package/lib/types/client/shared/creeveyClientApi.d.ts +9 -0
  176. package/lib/types/client/shared/helpers.d.ts +46 -0
  177. package/lib/types/client/shared/viewMode.d.ts +4 -0
  178. package/lib/types/client/web/CreeveyApp.d.ts +12 -0
  179. package/lib/types/client/web/CreeveyContext.d.ts +11 -0
  180. package/lib/types/client/web/CreeveyLoader.d.ts +3 -0
  181. package/lib/types/client/web/CreeveyView/SideBar/Checkbox.d.ts +22 -0
  182. package/lib/types/client/web/CreeveyView/SideBar/Search.d.ts +7 -0
  183. package/lib/types/client/web/CreeveyView/SideBar/SideBar.d.ts +14 -0
  184. package/lib/types/client/web/CreeveyView/SideBar/SideBarHeader.d.ts +13 -0
  185. package/lib/types/client/web/CreeveyView/SideBar/SuiteLink.d.ts +38 -0
  186. package/lib/types/client/web/CreeveyView/SideBar/TestLink.d.ts +8 -0
  187. package/lib/types/client/web/CreeveyView/SideBar/TestStatusIcon.d.ts +12 -0
  188. package/lib/types/client/web/CreeveyView/SideBar/TestsStatus.d.ts +11 -0
  189. package/lib/types/client/web/CreeveyView/SideBar/Toggle.d.ts +7 -0
  190. package/lib/types/client/web/CreeveyView/SideBar/index.d.ts +1 -0
  191. package/lib/types/client/web/KeyboardEventsContext.d.ts +13 -0
  192. package/lib/types/client/web/index.d.ts +4 -0
  193. package/lib/types/creevey.d.ts +1 -0
  194. package/lib/types/index.d.ts +2 -0
  195. package/lib/types/server/config.d.ts +4 -0
  196. package/lib/types/server/docker.d.ts +7 -0
  197. package/lib/types/server/extract.d.ts +2 -0
  198. package/lib/types/server/index.d.ts +2 -0
  199. package/lib/types/server/loaders/babel/creevey-plugin.d.ts +1 -0
  200. package/lib/types/server/loaders/babel/helpers.d.ts +19 -0
  201. package/lib/types/server/loaders/babel/register.d.ts +5 -0
  202. package/lib/types/server/loaders/hooks/mdx.d.ts +1 -0
  203. package/lib/types/server/loaders/hooks/svelte.d.ts +1 -0
  204. package/lib/types/server/loaders/webpack/compile.d.ts +2 -0
  205. package/lib/types/server/loaders/webpack/creevey-loader.d.ts +4 -0
  206. package/lib/types/server/loaders/webpack/dummy-hmr.d.ts +10 -0
  207. package/lib/types/server/loaders/webpack/mdx-loader.d.ts +6 -0
  208. package/lib/types/server/loaders/webpack/start.d.ts +1 -0
  209. package/lib/types/server/logger.d.ts +10 -0
  210. package/lib/types/server/master/api.d.ts +7 -0
  211. package/lib/types/server/master/index.d.ts +3 -0
  212. package/lib/types/server/master/master.d.ts +7 -0
  213. package/lib/types/server/master/pool.d.ts +31 -0
  214. package/lib/types/server/master/runner.d.ts +26 -0
  215. package/lib/types/server/master/server.d.ts +2 -0
  216. package/lib/types/server/messages.d.ts +29 -0
  217. package/lib/types/server/selenium/browser.d.ts +19 -0
  218. package/lib/types/server/selenium/index.d.ts +2 -0
  219. package/lib/types/server/selenium/selenoid.d.ts +3 -0
  220. package/lib/types/server/stories.d.ts +8 -0
  221. package/lib/types/server/storybook/entry.d.ts +16 -0
  222. package/lib/types/server/storybook/helpers.d.ts +24 -0
  223. package/lib/types/server/storybook/providers/browser.d.ts +2 -0
  224. package/lib/types/server/storybook/providers/nodejs.d.ts +6 -0
  225. package/lib/types/server/update.d.ts +2 -0
  226. package/lib/types/server/utils.d.ts +23 -0
  227. package/lib/types/server/worker/chai-image.d.ts +6 -0
  228. package/lib/types/server/worker/helpers.d.ts +8 -0
  229. package/lib/types/server/worker/index.d.ts +1 -0
  230. package/lib/types/server/worker/reporter.d.ts +8 -0
  231. package/lib/types/server/worker/worker.d.ts +4 -0
  232. package/lib/types/shared/index.d.ts +7 -0
  233. package/lib/types/shared/serializeRegExp.d.ts +9 -0
  234. package/lib/types/types.d.ts +486 -0
  235. package/package.json +1 -1
@@ -0,0 +1,252 @@
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
+ // eslint-disable-next-line @typescript-eslint/ban-ts-comment
4
+ //@ts-nocheck
5
+
6
+ /* eslint-disable */
7
+ import { SET_STORIES, STORY_RENDERED } from '@storybook/core-events';
8
+ import { denormalizeStoryParameters } from '../../shared';
9
+ import { isDefined } from '../../types';
10
+ import { initCreeveyClientApi } from '../shared/creeveyClientApi';
11
+ import { calcStatus } from '../shared/helpers';
12
+ import { ADDON_ID } from './register';
13
+ import { getEmojiByTestStatus } from './utils';
14
+ export class CreeveyManager {
15
+ constructor(storybookApi) {
16
+ this.storybookApi = storybookApi;
17
+
18
+ _defineProperty(this, "storyId", '');
19
+
20
+ _defineProperty(this, "activeBrowser", '');
21
+
22
+ _defineProperty(this, "selectedTestId", '');
23
+
24
+ _defineProperty(this, "status", {
25
+ isRunning: false,
26
+ tests: {},
27
+ browsers: []
28
+ });
29
+
30
+ _defineProperty(this, "creeveyApi", null);
31
+
32
+ _defineProperty(this, "stories", {});
33
+
34
+ _defineProperty(this, "updateStatusListeners", []);
35
+
36
+ _defineProperty(this, "changeTestListeners", []);
37
+
38
+ _defineProperty(this, "initAll", async () => {
39
+ this.storybookApi.on(STORY_RENDERED, this.onStoryRendered);
40
+ this.storybookApi.on(SET_STORIES, this.onSetStories);
41
+ this.creeveyApi = await initCreeveyClientApi();
42
+ this.creeveyApi.onUpdate(this.handleCreeveyUpdate);
43
+ this.status = await this.creeveyApi.status;
44
+ });
45
+
46
+ _defineProperty(this, "handleCreeveyUpdate", update => {
47
+ const {
48
+ tests,
49
+ removedTests = [],
50
+ isRunning
51
+ } = update;
52
+
53
+ if (isDefined(isRunning)) {
54
+ this.status.isRunning = isRunning;
55
+ }
56
+
57
+ if (isDefined(tests)) {
58
+ const prevTests = this.status.tests;
59
+ const prevStories = this.stories || {};
60
+ Object.values(tests).filter(isDefined).forEach(update => {
61
+ const {
62
+ id,
63
+ skip,
64
+ status,
65
+ results,
66
+ approved,
67
+ storyId
68
+ } = update;
69
+ const test = prevTests[id];
70
+
71
+ if (!test) {
72
+ return prevTests[id] = update;
73
+ }
74
+
75
+ if (isDefined(skip)) test.skip = skip;
76
+
77
+ if (isDefined(status)) {
78
+ test.status = status;
79
+
80
+ if (isDefined(storyId) && isDefined(prevStories[storyId])) {
81
+ const story = prevStories[storyId];
82
+ const storyStatus = this.getStoryTests(storyId);
83
+ const oldStatus = storyStatus.map(x => x.id === id ? status : x.status).reduce((oldStatus, newStatus) => calcStatus(oldStatus, newStatus), undefined);
84
+ story.name = this.addStatusToStoryName(story.name, calcStatus(oldStatus, status), skip || false);
85
+ }
86
+ }
87
+
88
+ if (isDefined(results)) test.results ? test.results.push(...results) : test.results = results;
89
+
90
+ if (isDefined(approved)) {
91
+ Object.entries(approved).forEach(_ref => {
92
+ let [image, retry] = _ref;
93
+ return retry !== undefined && test && ((test.approved = (test === null || test === void 0 ? void 0 : test.approved) || {})[image] = retry);
94
+ });
95
+ }
96
+ });
97
+ removedTests.forEach(_ref2 => {
98
+ let {
99
+ id
100
+ } = _ref2;
101
+ return delete prevTests[id];
102
+ });
103
+ this.status.tests = prevTests;
104
+ this.stories = prevStories;
105
+ this.setPanelsTitle();
106
+ void this.storybookApi.setStories(this.stories);
107
+ }
108
+
109
+ this.updateStatusListeners.forEach(x => x(update));
110
+ });
111
+
112
+ _defineProperty(this, "getCurrentTest", () => {
113
+ return this.status.tests[this.selectedTestId];
114
+ });
115
+
116
+ _defineProperty(this, "onStoryRendered", storyId => {
117
+ if (this.storyId === '') void this.addStatusesToSideBar();
118
+
119
+ if (this.storyId !== storyId) {
120
+ var _this$getTestsByStory, _this$getTestsByStory2;
121
+
122
+ this.storyId = storyId;
123
+ 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 : '';
124
+ this.setPanelsTitle();
125
+ this.changeTestListeners.forEach(x => x(this.selectedTestId));
126
+ }
127
+ });
128
+
129
+ _defineProperty(this, "onStart", () => {
130
+ var _this$creeveyApi;
131
+
132
+ (_this$creeveyApi = this.creeveyApi) === null || _this$creeveyApi === void 0 ? void 0 : _this$creeveyApi.start([this.selectedTestId]);
133
+ });
134
+
135
+ _defineProperty(this, "onStop", () => {
136
+ var _this$creeveyApi2;
137
+
138
+ (_this$creeveyApi2 = this.creeveyApi) === null || _this$creeveyApi2 === void 0 ? void 0 : _this$creeveyApi2.stop();
139
+ });
140
+
141
+ _defineProperty(this, "onImageApprove", (id, retry, image) => {
142
+ var _this$creeveyApi3;
143
+
144
+ return (_this$creeveyApi3 = this.creeveyApi) === null || _this$creeveyApi3 === void 0 ? void 0 : _this$creeveyApi3.approve(id, retry, image);
145
+ });
146
+
147
+ _defineProperty(this, "onStartAllStoryTests", () => {
148
+ var _this$creeveyApi4;
149
+
150
+ const ids = Object.values(this.status.tests).filter(isDefined).filter(x => x.storyId === this.storyId).map(x => x.id);
151
+ (_this$creeveyApi4 = this.creeveyApi) === null || _this$creeveyApi4 === void 0 ? void 0 : _this$creeveyApi4.start(ids);
152
+ });
153
+
154
+ _defineProperty(this, "onStartAllTests", () => {
155
+ var _this$creeveyApi5;
156
+
157
+ const ids = Object.values(this.status.tests).filter(isDefined).map(x => x.id);
158
+ (_this$creeveyApi5 = this.creeveyApi) === null || _this$creeveyApi5 === void 0 ? void 0 : _this$creeveyApi5.start(ids);
159
+ });
160
+
161
+ _defineProperty(this, "onSetStories", data => {
162
+ const stories = data.v ? denormalizeStoryParameters(data) : data.stories;
163
+ this.stories = stories;
164
+ });
165
+
166
+ _defineProperty(this, "setActiveBrowser", browser => {
167
+ var _this$getTestsByStory3, _this$getTestsByStory4;
168
+
169
+ this.activeBrowser = browser;
170
+ 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 : '';
171
+ this.changeTestListeners.forEach(x => x(this.selectedTestId));
172
+ });
173
+
174
+ _defineProperty(this, "setSelectedTestId", testId => {
175
+ this.selectedTestId = testId;
176
+ this.changeTestListeners.forEach(x => x(this.selectedTestId));
177
+ });
178
+
179
+ _defineProperty(this, "getStoryTests", storyId => {
180
+ if (!this.status || !this.status.tests) return [];
181
+ return Object.values(this.status.tests).filter(result => (result === null || result === void 0 ? void 0 : result.storyId) === storyId).filter(isDefined);
182
+ });
183
+
184
+ _defineProperty(this, "getBrowsers", () => {
185
+ return this.status.browsers;
186
+ });
187
+
188
+ _defineProperty(this, "getTestsByStoryIdAndBrowser", browser => {
189
+ return Object.values(this.status.tests).filter(x => (x === null || x === void 0 ? void 0 : x.browser) === browser && x.storyId === this.storyId).filter(isDefined);
190
+ });
191
+
192
+ _defineProperty(this, "getTabTitle", browser => {
193
+ const tests = this.getTestsByStoryIdAndBrowser(browser);
194
+ const browserStatus = tests.map(x => x && x.status).reduce((oldStatus, newStatus) => calcStatus(oldStatus, newStatus), undefined);
195
+ const browserSkip = tests.length > 0 ? tests.every(x => x && x.skip) : false;
196
+ const emojiStatus = getEmojiByTestStatus(browserStatus, browserSkip);
197
+ return "".concat(emojiStatus ? "".concat(emojiStatus, " ") : '', "Creevey/").concat(browser);
198
+ });
199
+
200
+ _defineProperty(this, "setPanelsTitle", () => {
201
+ var _this$storybookApi;
202
+
203
+ const panels = (_this$storybookApi = this.storybookApi) === null || _this$storybookApi === void 0 ? void 0 : _this$storybookApi.getPanels();
204
+ if (!panels) return;
205
+ let firstPanelBrowser = this.activeBrowser;
206
+
207
+ for (const p in panels) {
208
+ var _panel$id;
209
+
210
+ const panel = panels[p];
211
+
212
+ if (((_panel$id = panel.id) === null || _panel$id === void 0 ? void 0 : _panel$id.indexOf(ADDON_ID)) === 0 && panel.paramKey) {
213
+ panel.title = this.getTabTitle(panel.paramKey);
214
+ if (!firstPanelBrowser) firstPanelBrowser = panel.paramKey;
215
+ }
216
+ }
217
+
218
+ this.storybookApi.setSelectedPanel("".concat(ADDON_ID, "/panel/").concat(firstPanelBrowser));
219
+ });
220
+
221
+ this.storybookApi = storybookApi;
222
+ }
223
+
224
+ onUpdateStatus(listener) {
225
+ this.updateStatusListeners.push(listener);
226
+ return () => void (this.updateStatusListeners = this.updateStatusListeners.filter(x => x != listener));
227
+ }
228
+
229
+ onChangeTest(listener) {
230
+ this.changeTestListeners.push(listener);
231
+ return () => void (this.changeTestListeners = this.changeTestListeners.filter(x => x != listener));
232
+ }
233
+
234
+ async addStatusesToSideBar() {
235
+ if (!Object.keys(this.stories).length) return;
236
+ const stories = this.stories;
237
+ Object.keys(this.stories).forEach(storyId => {
238
+ const storyStatus = this.getStoryTests(storyId);
239
+ const status = storyStatus.map(x => x.status).reduce((oldStatus, newStatus) => calcStatus(oldStatus, newStatus), undefined);
240
+ const skip = storyStatus.length > 0 ? storyStatus.every(x => x.skip) : false;
241
+ this.stories[storyId].name = this.addStatusToStoryName(stories[storyId].name, status, skip);
242
+ });
243
+ await this.storybookApi.setStories(this.stories);
244
+ }
245
+
246
+ addStatusToStoryName(name, status, skip) {
247
+ name = name.replace(/^(❌|✔|🟡|🕗|⏸) /, '');
248
+ const emojiStatus = getEmojiByTestStatus(status, skip);
249
+ return "".concat(emojiStatus ? "".concat(emojiStatus, " ") : '', " ").concat(name);
250
+ }
251
+
252
+ }
@@ -0,0 +1,39 @@
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
+ };
@@ -0,0 +1,31 @@
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
+ };
@@ -0,0 +1,53 @@
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
+ };
@@ -0,0 +1,51 @@
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
+ }
@@ -0,0 +1,76 @@
1
+ // eslint-disable-next-line @typescript-eslint/ban-ts-comment
2
+ //@ts-nocheck
3
+ import React, { Fragment, useState, useEffect } from 'react';
4
+ import { IconButton, Icons, Separator } from '@storybook/components';
5
+ import { ForwardIcon, NextIcon } from './Icons';
6
+ import { stringify } from 'qs';
7
+ import { styled } from '@storybook/theming';
8
+ import { isDefined } from '../../../types';
9
+ import { getTestPath, useForceUpdate } from '../../shared/helpers';
10
+ const Button = styled(IconButton)({
11
+ '&:disabled': {
12
+ opacity: 0.5,
13
+ cursor: 'default'
14
+ },
15
+ '&:disabled:hover': {
16
+ color: 'inherit'
17
+ }
18
+ });
19
+ export const Tools = _ref => {
20
+ let {
21
+ manager
22
+ } = _ref;
23
+ const [buttonClicked, setButtonClicked] = useState();
24
+ const [isRunning, setRunning] = useState(manager.status.isRunning);
25
+ const forceUpdate = useForceUpdate();
26
+ const test = manager.getCurrentTest();
27
+ useEffect(() => {
28
+ const unsubscribe = manager.onChangeTest(() => {
29
+ forceUpdate();
30
+ });
31
+ return unsubscribe;
32
+ }, [manager, forceUpdate]);
33
+ useEffect(() => {
34
+ const unsubscribe = manager.onUpdateStatus(_ref2 => {
35
+ let {
36
+ isRunning
37
+ } = _ref2;
38
+ if (isDefined(isRunning)) setRunning(isRunning);
39
+ });
40
+ return unsubscribe;
41
+ }, [manager]);
42
+ if (!test) return null;
43
+
44
+ function renderButton(type, title, onClick, icon) {
45
+ const handleClick = () => {
46
+ setButtonClicked(type);
47
+ onClick();
48
+ };
49
+
50
+ const disabled = isRunning && buttonClicked != null && buttonClicked !== type;
51
+ return /*#__PURE__*/React.createElement(Button, {
52
+ onClick: () => {
53
+ isRunning ? manager.onStop() : handleClick();
54
+ },
55
+ title: disabled ? '' : title,
56
+ disabled: disabled
57
+ }, buttonClicked === type && isRunning ? /*#__PURE__*/React.createElement(Icons, {
58
+ icon: 'stop'
59
+ }) : icon);
60
+ }
61
+
62
+ return /*#__PURE__*/React.createElement(Fragment, null, /*#__PURE__*/React.createElement(IconButton, {
63
+ href: "http://localhost:".concat(__CREEVEY_CLIENT_PORT__ || __CREEVEY_SERVER_PORT__, "/?").concat(stringify({
64
+ testPath: getTestPath(test)
65
+ })),
66
+ target: "_blank",
67
+ title: "Show in Creevey UI"
68
+ }, /*#__PURE__*/React.createElement(Icons, {
69
+ icon: "sharealt"
70
+ })), /*#__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, {
71
+ width: 15,
72
+ height: 11
73
+ })), renderButton('RunTest', 'Run', manager.onStart, /*#__PURE__*/React.createElement(Icons, {
74
+ icon: "play"
75
+ })));
76
+ };
@@ -0,0 +1,2 @@
1
+ import { withCreevey } from './withCreevey';
2
+ export const decorators = [withCreevey()];
@@ -0,0 +1,2 @@
1
+ export * from './withCreevey';
2
+ export * from './readyForCapture';
@@ -0,0 +1,59 @@
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
+ };
@@ -0,0 +1,41 @@
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
+ }
@@ -0,0 +1,5 @@
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
+ }
@@ -0,0 +1,53 @@
1
+ // eslint-disable-next-line @typescript-eslint/ban-ts-comment
2
+ //@ts-nocheck
3
+ import { addons, types } from '@storybook/addons';
4
+ import React from 'react';
5
+ import { Addon } from './components/Addon';
6
+ import { Tools } from './components/Tools';
7
+ import { CreeveyManager } from './Manager';
8
+ export const ADDON_ID = 'creevey';
9
+ addons.register(ADDON_ID, api => {
10
+ void registerCreeveyPanels(api);
11
+ });
12
+ export async function registerCreeveyPanels(storybookApi) {
13
+ const manager = new CreeveyManager(storybookApi);
14
+ addons.addPanel("".concat(ADDON_ID, "/panel/run"), {
15
+ title: "Creevey/Run",
16
+ match: _ref => {
17
+ let {
18
+ viewMode
19
+ } = _ref;
20
+ return !!(viewMode && /^story$/.exec(viewMode));
21
+ },
22
+ type: types.TOOL,
23
+ // eslint-disable-next-line react/display-name
24
+ render: () => /*#__PURE__*/React.createElement(Tools, {
25
+ manager
26
+ })
27
+ });
28
+ await manager.initAll();
29
+ const browsers = manager.getBrowsers();
30
+ browsers.forEach(browser => {
31
+ const panelId = "".concat(ADDON_ID, "/panel/").concat(browser);
32
+ const title = manager.getTabTitle(browser);
33
+ addons.addPanel(panelId, {
34
+ title,
35
+ type: types.PANEL,
36
+ paramKey: browser,
37
+ // NOTE key = PANEL_ID needs to correct render button in addons panel
38
+ // eslint-disable-next-line react/display-name
39
+ render: _ref2 => {
40
+ let {
41
+ active,
42
+ key
43
+ } = _ref2;
44
+ return /*#__PURE__*/React.createElement(Addon, {
45
+ active,
46
+ key,
47
+ manager,
48
+ browser
49
+ });
50
+ }
51
+ });
52
+ });
53
+ }