creevey 0.9.0-beta.1 → 0.9.0-beta.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 (262) hide show
  1. package/CHANGELOG.md +33 -0
  2. package/README.md +9 -1
  3. package/addon/README.md +3 -0
  4. package/addon/package.json +4 -0
  5. package/docs/config.md +29 -26
  6. package/jest.config.js +6 -0
  7. package/lib/cjs/cli.js +5 -0
  8. package/lib/cjs/client/addon/Manager.js +264 -0
  9. package/lib/cjs/client/addon/components/Addon.js +55 -0
  10. package/lib/cjs/client/addon/components/Icons.js +46 -0
  11. package/lib/cjs/client/addon/components/Panel.js +72 -0
  12. package/lib/cjs/client/addon/components/TestSelect.js +65 -0
  13. package/lib/cjs/client/addon/components/Tools.js +95 -0
  14. package/lib/cjs/client/addon/decorator.js +11 -0
  15. package/lib/cjs/client/addon/index.js +31 -0
  16. package/lib/cjs/client/addon/preset.ie11.js +74 -0
  17. package/lib/cjs/client/addon/preset.js +62 -0
  18. package/lib/cjs/client/addon/readyForCapture.js +12 -0
  19. package/lib/cjs/client/addon/register.js +72 -0
  20. package/lib/cjs/client/addon/utils.js +42 -0
  21. package/lib/cjs/client/addon/withCreevey.js +350 -0
  22. package/lib/cjs/client/shared/components/ImagesView/BlendView.js +87 -0
  23. package/lib/cjs/client/shared/components/ImagesView/ImagesView.js +92 -0
  24. package/lib/cjs/client/shared/components/ImagesView/SideBySideView.js +154 -0
  25. package/lib/cjs/client/shared/components/ImagesView/SlideView.js +166 -0
  26. package/lib/cjs/client/shared/components/ImagesView/SwapView.js +91 -0
  27. package/lib/cjs/client/shared/components/ImagesView/index.js +45 -0
  28. package/lib/cjs/client/shared/components/PageFooter/PageFooter.js +50 -0
  29. package/lib/cjs/client/shared/components/PageFooter/Paging.js +94 -0
  30. package/lib/cjs/client/shared/components/PageHeader/ImagePreview.js +82 -0
  31. package/lib/cjs/client/shared/components/PageHeader/PageHeader.js +119 -0
  32. package/lib/cjs/client/shared/components/ResultsPage.js +143 -0
  33. package/lib/cjs/client/shared/creeveyClientApi.js +76 -0
  34. package/lib/cjs/client/shared/helpers.js +411 -0
  35. package/lib/cjs/client/shared/viewMode.js +17 -0
  36. package/lib/cjs/client/web/142.js +2 -0
  37. package/lib/cjs/client/web/142.js.LICENSE.txt +12 -0
  38. package/lib/cjs/client/web/32.js +1 -0
  39. package/lib/cjs/client/web/551.js +1 -0
  40. package/lib/cjs/client/web/566.js +2 -0
  41. package/lib/cjs/client/web/566.js.LICENSE.txt +31 -0
  42. package/lib/cjs/client/web/691.js +2 -0
  43. package/lib/cjs/client/web/691.js.LICENSE.txt +8 -0
  44. package/lib/cjs/client/web/725.js +1 -0
  45. package/lib/cjs/client/web/index.html +19 -0
  46. package/lib/cjs/client/web/main.js +2 -38
  47. package/lib/cjs/client/web/main.js.LICENSE.txt +49 -0
  48. package/lib/cjs/creevey.js +69 -0
  49. package/lib/cjs/index.js +62 -0
  50. package/lib/cjs/server/config.js +94 -0
  51. package/lib/cjs/server/docker.js +146 -0
  52. package/lib/cjs/server/extract.js +46 -0
  53. package/lib/cjs/server/index.js +83 -0
  54. package/lib/cjs/server/loaders/babel/creevey-plugin.js +86 -0
  55. package/lib/cjs/server/loaders/babel/helpers.js +469 -0
  56. package/lib/cjs/server/loaders/babel/register.js +124 -0
  57. package/lib/cjs/server/loaders/hooks/mdx.js +30 -0
  58. package/lib/cjs/server/loaders/hooks/svelte.js +65 -0
  59. package/lib/cjs/server/loaders/webpack/compile.js +269 -0
  60. package/lib/cjs/server/loaders/webpack/creevey-loader.js +172 -0
  61. package/lib/cjs/server/loaders/webpack/dummy-hmr.js +39 -0
  62. package/lib/cjs/server/loaders/webpack/mdx-loader.js +72 -0
  63. package/lib/cjs/server/loaders/webpack/start.js +41 -0
  64. package/lib/cjs/server/logger.js +48 -0
  65. package/lib/cjs/server/master/api.js +71 -0
  66. package/lib/cjs/server/master/index.js +146 -0
  67. package/lib/cjs/server/master/master.js +57 -0
  68. package/lib/cjs/server/master/pool.js +197 -0
  69. package/lib/cjs/server/master/runner.js +281 -0
  70. package/lib/cjs/server/master/server.js +131 -0
  71. package/lib/cjs/server/messages.js +264 -0
  72. package/lib/cjs/server/selenium/browser.js +656 -0
  73. package/lib/cjs/server/selenium/index.js +31 -0
  74. package/lib/cjs/server/selenium/selenoid.js +172 -0
  75. package/lib/cjs/server/stories.js +153 -0
  76. package/lib/cjs/server/storybook/entry.js +53 -0
  77. package/lib/cjs/server/storybook/helpers.js +158 -0
  78. package/lib/cjs/server/storybook/providers/browser.js +74 -0
  79. package/lib/cjs/server/storybook/providers/hybrid.js +84 -0
  80. package/lib/cjs/server/storybook/providers/nodejs.js +237 -0
  81. package/lib/cjs/server/testsFiles/parser.js +72 -0
  82. package/lib/cjs/server/testsFiles/register.js +48 -0
  83. package/lib/cjs/server/update.js +79 -0
  84. package/lib/cjs/server/utils.js +176 -0
  85. package/lib/cjs/server/worker/chai-image.js +142 -0
  86. package/lib/cjs/server/worker/helpers.js +69 -0
  87. package/lib/cjs/server/worker/index.js +15 -0
  88. package/lib/cjs/server/worker/reporter.js +108 -0
  89. package/lib/cjs/server/worker/worker.js +268 -0
  90. package/lib/cjs/shared/index.js +101 -0
  91. package/lib/cjs/shared/serializeRegExp.js +42 -0
  92. package/lib/cjs/types.js +74 -0
  93. package/lib/esm/cli.js +4 -0
  94. package/lib/esm/client/addon/Manager.js +248 -0
  95. package/lib/esm/client/addon/components/Addon.js +39 -0
  96. package/lib/esm/client/addon/components/Icons.js +31 -0
  97. package/lib/esm/client/addon/components/Panel.js +53 -0
  98. package/lib/esm/client/addon/components/TestSelect.js +51 -0
  99. package/lib/esm/client/addon/components/Tools.js +74 -0
  100. package/lib/esm/client/addon/decorator.js +2 -0
  101. package/lib/esm/client/addon/index.js +2 -0
  102. package/lib/esm/client/addon/preset.ie11.js +59 -0
  103. package/lib/esm/client/addon/preset.js +41 -0
  104. package/lib/esm/client/addon/readyForCapture.js +5 -0
  105. package/lib/esm/client/addon/register.js +51 -0
  106. package/lib/esm/client/addon/utils.js +32 -0
  107. package/lib/esm/client/addon/withCreevey.js +323 -0
  108. package/lib/esm/client/shared/components/ImagesView/BlendView.js +67 -0
  109. package/lib/esm/client/shared/components/ImagesView/ImagesView.js +69 -0
  110. package/lib/esm/client/shared/components/ImagesView/SideBySideView.js +131 -0
  111. package/lib/esm/client/shared/components/ImagesView/SlideView.js +143 -0
  112. package/lib/esm/client/shared/components/ImagesView/SwapView.js +71 -0
  113. package/lib/esm/client/shared/components/ImagesView/index.js +5 -0
  114. package/lib/esm/client/shared/components/PageFooter/PageFooter.js +36 -0
  115. package/lib/esm/client/shared/components/PageFooter/Paging.js +80 -0
  116. package/lib/esm/client/shared/components/PageHeader/ImagePreview.js +68 -0
  117. package/lib/esm/client/shared/components/PageHeader/PageHeader.js +97 -0
  118. package/lib/esm/client/shared/components/ResultsPage.js +115 -0
  119. package/lib/esm/client/shared/creeveyClientApi.js +67 -0
  120. package/lib/esm/client/shared/helpers.js +353 -0
  121. package/lib/esm/client/shared/viewMode.js +6 -0
  122. package/lib/esm/creevey.js +54 -0
  123. package/lib/esm/index.js +5 -0
  124. package/lib/esm/server/config.js +71 -0
  125. package/lib/esm/server/docker.js +123 -0
  126. package/lib/esm/server/extract.js +32 -0
  127. package/lib/esm/server/index.js +64 -0
  128. package/lib/esm/server/loaders/babel/creevey-plugin.js +72 -0
  129. package/lib/esm/server/loaders/babel/helpers.js +452 -0
  130. package/lib/esm/server/loaders/babel/register.js +103 -0
  131. package/lib/esm/server/loaders/hooks/mdx.js +15 -0
  132. package/lib/esm/server/loaders/hooks/svelte.js +49 -0
  133. package/lib/esm/server/loaders/webpack/compile.js +246 -0
  134. package/lib/esm/server/loaders/webpack/creevey-loader.js +152 -0
  135. package/lib/esm/server/loaders/webpack/dummy-hmr.js +32 -0
  136. package/lib/esm/server/loaders/webpack/mdx-loader.js +58 -0
  137. package/lib/esm/server/loaders/webpack/start.js +27 -0
  138. package/lib/esm/server/logger.js +20 -0
  139. package/lib/esm/server/master/api.js +60 -0
  140. package/lib/esm/server/master/index.js +125 -0
  141. package/lib/esm/server/master/master.js +38 -0
  142. package/lib/esm/server/master/pool.js +176 -0
  143. package/lib/esm/server/master/runner.js +259 -0
  144. package/lib/esm/server/master/server.js +107 -0
  145. package/lib/esm/server/messages.js +232 -0
  146. package/lib/esm/server/selenium/browser.js +623 -0
  147. package/lib/esm/server/selenium/index.js +2 -0
  148. package/lib/esm/server/selenium/selenoid.js +149 -0
  149. package/lib/esm/server/stories.js +135 -0
  150. package/lib/esm/server/storybook/entry.js +27 -0
  151. package/lib/esm/server/storybook/helpers.js +97 -0
  152. package/lib/esm/server/storybook/providers/browser.js +60 -0
  153. package/lib/esm/server/storybook/providers/hybrid.js +64 -0
  154. package/lib/esm/server/storybook/providers/nodejs.js +216 -0
  155. package/lib/esm/server/testsFiles/parser.js +50 -0
  156. package/lib/esm/server/testsFiles/register.js +35 -0
  157. package/lib/esm/server/update.js +61 -0
  158. package/lib/esm/server/utils.js +133 -0
  159. package/lib/esm/server/worker/chai-image.js +130 -0
  160. package/lib/esm/server/worker/helpers.js +60 -0
  161. package/lib/esm/server/worker/index.js +1 -0
  162. package/lib/esm/server/worker/reporter.js +86 -0
  163. package/lib/esm/server/worker/worker.js +238 -0
  164. package/lib/esm/shared/index.js +78 -0
  165. package/lib/esm/shared/serializeRegExp.js +24 -0
  166. package/lib/esm/types.js +43 -0
  167. package/lib/types/cli.d.ts +1 -1
  168. package/lib/types/client/addon/Manager.d.ts +37 -37
  169. package/lib/types/client/addon/components/Addon.d.ts +8 -8
  170. package/lib/types/client/addon/components/Icons.d.ts +7 -7
  171. package/lib/types/client/addon/components/Panel.d.ts +9 -9
  172. package/lib/types/client/addon/components/TestSelect.d.ts +8 -9
  173. package/lib/types/client/addon/components/Tools.d.ts +6 -6
  174. package/lib/types/client/addon/decorator.d.ts +1 -1
  175. package/lib/types/client/addon/index.d.ts +2 -0
  176. package/lib/types/client/addon/preset.d.ts +23 -24
  177. package/lib/types/client/addon/preset.ie11.d.ts +10 -0
  178. package/lib/types/client/addon/readyForCapture.d.ts +6 -6
  179. package/lib/types/client/addon/register.d.ts +3 -3
  180. package/lib/types/client/addon/utils.d.ts +3 -2
  181. package/lib/types/client/addon/withCreevey.d.ts +24 -24
  182. package/lib/types/client/shared/components/ImagesView/BlendView.d.ts +3 -3
  183. package/lib/types/client/shared/components/ImagesView/ImagesView.d.ts +24 -25
  184. package/lib/types/client/shared/components/ImagesView/SideBySideView.d.ts +3 -3
  185. package/lib/types/client/shared/components/ImagesView/SlideView.d.ts +3 -3
  186. package/lib/types/client/shared/components/ImagesView/SwapView.d.ts +3 -3
  187. package/lib/types/client/shared/components/ImagesView/index.d.ts +5 -5
  188. package/lib/types/client/shared/components/PageFooter/PageFooter.d.ts +8 -9
  189. package/lib/types/client/shared/components/PageFooter/Paging.d.ts +7 -8
  190. package/lib/types/client/shared/components/PageHeader/ImagePreview.d.ts +12 -12
  191. package/lib/types/client/shared/components/PageHeader/PageHeader.d.ts +16 -17
  192. package/lib/types/client/shared/components/ResultsPage.d.ts +18 -18
  193. package/lib/types/client/shared/creeveyClientApi.d.ts +9 -9
  194. package/lib/types/client/shared/helpers.d.ts +46 -46
  195. package/lib/types/client/shared/viewMode.d.ts +4 -4
  196. package/lib/types/client/web/CreeveyApp.d.ts +11 -12
  197. package/lib/types/client/web/CreeveyContext.d.ts +11 -11
  198. package/lib/types/client/web/CreeveyLoader.d.ts +2 -3
  199. package/lib/types/client/web/CreeveyView/SideBar/Checkbox.d.ts +19 -19
  200. package/lib/types/client/web/CreeveyView/SideBar/Search.d.ts +6 -6
  201. package/lib/types/client/web/CreeveyView/SideBar/SideBar.d.ts +14 -14
  202. package/lib/types/client/web/CreeveyView/SideBar/SideBarHeader.d.ts +12 -13
  203. package/lib/types/client/web/CreeveyView/SideBar/SuiteLink.d.ts +33 -33
  204. package/lib/types/client/web/CreeveyView/SideBar/TestLink.d.ts +7 -8
  205. package/lib/types/client/web/CreeveyView/SideBar/TestStatusIcon.d.ts +10 -10
  206. package/lib/types/client/web/CreeveyView/SideBar/TestsStatus.d.ts +9 -9
  207. package/lib/types/client/web/CreeveyView/SideBar/Toggle.d.ts +6 -6
  208. package/lib/types/client/web/CreeveyView/SideBar/index.d.ts +1 -1
  209. package/lib/types/client/web/KeyboardEventsContext.d.ts +13 -13
  210. package/lib/types/client/web/index.d.ts +4 -4
  211. package/lib/types/creevey.d.ts +1 -1
  212. package/lib/types/index.d.ts +1 -4
  213. package/lib/types/server/config.d.ts +4 -4
  214. package/lib/types/server/docker.d.ts +7 -7
  215. package/lib/types/server/extract.d.ts +2 -2
  216. package/lib/types/server/index.d.ts +2 -2
  217. package/lib/types/server/loaders/babel/creevey-plugin.d.ts +1 -1
  218. package/lib/types/server/loaders/babel/helpers.d.ts +19 -19
  219. package/lib/types/server/loaders/babel/register.d.ts +5 -5
  220. package/lib/types/server/loaders/hooks/mdx.d.ts +1 -1
  221. package/lib/types/server/loaders/hooks/svelte.d.ts +1 -1
  222. package/lib/types/server/loaders/webpack/compile.d.ts +2 -2
  223. package/lib/types/server/loaders/webpack/creevey-loader.d.ts +4 -2
  224. package/lib/types/server/loaders/webpack/dummy-hmr.d.ts +10 -10
  225. package/lib/types/server/loaders/webpack/mdx-loader.d.ts +6 -6
  226. package/lib/types/server/loaders/webpack/start.d.ts +1 -1
  227. package/lib/types/server/logger.d.ts +10 -6
  228. package/lib/types/server/master/api.d.ts +7 -7
  229. package/lib/types/server/master/index.d.ts +3 -3
  230. package/lib/types/server/master/master.d.ts +7 -7
  231. package/lib/types/server/master/pool.d.ts +31 -31
  232. package/lib/types/server/master/runner.d.ts +26 -26
  233. package/lib/types/server/master/server.d.ts +2 -2
  234. package/lib/types/server/messages.d.ts +27 -27
  235. package/lib/types/server/selenium/browser.d.ts +17 -17
  236. package/lib/types/server/selenium/index.d.ts +2 -2
  237. package/lib/types/server/selenium/selenoid.d.ts +3 -3
  238. package/lib/types/server/stories.d.ts +8 -8
  239. package/lib/types/server/storybook/entry.d.ts +17 -18
  240. package/lib/types/server/storybook/helpers.d.ts +24 -24
  241. package/lib/types/server/storybook/providers/browser.d.ts +4 -4
  242. package/lib/types/server/storybook/providers/hybrid.d.ts +4 -4
  243. package/lib/types/server/storybook/providers/nodejs.d.ts +9 -9
  244. package/lib/types/server/testsFiles/parser.d.ts +12 -12
  245. package/lib/types/server/testsFiles/register.d.ts +2 -2
  246. package/lib/types/server/update.d.ts +2 -2
  247. package/lib/types/server/utils.d.ts +24 -20
  248. package/lib/types/server/worker/chai-image.d.ts +6 -6
  249. package/lib/types/server/worker/helpers.d.ts +8 -8
  250. package/lib/types/server/worker/index.d.ts +1 -1
  251. package/lib/types/server/worker/reporter.d.ts +8 -8
  252. package/lib/types/server/worker/worker.d.ts +4 -4
  253. package/lib/types/{shared.d.ts → shared/index.d.ts} +7 -16
  254. package/lib/types/shared/serializeRegExp.d.ts +9 -0
  255. package/lib/types/types.d.ts +489 -489
  256. package/package.json +114 -102
  257. package/preset/ie11.js +5 -0
  258. package/{preset.js → preset/index.js} +2 -2
  259. package/types/mdx.d.ts +3 -2
  260. package/lib/cjs/client/web/1.js +0 -13
  261. package/lib/cjs/client/web/2.js +0 -1
  262. package/storybook-static/stories.json +0 -21
package/CHANGELOG.md CHANGED
@@ -1,3 +1,36 @@
1
+ # [0.9.0-beta.3](https://github.com/wKich/creevey/compare/v0.8.0...v0.9.0-beta.3) (2023-03-24)
2
+
3
+ ### Features
4
+
5
+ - hybrid stories provider ([89d9c73](https://github.com/wKich/creevey/commit/89d9c7357369dffb320ea06fe158b4113f57034c))
6
+
7
+ # [0.8.0](https://github.com/wKich/creevey/compare/v0.8.0-beta.1...v0.8.0) (2023-03-07)
8
+
9
+ ### Bug Fixes
10
+
11
+ - drop support of SkipOption on root skip level ([31be1bf](https://github.com/wKich/creevey/commit/31be1bf4d67f464ea6790e6e218ca75674366711))
12
+
13
+ # [0.8.0-beta.1](https://github.com/wKich/creevey/compare/v0.8.0-beta.0...v0.8.0-beta.1) (2023-01-18)
14
+
15
+ ### Bug Fixes
16
+
17
+ - **addon:** restore IE11 support ([94f452f](https://github.com/wKich/creevey/commit/94f452fff4225e974c9efdff21f982d5155de4f8))
18
+ - allow setting timeouts via capabilities ([72de9e5](https://github.com/wKich/creevey/commit/72de9e50b818587309f665c782637ae43c3e4864))
19
+ - infinite UI loading ([4f7b47d](https://github.com/wKich/creevey/commit/4f7b47db3ff1274217b044ce608e34d22148fe32))
20
+ - **addon:** restore and move ie11 support to separate addon ([3ba2cc7](https://github.com/wKich/creevey/commit/3ba2cc7fde281037406f1705c0abc616c576e641))
21
+ - browser-node regexp parameters transfering ([737670e](https://github.com/wKich/creevey/commit/737670e18aa5d0ce416fe12b765406116b453e31))
22
+ - correct call of the test fn ([98c03ad](https://github.com/wKich/creevey/commit/98c03ad1700486bfd75170f4517970717250f6d8))
23
+ - handle null from selectStory ([1895602](https://github.com/wKich/creevey/commit/1895602143b3236ab195e11fcfa162df2a01af03))
24
+ - ie11 support ([523e35b](https://github.com/wKich/creevey/commit/523e35b6950d978ca3aaa77dd4f072a835053687))
25
+ - move addon to the separate entry point ([f3fc59f](https://github.com/wKich/creevey/commit/f3fc59f980a56f87f882507c3a0367ed6a356d33))
26
+ - prevent importing browser-specific code to node ([37706ef](https://github.com/wKich/creevey/commit/37706efbb49dd5bd1d6ec06821fac52480a0e132))
27
+ - **selenium-webdriver:** bump [@types](https://github.com/types) package version ([ca4b369](https://github.com/wKich/creevey/commit/ca4b369046e2c56e0548f5cbb6f98c17b0125228))
28
+
29
+ ### Features
30
+
31
+ - 🎸 add support `play()` story method ([318ac62](https://github.com/wKich/creevey/commit/318ac628cb14fb0de7a89c088ae241df520df1e7))
32
+ - drop support for storybook < 6.4 ([fb8c0f5](https://github.com/wKich/creevey/commit/fb8c0f5158ab7c0495949eaa61ba52049c3d66cf))
33
+
1
34
  # [0.8.0-beta.0](https://github.com/wKich/creevey/compare/v0.7.39...v0.8.0-beta.0) (2022-03-17)
2
35
 
3
36
  ### Bug Fixes
package/README.md CHANGED
@@ -1,9 +1,12 @@
1
- # 📸+👦🏼 [Creevey](https://harrypotter.fandom.com/wiki/Colin_Creevey)
1
+ [<img width="274" alt="Creevey" src="https://user-images.githubusercontent.com/4607770/220418756-89cf4f54-ccb7-4086-a74c-a044ea1d2a61.png">](https://harrypotter.fandom.com/wiki/Colin_Creevey)
2
+
3
+ **IMPORTANT** _Looking for any help with maintaining_
2
4
 
3
5
  Cross-browser screenshot testing tool for [Storybook](https://storybook.js.org/) with fancy UI Runner.
4
6
 
5
7
  [![Creevey downloads](https://img.shields.io/npm/dt/creevey)](https://www.npmjs.com/package/creevey)
6
8
  [![Commitizen friendly](https://img.shields.io/badge/commitizen-friendly-brightgreen.svg)](http://commitizen.github.io/cz-cli/)
9
+ [![FOSSA Status](https://app.fossa.com/api/projects/git%2Bgithub.com%2FwKich%2Fcreevey.svg?type=shield)](https://app.fossa.com/projects/git%2Bgithub.com%2FwKich%2Fcreevey?ref=badge_shield)
7
10
 
8
11
  ![Creevey Demo](https://user-images.githubusercontent.com/6397708/100863723-cd6b8500-34b6-11eb-94e1-849590bc8066.gif)
9
12
 
@@ -37,6 +40,7 @@ It named after [Colin Creevey](https://harrypotter.fandom.com/wiki/Colin_Creevey
37
40
  ## Pre-requisites
38
41
 
39
42
  - Make sure you have installed [Docker](https://www.docker.com/products/docker-desktop). But if you going to use your own separate Selenium Grid, you don't need `Docker`.
43
+ - Supported Storybook versions: `^6.4.0`.
40
44
 
41
45
  ## How to start
42
46
 
@@ -145,3 +149,7 @@ Because tests defined in story parameters and `selenium-webdriver` depends on no
145
149
 
146
150
  | [![Whisk](https://raw.githubusercontent.com/wKich/creevey/master/.github/images/whisk.svg)](https://whisk.com/) | [![SKB Kontur](https://kontur.ru/Files/userfiles/image/brandbook/logo-skb-kontur-eng.png)](https://kontur.ru/) | [![ABBYY](https://raw.githubusercontent.com/wKich/creevey/master/.github/images/abbyy.svg)](https://www.abbyy.com/) |
147
151
  | --------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------- |
152
+
153
+ ## License
154
+
155
+ [![FOSSA Status](https://app.fossa.com/api/projects/git%2Bgithub.com%2FwKich%2Fcreevey.svg?type=large)](https://app.fossa.com/projects/git%2Bgithub.com%2FwKich%2Fcreevey?ref=badge_large)
@@ -0,0 +1,3 @@
1
+ This is a fallback for package.json's `exports.addon` field. It's required for outdated environments (like node 11 and typescript with the "node" moduleResolution) to resolve imports from `creevey/addon` properly.
2
+
3
+ See https://github.com/andrewbranch/example-subpath-exports-ts-compat. The fallback uses the "package-json-redirects" startegy.
@@ -0,0 +1,4 @@
1
+ {
2
+ "main": "../lib/cjs/client/addon/index.js",
3
+ "types": "../lib/types/client/addon/index.d.ts"
4
+ }
package/docs/config.md CHANGED
@@ -120,7 +120,7 @@ export const parameters = {
120
120
  creevey: {
121
121
  // Skip all *hover tests in IE11 on the global level
122
122
  skip: {
123
- ie11: { in: 'ie11', tests: /.*hover$/ },
123
+ "hovers don't work in ie11": { in: 'ie11', tests: /.*hover$/ },
124
124
  },
125
125
  },
126
126
  };
@@ -137,15 +137,14 @@ export default {
137
137
  parameters: {
138
138
  creevey: {
139
139
  // You could skip some browsers/stories or even specific tests
140
- skip: [
141
- { in: 'ie11', reason: "`MyComponent` doesn't support ie11" },
142
- { in: 'firefox', stories: 'Loading', reason: "Loading stories are flaky in firefox" },
143
- {
140
+ skip: {
141
+ "`MyComponent` doesn't support ie11": { in: 'ie11' },
142
+ "Loading stories are flaky in firefox": { in: 'firefox', stories: 'Loading' },
143
+ "`MyComponent` hovering doesn't work correctly": {
144
144
  in: ['firefox', 'chrome'],
145
145
  tests: /.*hover$/,
146
- reason: "For some reason `MyComponent` hovering doesn't work correctly",
147
146
  },
148
- ],
147
+ },
149
148
  },
150
149
  },
151
150
  } as Meta & CreeveyMeta;
@@ -169,43 +168,47 @@ Basic.parameters = {
169
168
 
170
169
  ```ts
171
170
  interface SkipOption {
172
- reason?: string;
173
171
  in?: string | string[] | RegExp;
174
172
  kinds?: string | string[] | RegExp;
175
173
  stories?: string | string[] | RegExp;
176
174
  tests?: string | string[] | RegExp;
177
175
  }
178
176
 
179
- type SkipOptions = SkipOption | SkipOption[] | Record<string, SkipOption | SkipOption[]>;
177
+ type SkipOptions = boolean | string | Record<string, SkipOption | SkipOption[]>;
180
178
  ```
181
179
 
182
180
  - Skip all stories for all browsers:
183
181
  - `skip: true`
184
182
  - `skip: 'Skip reason message'`
185
- - `skip: { reason: 'Skip reason message' }`
183
+ - `skip: { 'Skip reason message': true }`
186
184
  - Skip all stories for specific browsers:
187
- - `skip: { in: 'ie11' }`
188
- - `skip: { in: ['ie11', 'chrome'] }`
189
- - `skip: { in: /^fire.*/ }`
185
+ - `skip: { 'Skip reason message': { in: 'ie11' } }`
186
+ - `skip: { 'Skip reason message': { in: ['ie11', 'chrome'] } }`
187
+ - `skip: { 'Skip reason message': { in: /^fire.*/ } }`
190
188
  - Skip all stories in specific kinds:
191
- - `skip: { kinds: 'Button' }`
192
- - `skip: { kinds: ['Button', 'Input'] }`
193
- - `skip: { kinds: /.*Modal$/ }`
189
+ - `skip: { 'Skip reason message': { kinds: 'Button' } }`
190
+ - `skip: { 'Skip reason message': { kinds: ['Button', 'Input'] } }`
191
+ - `skip: { 'Skip reason message': { kinds: /.*Modal$/ } }`
194
192
  - Skip all tests in specific stories:
195
- - `skip: { stories: 'simple' }`
196
- - `skip: { stories: ['simple', 'special'] }`
197
- - `skip: { stories: /.*large$/ }`
193
+ - `skip: { 'Skip reason message': { stories: 'simple' } }`
194
+ - `skip: { 'Skip reason message': { stories: ['simple', 'special'] } }`
195
+ - `skip: { 'Skip reason message': { stories: /.*large$/ } }`
198
196
  - Skip specific tests:
199
- - `skip: { tests: 'click' }`
200
- - `skip: { tests: ['hover', 'click'] }`
201
- - `skip: { tests: /^press.*$/ }`
197
+ - `skip: { 'Skip reason message': { tests: 'click' } }`
198
+ - `skip: { 'Skip reason message': { tests: ['hover', 'click'] } }`
199
+ - `skip: { 'Skip reason message': { tests: /^press.*$/ } }`
202
200
  - Multiple skip options:
203
- - as an array `skip: [{ /* ... */ }]`
204
- - as an object
201
+ - for one reason
202
+ ```
203
+ skip: {
204
+ "reason": [{ /* ... */ }, { /* ... */ }],
205
+ }
206
+ ```
207
+ - for several reasons
205
208
  ```
206
209
  skip: {
207
- foo: { /* ... */ },
208
- bar: { /* ... */ },
210
+ "reason 1": { /* ... */ },
211
+ "reason 2": { /* ... */ },
209
212
  }
210
213
  ```
211
214
 
package/jest.config.js ADDED
@@ -0,0 +1,6 @@
1
+ module.exports = {
2
+ moduleNameMapper: {
3
+ '#(.*)': '<rootDir>/node_modules/$1',
4
+ },
5
+ transformIgnorePatterns: [],
6
+ };
package/lib/cjs/cli.js ADDED
@@ -0,0 +1,5 @@
1
+ #!/usr/bin/env node
2
+ // eslint-disable-next-line node/shebang
3
+ "use strict";
4
+
5
+ require('./creevey');
@@ -0,0 +1,264 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.CreeveyManager = void 0;
7
+
8
+ var _coreEvents = require("@storybook/core-events");
9
+
10
+ var _shared = require("../../shared");
11
+
12
+ var _types = require("../../types");
13
+
14
+ var _creeveyClientApi = require("../shared/creeveyClientApi");
15
+
16
+ var _helpers = require("../shared/helpers");
17
+
18
+ var _register = require("./register");
19
+
20
+ 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
+ class CreeveyManager {
25
+ constructor(storybookApi) {
26
+ 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
+ this.storybookApi = storybookApi;
232
+ }
233
+
234
+ onUpdateStatus(listener) {
235
+ this.updateStatusListeners.push(listener);
236
+ return () => void (this.updateStatusListeners = this.updateStatusListeners.filter(x => x != listener));
237
+ }
238
+
239
+ onChangeTest(listener) {
240
+ this.changeTestListeners.push(listener);
241
+ return () => void (this.changeTestListeners = this.changeTestListeners.filter(x => x != listener));
242
+ }
243
+
244
+ async addStatusesToSideBar() {
245
+ if (!Object.keys(this.stories).length) return;
246
+ const stories = this.stories;
247
+ Object.keys(this.stories).forEach(storyId => {
248
+ const storyStatus = this.getStoryTests(storyId);
249
+ const status = storyStatus.map(x => x.status).reduce((oldStatus, newStatus) => (0, _helpers.calcStatus)(oldStatus, newStatus), undefined);
250
+ const skip = storyStatus.length > 0 ? storyStatus.every(x => x.skip) : false;
251
+ this.stories[storyId].name = this.addStatusToStoryName(stories[storyId].name, status, skip);
252
+ });
253
+ await this.storybookApi.setStories(this.stories);
254
+ }
255
+
256
+ addStatusToStoryName(name, status, skip) {
257
+ name = name.replace(/^(❌|✔|🟡|🕗|⏸) /, '');
258
+ const emojiStatus = (0, _utils.getEmojiByTestStatus)(status, skip);
259
+ return "".concat(emojiStatus ? "".concat(emojiStatus, " ") : '', " ").concat(name);
260
+ }
261
+
262
+ }
263
+
264
+ exports.CreeveyManager = CreeveyManager;
@@ -0,0 +1,55 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.Addon = void 0;
7
+
8
+ var _components = require("@storybook/components");
9
+
10
+ var _react = _interopRequireWildcard(require("react"));
11
+
12
+ 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
+
18
+ const Addon = _ref => {
19
+ let {
20
+ active,
21
+ browser,
22
+ manager
23
+ } = _ref;
24
+ const [tests, setTests] = (0, _react.useState)([]);
25
+ const [selectedTestId, setSelectedTestId] = (0, _react.useState)(manager.selectedTestId);
26
+ (0, _react.useEffect)(() => {
27
+ if (active) {
28
+ manager.setActiveBrowser(browser);
29
+ const browserTests = manager.getTestsByStoryIdAndBrowser(manager.activeBrowser);
30
+ setTests(browserTests);
31
+ }
32
+ }, [active, browser, manager]);
33
+ (0, _react.useEffect)(() => {
34
+ const unsubscribe = manager.onChangeTest(testId => {
35
+ setSelectedTestId(testId);
36
+ const status = manager.getTestsByStoryIdAndBrowser(manager.activeBrowser);
37
+ setTests(status);
38
+ });
39
+ return unsubscribe;
40
+ }, [manager]);
41
+ (0, _react.useEffect)(() => {
42
+ const unsubscribe = manager.onUpdateStatus(() => {
43
+ setTests(manager.getTestsByStoryIdAndBrowser(manager.activeBrowser));
44
+ });
45
+ return unsubscribe;
46
+ }, [manager, browser]);
47
+ return active ? tests.length ? /*#__PURE__*/_react.default.createElement(_Panel.Panel, {
48
+ tests: tests,
49
+ selectedTestId: selectedTestId,
50
+ onChangeTest: manager.setSelectedTestId,
51
+ onImageApprove: manager.onImageApprove
52
+ }) : /*#__PURE__*/_react.default.createElement(_components.Placeholder, null, "No test results") : null;
53
+ };
54
+
55
+ exports.Addon = Addon;
@@ -0,0 +1,46 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.NextIcon = exports.ForwardIcon = void 0;
7
+
8
+ var _react = _interopRequireDefault(require("react"));
9
+
10
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
11
+
12
+ const NextIcon = _ref => {
13
+ let {
14
+ width,
15
+ height
16
+ } = _ref;
17
+ return /*#__PURE__*/_react.default.createElement("svg", {
18
+ version: "1.1",
19
+ width: width,
20
+ height: height,
21
+ viewBox: "0 0 306 306"
22
+ }, /*#__PURE__*/_react.default.createElement("path", {
23
+ d: "M0,306l216.75-153L0,0V306z M255,0v306h51V0H255z",
24
+ fill: "currentColor"
25
+ }));
26
+ };
27
+
28
+ exports.NextIcon = NextIcon;
29
+
30
+ const ForwardIcon = _ref2 => {
31
+ let {
32
+ width,
33
+ height
34
+ } = _ref2;
35
+ return /*#__PURE__*/_react.default.createElement("svg", {
36
+ version: "1.1",
37
+ width: width,
38
+ height: height,
39
+ viewBox: "0 0 512 512"
40
+ }, /*#__PURE__*/_react.default.createElement("path", {
41
+ fill: "currentColor",
42
+ 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
+ }));
44
+ };
45
+
46
+ exports.ForwardIcon = ForwardIcon;
@@ -0,0 +1,72 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.Panel = void 0;
7
+
8
+ var _react = _interopRequireDefault(require("react"));
9
+
10
+ var _components = require("@storybook/components");
11
+
12
+ var _ResultsPage = require("../../shared/components/ResultsPage");
13
+
14
+ var _theming = require("@storybook/theming");
15
+
16
+ var _helpers = require("../../shared/helpers");
17
+
18
+ var _TestSelect = _interopRequireDefault(require("./TestSelect"));
19
+
20
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
21
+
22
+ const Wrapper = _theming.styled.div(_ref => {
23
+ let {
24
+ isRunning
25
+ } = _ref;
26
+ return {
27
+ opacity: isRunning ? 0.5 : 1,
28
+ height: '100%'
29
+ };
30
+ });
31
+
32
+ const TestSelectContainer = _theming.styled.div(_ref2 => {
33
+ let {
34
+ theme
35
+ } = _ref2;
36
+ return {
37
+ padding: '8px',
38
+ border: "1px solid ".concat(theme.appBorderColor)
39
+ };
40
+ });
41
+
42
+ const Panel = _ref3 => {
43
+ var _result$results, _result$results$lengt, _result$results2;
44
+
45
+ let {
46
+ tests,
47
+ selectedTestId,
48
+ onChangeTest,
49
+ onImageApprove
50
+ } = _ref3;
51
+ const result = tests.find(x => x.id === selectedTestId);
52
+ const isRunning = (result === null || result === void 0 ? void 0 : result.status) === 'running';
53
+ return /*#__PURE__*/_react.default.createElement("div", null, tests.length > 1 && /*#__PURE__*/_react.default.createElement(TestSelectContainer, null, /*#__PURE__*/_react.default.createElement(_TestSelect.default, {
54
+ tests: tests,
55
+ selectedTestId: selectedTestId,
56
+ 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, {
58
+ isRunning: isRunning
59
+ }, /*#__PURE__*/_react.default.createElement(_ResultsPage.ResultsPage, {
60
+ 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
62
+ ,
63
+ id: result.id,
64
+ path: (0, _helpers.getTestPath)(result) // TODO Memo?
65
+ ,
66
+ results: result.results,
67
+ approved: result.approved,
68
+ onImageApprove: onImageApprove
69
+ })) : null);
70
+ };
71
+
72
+ exports.Panel = Panel;