@panoramax/web-viewer 3.2.3 → 4.0.0-develop-39167b4d

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 (255) hide show
  1. package/.gitlab-ci.yml +13 -6
  2. package/CHANGELOG.md +53 -1
  3. package/CODE_OF_CONDUCT.md +1 -1
  4. package/README.md +1 -1
  5. package/build/editor.html +10 -1
  6. package/build/index.css +12 -12
  7. package/build/index.css.map +1 -1
  8. package/build/index.html +1 -1
  9. package/build/index.js +2126 -14
  10. package/build/index.js.map +1 -1
  11. package/build/map.html +1 -1
  12. package/build/photo.html +1 -0
  13. package/build/static/media/atkinson-hyperlegible-next-latin-400-normal..woff +0 -0
  14. package/build/static/media/atkinson-hyperlegible-next-latin-400-normal..woff2 +0 -0
  15. package/build/static/media/atkinson-hyperlegible-next-latin-ext-400-normal..woff +0 -0
  16. package/build/static/media/atkinson-hyperlegible-next-latin-ext-400-normal..woff2 +0 -0
  17. package/build/viewer.html +12 -1
  18. package/build/widgets.html +1 -0
  19. package/config/jest/mocks.js +201 -0
  20. package/config/paths.js +2 -0
  21. package/config/webpack.config.js +52 -0
  22. package/docs/03_URL_settings.md +14 -16
  23. package/docs/05_Compatibility.md +59 -76
  24. package/docs/09_Develop.md +46 -11
  25. package/docs/90_Releases.md +2 -2
  26. package/docs/images/class_diagram.drawio +60 -45
  27. package/docs/images/class_diagram.jpg +0 -0
  28. package/docs/images/screenshot.jpg +0 -0
  29. package/docs/index.md +135 -0
  30. package/docs/reference/components/core/Basic.md +196 -0
  31. package/docs/reference/components/core/CoverageMap.md +210 -0
  32. package/docs/reference/components/core/Editor.md +224 -0
  33. package/docs/reference/components/core/PhotoViewer.md +307 -0
  34. package/docs/reference/components/core/Viewer.md +350 -0
  35. package/docs/reference/components/layout/BottomDrawer.md +35 -0
  36. package/docs/reference/components/layout/CorneredGrid.md +29 -0
  37. package/docs/reference/components/layout/Mini.md +45 -0
  38. package/docs/reference/components/layout/Tabs.md +45 -0
  39. package/docs/reference/components/menus/MapBackground.md +32 -0
  40. package/docs/reference/components/menus/MapFilters.md +15 -0
  41. package/docs/reference/components/menus/MapLayers.md +15 -0
  42. package/docs/reference/components/menus/MapLegend.md +15 -0
  43. package/docs/reference/components/menus/PictureLegend.md +16 -0
  44. package/docs/reference/components/menus/PictureMetadata.md +15 -0
  45. package/docs/reference/components/menus/PlayerOptions.md +15 -0
  46. package/docs/reference/components/menus/QualityScoreDoc.md +15 -0
  47. package/docs/reference/components/menus/ReportForm.md +15 -0
  48. package/docs/reference/components/menus/ShareMenu.md +15 -0
  49. package/docs/reference/components/ui/Button.md +40 -0
  50. package/docs/reference/components/ui/ButtonGroup.md +36 -0
  51. package/docs/reference/components/ui/CopyButton.md +38 -0
  52. package/docs/reference/components/ui/Grade.md +32 -0
  53. package/docs/reference/components/ui/LinkButton.md +45 -0
  54. package/docs/reference/components/ui/ListGroup.md +22 -0
  55. package/docs/reference/components/ui/Loader.md +56 -0
  56. package/docs/reference/components/ui/Map.md +239 -0
  57. package/docs/reference/components/ui/MapMore.md +256 -0
  58. package/docs/reference/components/ui/Photo.md +385 -0
  59. package/docs/reference/components/ui/Popup.md +56 -0
  60. package/docs/reference/components/ui/ProgressBar.md +32 -0
  61. package/docs/reference/components/ui/QualityScore.md +45 -0
  62. package/docs/reference/components/ui/SearchBar.md +63 -0
  63. package/docs/reference/components/ui/TogglableGroup.md +39 -0
  64. package/docs/reference/components/ui/widgets/GeoSearch.md +32 -0
  65. package/docs/reference/components/ui/widgets/Legend.md +49 -0
  66. package/docs/reference/components/ui/widgets/MapFiltersButton.md +33 -0
  67. package/docs/reference/components/ui/widgets/MapLayersButton.md +15 -0
  68. package/docs/reference/components/ui/widgets/OSMEditors.md +15 -0
  69. package/docs/reference/components/ui/widgets/PictureLegendActions.md +32 -0
  70. package/docs/reference/components/ui/widgets/Player.md +33 -0
  71. package/docs/reference/components/ui/widgets/Zoom.md +15 -0
  72. package/docs/reference/utils/API.md +334 -0
  73. package/docs/reference/utils/InitParameters.md +68 -0
  74. package/docs/reference/utils/URLHandler.md +107 -0
  75. package/docs/reference.md +79 -0
  76. package/docs/shortcuts.md +11 -0
  77. package/docs/tutorials/aerial_imagery.md +19 -0
  78. package/docs/tutorials/authentication.md +10 -0
  79. package/docs/tutorials/custom_widgets.md +59 -0
  80. package/docs/tutorials/map_style.md +39 -0
  81. package/docs/tutorials/migrate_v4.md +153 -0
  82. package/docs/tutorials/synced_coverage.md +43 -0
  83. package/mkdocs.yml +66 -5
  84. package/package.json +22 -17
  85. package/public/editor.html +21 -29
  86. package/public/index.html +17 -12
  87. package/public/map.html +19 -18
  88. package/public/photo.html +55 -0
  89. package/public/viewer.html +22 -26
  90. package/public/widgets.html +306 -0
  91. package/scripts/doc.js +79 -0
  92. package/src/components/core/Basic.css +48 -0
  93. package/src/components/core/Basic.js +349 -0
  94. package/src/components/core/CoverageMap.css +9 -0
  95. package/src/components/core/CoverageMap.js +139 -0
  96. package/src/components/core/Editor.css +23 -0
  97. package/src/components/core/Editor.js +390 -0
  98. package/src/components/core/PhotoViewer.css +48 -0
  99. package/src/components/core/PhotoViewer.js +499 -0
  100. package/src/components/core/Viewer.css +98 -0
  101. package/src/components/core/Viewer.js +564 -0
  102. package/src/components/core/index.js +12 -0
  103. package/src/components/index.js +13 -0
  104. package/src/components/layout/BottomDrawer.js +257 -0
  105. package/src/components/layout/CorneredGrid.js +112 -0
  106. package/src/components/layout/Mini.js +117 -0
  107. package/src/components/layout/Tabs.js +133 -0
  108. package/src/components/layout/index.js +9 -0
  109. package/src/components/menus/MapBackground.js +106 -0
  110. package/src/components/menus/MapFilters.js +400 -0
  111. package/src/components/menus/MapLayers.js +143 -0
  112. package/src/components/menus/MapLegend.js +34 -0
  113. package/src/components/menus/PictureLegend.js +257 -0
  114. package/src/components/menus/PictureMetadata.js +317 -0
  115. package/src/components/menus/PlayerOptions.js +95 -0
  116. package/src/components/menus/QualityScoreDoc.js +36 -0
  117. package/src/components/menus/ReportForm.js +133 -0
  118. package/src/components/menus/Share.js +100 -0
  119. package/src/components/menus/index.js +15 -0
  120. package/src/components/styles.js +383 -0
  121. package/src/components/ui/Button.js +77 -0
  122. package/src/components/ui/ButtonGroup.css +57 -0
  123. package/src/components/ui/ButtonGroup.js +68 -0
  124. package/src/components/ui/CopyButton.js +106 -0
  125. package/src/components/ui/Grade.js +54 -0
  126. package/src/components/ui/LinkButton.js +67 -0
  127. package/src/components/ui/ListGroup.js +66 -0
  128. package/src/components/ui/Loader.js +203 -0
  129. package/src/components/{Map.css → ui/Map.css} +5 -17
  130. package/src/components/{Map.js → ui/Map.js} +148 -156
  131. package/src/components/ui/MapMore.js +324 -0
  132. package/src/components/{Photo.css → ui/Photo.css} +6 -6
  133. package/src/components/{Photo.js → ui/Photo.js} +313 -101
  134. package/src/components/ui/Popup.js +145 -0
  135. package/src/components/ui/ProgressBar.js +104 -0
  136. package/src/components/ui/QualityScore.js +147 -0
  137. package/src/components/ui/SearchBar.js +367 -0
  138. package/src/components/ui/TogglableGroup.js +157 -0
  139. package/src/components/ui/index.js +22 -0
  140. package/src/components/ui/widgets/GeoSearch.css +21 -0
  141. package/src/components/ui/widgets/GeoSearch.js +139 -0
  142. package/src/components/ui/widgets/Legend.js +113 -0
  143. package/src/components/ui/widgets/MapFiltersButton.js +104 -0
  144. package/src/components/ui/widgets/MapLayersButton.js +79 -0
  145. package/src/components/ui/widgets/OSMEditors.js +155 -0
  146. package/src/components/ui/widgets/PictureLegendActions.js +117 -0
  147. package/src/components/ui/widgets/Player.css +7 -0
  148. package/src/components/ui/widgets/Player.js +151 -0
  149. package/src/components/ui/widgets/Zoom.js +82 -0
  150. package/src/components/ui/widgets/index.js +13 -0
  151. package/src/img/loader_base.jpg +0 -0
  152. package/src/img/panoramax.svg +13 -0
  153. package/src/img/switch_big.svg +20 -10
  154. package/src/index.js +7 -9
  155. package/src/translations/br.json +1 -0
  156. package/src/translations/da.json +38 -15
  157. package/src/translations/de.json +5 -3
  158. package/src/translations/en.json +35 -15
  159. package/src/translations/eo.json +38 -15
  160. package/src/translations/es.json +1 -1
  161. package/src/translations/fr.json +36 -16
  162. package/src/translations/hu.json +1 -1
  163. package/src/translations/it.json +39 -16
  164. package/src/translations/ja.json +182 -1
  165. package/src/translations/nl.json +106 -6
  166. package/src/translations/pl.json +1 -1
  167. package/src/translations/sv.json +182 -0
  168. package/src/translations/zh_Hant.json +35 -14
  169. package/src/utils/API.js +109 -49
  170. package/src/utils/InitParameters.js +388 -0
  171. package/src/utils/PhotoAdapter.js +1 -0
  172. package/src/utils/URLHandler.js +362 -0
  173. package/src/utils/geocoder.js +152 -0
  174. package/src/utils/{I18n.js → i18n.js} +7 -3
  175. package/src/utils/index.js +11 -0
  176. package/src/utils/{Map.js → map.js} +256 -77
  177. package/src/utils/picture.js +442 -0
  178. package/src/utils/utils.js +324 -0
  179. package/src/utils/widgets.js +55 -0
  180. package/tests/components/core/Basic.test.js +121 -0
  181. package/tests/components/core/BasicMock.js +25 -0
  182. package/tests/components/core/CoverageMap.test.js +20 -0
  183. package/tests/components/core/Editor.test.js +20 -0
  184. package/tests/components/core/PhotoViewer.test.js +57 -0
  185. package/tests/components/core/Viewer.test.js +84 -0
  186. package/tests/components/core/__snapshots__/PhotoViewer.test.js.snap +73 -0
  187. package/tests/components/core/__snapshots__/Viewer.test.js.snap +145 -0
  188. package/tests/components/ui/CopyButton.test.js +52 -0
  189. package/tests/components/ui/Loader.test.js +55 -0
  190. package/tests/components/{Map.test.js → ui/Map.test.js} +73 -61
  191. package/tests/components/{Photo.test.js → ui/Photo.test.js} +97 -63
  192. package/tests/components/ui/Popup.test.js +26 -0
  193. package/tests/components/ui/QualityScore.test.js +18 -0
  194. package/tests/components/ui/SearchBar.test.js +110 -0
  195. package/tests/components/ui/__snapshots__/CopyButton.test.js.snap +33 -0
  196. package/tests/components/ui/__snapshots__/Loader.test.js.snap +56 -0
  197. package/tests/components/{__snapshots__ → ui/__snapshots__}/Map.test.js.snap +11 -38
  198. package/tests/components/{__snapshots__ → ui/__snapshots__}/Photo.test.js.snap +70 -6
  199. package/tests/components/ui/__snapshots__/Popup.test.js.snap +29 -0
  200. package/tests/components/ui/__snapshots__/QualityScore.test.js.snap +11 -0
  201. package/tests/components/ui/__snapshots__/SearchBar.test.js.snap +65 -0
  202. package/tests/utils/API.test.js +83 -83
  203. package/tests/utils/InitParameters.test.js +499 -0
  204. package/tests/utils/URLHandler.test.js +401 -0
  205. package/tests/utils/__snapshots__/API.test.js.snap +10 -0
  206. package/tests/utils/__snapshots__/URLHandler.test.js.snap +21 -0
  207. package/tests/utils/__snapshots__/{Map.test.js.snap → geocoder.test.js.snap} +1 -1
  208. package/tests/utils/__snapshots__/map.test.js.snap +11 -0
  209. package/tests/utils/__snapshots__/picture.test.js.snap +327 -0
  210. package/tests/utils/__snapshots__/widgets.test.js.snap +19 -0
  211. package/tests/utils/geocoder.test.js +37 -0
  212. package/tests/utils/{I18n.test.js → i18n.test.js} +8 -8
  213. package/tests/utils/map.test.js +126 -0
  214. package/tests/utils/picture.test.js +745 -0
  215. package/tests/utils/utils.test.js +288 -0
  216. package/tests/utils/widgets.test.js +31 -0
  217. package/docs/01_Start.md +0 -149
  218. package/docs/02_Usage.md +0 -831
  219. package/docs/04_Advanced_examples.md +0 -216
  220. package/src/Editor.css +0 -37
  221. package/src/Editor.js +0 -361
  222. package/src/StandaloneMap.js +0 -114
  223. package/src/Viewer.css +0 -203
  224. package/src/Viewer.js +0 -1246
  225. package/src/components/CoreView.css +0 -70
  226. package/src/components/CoreView.js +0 -175
  227. package/src/components/Loader.css +0 -74
  228. package/src/components/Loader.js +0 -120
  229. package/src/img/loader_hd.jpg +0 -0
  230. package/src/utils/Exif.js +0 -193
  231. package/src/utils/Utils.js +0 -631
  232. package/src/utils/Widgets.js +0 -562
  233. package/src/viewer/URLHash.js +0 -469
  234. package/src/viewer/Widgets.css +0 -880
  235. package/src/viewer/Widgets.js +0 -1470
  236. package/tests/Editor.test.js +0 -126
  237. package/tests/StandaloneMap.test.js +0 -45
  238. package/tests/Viewer.test.js +0 -366
  239. package/tests/__snapshots__/Editor.test.js.snap +0 -298
  240. package/tests/__snapshots__/StandaloneMap.test.js.snap +0 -30
  241. package/tests/__snapshots__/Viewer.test.js.snap +0 -195
  242. package/tests/components/CoreView.test.js +0 -92
  243. package/tests/components/Loader.test.js +0 -38
  244. package/tests/components/__snapshots__/Loader.test.js.snap +0 -15
  245. package/tests/utils/Exif.test.js +0 -124
  246. package/tests/utils/Map.test.js +0 -113
  247. package/tests/utils/Utils.test.js +0 -300
  248. package/tests/utils/Widgets.test.js +0 -107
  249. package/tests/utils/__snapshots__/Exif.test.js.snap +0 -43
  250. package/tests/utils/__snapshots__/Utils.test.js.snap +0 -41
  251. package/tests/utils/__snapshots__/Widgets.test.js.snap +0 -44
  252. package/tests/viewer/URLHash.test.js +0 -559
  253. package/tests/viewer/Widgets.test.js +0 -127
  254. package/tests/viewer/__snapshots__/URLHash.test.js.snap +0 -108
  255. package/tests/viewer/__snapshots__/Widgets.test.js.snap +0 -403
@@ -1,62 +1,14 @@
1
- import Photo from "../../src/components/Photo";
1
+ import Photo from "../../../src/components/ui/Photo";
2
2
  import fs from "fs";
3
3
  import path from "path";
4
4
 
5
- jest.mock("@photo-sphere-viewer/core", () => ({
6
- Viewer: class {
7
- constructor(opts) {
8
- this._psvOpts = opts;
9
- this.loader = {
10
- canvas: { setAttribute: jest.fn() },
11
- __updateContent: jest.fn(),
12
- show: jest.fn(),
13
- };
14
- this.renderer = {
15
- renderer: {
16
- toneMapping: null,
17
- toneMappingExposure: null,
18
- }
19
- };
20
- }
21
- addEventListener() {;}
22
- getPlugin() {
23
- return {
24
- addEventListener: jest.fn(),
25
- datasource: {
26
- nodeResolver: jest.fn(),
27
- },
28
- arrowsRenderer: {
29
- clear: jest.fn(),
30
- },
31
- state: {
32
- currentNode: null,
33
- datasource: { nodes: {} },
34
- },
35
- config: {
36
- transitionOptions: jest.fn(),
37
- },
38
- __onEnterObject: jest.fn(),
39
- __onLeaveObject: jest.fn(),
40
- };
41
- }
42
- }
43
- }));
44
-
45
- jest.mock("@photo-sphere-viewer/equirectangular-tiles-adapter", () => ({
46
- EquirectangularTilesAdapter: jest.fn(),
47
- }));
48
-
49
- jest.mock("@photo-sphere-viewer/virtual-tour-plugin", () => ({
50
- VirtualTourPlugin: jest.fn(),
51
- }));
52
-
53
5
  const createParent = () => ({
54
6
  addEventListener: jest.fn(),
55
7
  dispatchEvent: jest.fn(),
56
8
  isWidthSmall: jest.fn(),
57
9
  select: jest.fn(),
58
- _t: { gvs: {} },
59
- _api: {
10
+ _t: { pnx: {} },
11
+ api: {
60
12
  _getFetchOptions: jest.fn(),
61
13
  getPictureMetadataUrl: (picId, seqId) => `https://geovisio.fr/api/collections/${seqId}/items/${picId}`
62
14
  },
@@ -68,7 +20,7 @@ describe("constructor", () => {
68
20
  const p = createParent();
69
21
  const c = document.createElement("div");
70
22
  const ph = new Photo(p, c);
71
- expect(c.className).toBe("gvs-psv");
23
+ expect(c.className).toBe("pnx-psv");
72
24
  });
73
25
  });
74
26
 
@@ -84,7 +36,7 @@ describe("_getNodeFromAPI", () => {
84
36
  global.fetch = jest.fn(() =>
85
37
  Promise.resolve({
86
38
  ok: true,
87
- json: () => Promise.resolve(JSON.parse(fs.readFileSync(path.join(__dirname, "..", "data", "Viewer_pictures_1.json")))),
39
+ json: () => Promise.resolve(JSON.parse(fs.readFileSync(path.join(__dirname, "..", "..", "data", "Viewer_pictures_1.json")))),
88
40
  })
89
41
  );
90
42
  global.Date = jest.fn(() => ({ toLocaleDateString: () => "June 3 2022" }));
@@ -100,7 +52,7 @@ describe("_getNodeFromAPI", () => {
100
52
  global.fetch = jest.fn(() =>
101
53
  Promise.resolve({
102
54
  ok: true,
103
- json: () => Promise.resolve(JSON.parse(fs.readFileSync(path.join(__dirname, "..", "data", "Viewer_pictures_1.json")))),
55
+ json: () => Promise.resolve(JSON.parse(fs.readFileSync(path.join(__dirname, "..", "..", "data", "Viewer_pictures_1.json")))),
104
56
  })
105
57
  );
106
58
  global.Date = jest.fn(() => ({ toLocaleDateString: () => "June 3 2022" }));
@@ -114,8 +66,8 @@ describe("getPictureMetadata", () => {
114
66
  const p = createParent();
115
67
  const c = document.createElement("div");
116
68
  const ph = new Photo(p, c);
117
- ph._myVTour.state.currentNode = { bla: "bla" };
118
- expect(ph.getPictureMetadata()).toStrictEqual({ bla: "bla" });
69
+ ph._myVTour.state.currentNode = { id: "1234", bla: "bla" };
70
+ expect(ph.getPictureMetadata()).toStrictEqual({ id: "1234", bla: "bla" });
119
71
  });
120
72
 
121
73
  it("nulls when no pic is selected", () => {
@@ -159,7 +111,7 @@ describe("goToNextPicture", () => {
159
111
  const p = createParent();
160
112
  const c = document.createElement("div");
161
113
  const ph = new Photo(p, c);
162
- ph._myVTour = { state: { currentNode: { sequence: { id: "seq", nextPic: "idnext" } } } };
114
+ ph._myVTour = { state: { currentNode: { id: "bla", sequence: { id: "seq", nextPic: "idnext" } } } };
163
115
  ph.goToNextPicture();
164
116
  expect(p.select.mock.calls).toEqual([["seq", "idnext"]]);
165
117
  });
@@ -168,7 +120,7 @@ describe("goToNextPicture", () => {
168
120
  const p = createParent();
169
121
  const c = document.createElement("div");
170
122
  const ph = new Photo(p, c);
171
- ph._myVTour = { state: { currentNode: { sequence: {} } } };
123
+ ph._myVTour = { state: { currentNode: { id: "bla", sequence: {} } } };
172
124
  expect(() => ph.goToNextPicture()).toThrow(new Error("No next picture available"));
173
125
  });
174
126
  });
@@ -186,7 +138,7 @@ describe("goToPrevPicture", () => {
186
138
  const p = createParent();
187
139
  const c = document.createElement("div");
188
140
  const ph = new Photo(p, c);
189
- ph._myVTour = { state: { currentNode: { sequence: { id: "seq", prevPic: "idprev" } } } };
141
+ ph._myVTour = { state: { currentNode: { id: "bla", sequence: { id: "seq", prevPic: "idprev" } } } };
190
142
  ph.goToPrevPicture();
191
143
  expect(p.select.mock.calls).toEqual([["seq", "idprev"]]);
192
144
  });
@@ -195,7 +147,7 @@ describe("goToPrevPicture", () => {
195
147
  const p = createParent();
196
148
  const c = document.createElement("div");
197
149
  const ph = new Photo(p, c);
198
- ph._myVTour = { state: { currentNode: { sequence: {} } } };
150
+ ph._myVTour = { state: { currentNode: { id: "bla", sequence: {} } } };
199
151
  expect(() => ph.goToPrevPicture()).toThrow(new Error("No previous picture available"));
200
152
  });
201
153
  });
@@ -205,8 +157,8 @@ describe("goToPosition", () => {
205
157
  const p = createParent();
206
158
  const c = document.createElement("div");
207
159
  const ph = new Photo(p, c);
208
- p._api = {
209
- getPicturesAroundCoordinates: () => Promise.resolve(JSON.parse(fs.readFileSync(path.join(__dirname, "..", "data", "Viewer_pictures_1.json")))),
160
+ p.api = {
161
+ getPicturesAroundCoordinates: () => Promise.resolve(JSON.parse(fs.readFileSync(path.join(__dirname, "..", "..", "data", "Viewer_pictures_1.json")))),
210
162
  _getFetchOptions: jest.fn()
211
163
  };
212
164
 
@@ -220,7 +172,7 @@ describe("goToPosition", () => {
220
172
  const p = createParent();
221
173
  const c = document.createElement("div");
222
174
  const ph = new Photo(p, c);
223
- p._api = {
175
+ p.api = {
224
176
  getPicturesAroundCoordinates: () => Promise.resolve({ "features": [] }),
225
177
  _getFetchOptions: jest.fn()
226
178
  };
@@ -333,3 +285,85 @@ describe("setTransitionDuration", () => {
333
285
  expect(() => ph.setTransitionDuration(3001)).toThrowError("Invalid transition duration (should be between 100 and 3000)");
334
286
  });
335
287
  });
288
+
289
+ describe("playSequence", () => {
290
+ it("sends event", () => {
291
+ const p = createParent();
292
+ const c = document.createElement("div");
293
+ const ph = new Photo(p, c);
294
+ return new Promise(resolve => {
295
+ ph.addEventListener("sequence-playing", resolve);
296
+ ph.playSequence();
297
+ });
298
+ });
299
+ });
300
+
301
+ describe("stopSequence", () => {
302
+ it("sends event", async () => {
303
+ const p = createParent();
304
+ const c = document.createElement("div");
305
+ const ph = new Photo(p, c);
306
+ return new Promise(resolve => {
307
+ ph.addEventListener("sequence-stopped", resolve);
308
+ ph.stopSequence();
309
+ });
310
+ });
311
+ });
312
+
313
+ describe("isSequencePlaying", () => {
314
+ it("is true when sequence is playing", () => {
315
+ const p = createParent();
316
+ const c = document.createElement("div");
317
+ const ph = new Photo(p, c);
318
+ ph.goToNextPicture = jest.fn();
319
+ ph.playSequence();
320
+ expect(ph.isSequencePlaying()).toBe(true);
321
+ });
322
+
323
+ it("is false when sequence never played", () => {
324
+ const p = createParent();
325
+ const c = document.createElement("div");
326
+ const ph = new Photo(p, c);
327
+ expect(ph.isSequencePlaying()).toBe(false);
328
+ });
329
+
330
+ it("is false when sequence stopped", () => {
331
+ const p = createParent();
332
+ const c = document.createElement("div");
333
+ const ph = new Photo(p, c);
334
+ ph.playSequence();
335
+ ph.stopSequence();
336
+ expect(ph.isSequencePlaying()).toBe(false);
337
+ });
338
+ });
339
+
340
+ describe("getPicturesNavigation", () => {
341
+ it("works", () => {
342
+ const p = createParent();
343
+ const c = document.createElement("div");
344
+ const ph = new Photo(p, c, {picturesNavigation: "pic"});
345
+ expect(ph.getPicturesNavigation()).toBe("pic");
346
+ ph._picturesNavigation = "seq";
347
+ expect(ph.getPicturesNavigation()).toBe("seq");
348
+ });
349
+ });
350
+
351
+ describe("setPicturesNavigation", () => {
352
+ it("works", () => {
353
+ const p = createParent();
354
+ const c = document.createElement("div");
355
+ const ph = new Photo(p, c);
356
+ const eventWatcher = jest.fn();
357
+ ph.addEventListener("pictures-navigation-changed", eventWatcher);
358
+ expect(ph.getPicturesNavigation()).toBe("any");
359
+ ph.setPicturesNavigation("pic");
360
+ expect(ph.getPicturesNavigation()).toBe("pic");
361
+ ph.setPicturesNavigation("seq");
362
+ expect(ph.getPicturesNavigation()).toBe("seq");
363
+ ph.setPicturesNavigation("any");
364
+ expect(ph.getPicturesNavigation()).toBe("any");
365
+ ph.setPicturesNavigation("none");
366
+ expect(ph.getPicturesNavigation()).toBe("pic");
367
+ expect(eventWatcher.mock.calls).toMatchSnapshot();
368
+ });
369
+ });
@@ -0,0 +1,26 @@
1
+ import Popup from "../../../src/components/ui/Popup";
2
+
3
+ describe("constructor", () => {
4
+ it("works", () => {
5
+ document.addEventListener = jest.fn();
6
+ const p = new Popup();
7
+ p.addEventListener = jest.fn();
8
+ expect(p.visible).toBe(false);
9
+
10
+ p.connectedCallback();
11
+ expect(p.addEventListener.mock.calls).toMatchSnapshot();
12
+ expect(document.addEventListener.mock.calls).toMatchSnapshot();
13
+ });
14
+ });
15
+
16
+ describe("close", () => {
17
+ it("works", () => {
18
+ const p = new Popup();
19
+ p.dispatchEvent = jest.fn();
20
+ p.visible = true;
21
+ p.close();
22
+
23
+ expect(p.visible).toBe(false);
24
+ expect(p.dispatchEvent.mock.calls).toMatchSnapshot();
25
+ });
26
+ });
@@ -0,0 +1,18 @@
1
+ import QualityScore from "../../../src/components/ui/QualityScore";
2
+
3
+ describe("_onInput", () => {
4
+ it("works", () => {
5
+ const qs = new QualityScore();
6
+ qs.dispatchEvent = jest.fn();
7
+ qs.renderRoot.querySelectorAll.mockReturnValueOnce([
8
+ { value: 5, checked: false },
9
+ { value: 4, checked: true },
10
+ { value: 3, checked: false },
11
+ { value: 2, checked: true },
12
+ { value: 1, checked: false },
13
+ ])
14
+ qs._onInput();
15
+ expect(qs.grade).toEqual("4,2");
16
+ expect(qs.dispatchEvent.mock.calls).toMatchSnapshot();
17
+ });
18
+ });
@@ -0,0 +1,110 @@
1
+ import SearchBar from "../../../src/components/ui/SearchBar";
2
+
3
+ describe("_onIconClick", () => {
4
+ it("resets on error", () => {
5
+ const sb = new SearchBar();
6
+ sb.reset = jest.fn();
7
+ sb._icon = "warn";
8
+ sb._onIconClick();
9
+ expect(sb.reset.mock.calls).toMatchSnapshot();
10
+ });
11
+
12
+ it("resets on clear", () => {
13
+ const sb = new SearchBar();
14
+ sb.reset = jest.fn();
15
+ sb._icon = "empty";
16
+ sb._onIconClick();
17
+ expect(sb.reset.mock.calls).toMatchSnapshot();
18
+ });
19
+
20
+ it("reduces if reduceable & extended", () => {
21
+ const sb = new SearchBar();
22
+ sb.reduceable = true;
23
+ sb.reduced = false;
24
+ sb._onIconClick();
25
+ expect(sb.reduced).toBe(true);
26
+ });
27
+
28
+ it("expands if reduceable & reduced", () => {
29
+ const sb = new SearchBar();
30
+ sb.reduceable = true;
31
+ sb.reduced = true;
32
+ sb._onIconClick();
33
+ expect(sb.reduced).toBe(false);
34
+ });
35
+ });
36
+
37
+ describe("_onResultClick", () => {
38
+ it("works on classic", () => {
39
+ const sb = new SearchBar();
40
+ sb.dispatchEvent = jest.fn();
41
+ sb._onResultClick({title: "res1", subtitle: "sub1", data: "coucou"});
42
+ expect(sb.dispatchEvent.mock.calls).toMatchSnapshot();
43
+ expect(sb.value).toEqual("res1");
44
+ expect(sb._icon).toEqual("empty");
45
+ expect(sb._results).toBe(null);
46
+ });
47
+
48
+ it("works on reduced", () => {
49
+ const sb = new SearchBar();
50
+ sb.dispatchEvent = jest.fn();
51
+ sb.reduceable = true;
52
+ sb._onResultClick({title: "res1", subtitle: "sub1", data: "coucou"});
53
+ expect(sb.dispatchEvent.mock.calls).toMatchSnapshot();
54
+ expect(sb.value).toEqual("");
55
+ expect(sb._icon).toEqual("search");
56
+ expect(sb._results).toBe(null);
57
+ expect(sb.reduced).toBe(true);
58
+ });
59
+
60
+ it("resets on null value", () => {
61
+ const sb = new SearchBar();
62
+ sb.dispatchEvent = jest.fn();
63
+ sb._onResultClick(null);
64
+ expect(sb.dispatchEvent.mock.calls).toMatchSnapshot();
65
+ expect(sb.value).toEqual("");
66
+ expect(sb._icon).toEqual("search");
67
+ expect(sb._results).toBe(null);
68
+ });
69
+ });
70
+
71
+ describe("_search", () => {
72
+ it("skips if value is empty", () => {
73
+ const sb = new SearchBar();
74
+ sb.reset = jest.fn();
75
+ sb._search();
76
+ expect(sb.reset.mock.calls).toMatchSnapshot();
77
+ });
78
+
79
+ it("skips if no searcher fct", () => {
80
+ global.console = { warn: jest.fn() };
81
+
82
+ const sb = new SearchBar();
83
+ sb.value = "test";
84
+ sb._search();
85
+ expect(global.console.warn.mock.calls).toMatchSnapshot();
86
+ });
87
+
88
+ it("works with actual data", () => {
89
+ const sb = new SearchBar();
90
+ return new Promise(resolve => {
91
+ sb.searcher = value => {
92
+ expect(value).toEqual("my search");
93
+ expect(sb._icon).toEqual("loading");
94
+ expect(sb._results).toBe(null);
95
+ resolve();
96
+ };
97
+ sb.value = "my search";
98
+ sb._search();
99
+ });
100
+ });
101
+ });
102
+
103
+ describe("reset", () => {
104
+ it("works", () => {
105
+ const sb = new SearchBar();
106
+ sb._onResultClick = jest.fn();
107
+ sb.reset();
108
+ expect(sb._onResultClick.mock.calls).toMatchSnapshot();
109
+ });
110
+ });
@@ -0,0 +1,33 @@
1
+ // Jest Snapshot v1, https://goo.gl/fbAQLP
2
+
3
+ exports[`_onClick works with input 1`] = `
4
+ Array [
5
+ Array [
6
+ "copy me from input",
7
+ ],
8
+ ]
9
+ `;
10
+
11
+ exports[`_onClick works with text 1`] = `
12
+ Array [
13
+ Array [
14
+ "I am a copy text",
15
+ ],
16
+ ]
17
+ `;
18
+
19
+ exports[`_onClick works with textarea 1`] = `
20
+ Array [
21
+ Array [
22
+ "copy me from textarea",
23
+ ],
24
+ ]
25
+ `;
26
+
27
+ exports[`constructor listens to click 1`] = `
28
+ Object {
29
+ "click": Array [
30
+ [Function],
31
+ ],
32
+ }
33
+ `;
@@ -0,0 +1,56 @@
1
+ // Jest Snapshot v1, https://goo.gl/fbAQLP
2
+
3
+ exports[`dismiss works on success + next fct 1`] = `
4
+ Array [
5
+ Array [
6
+ CustomEvent {
7
+ "isTrusted": false,
8
+ },
9
+ ],
10
+ ]
11
+ `;
12
+
13
+ exports[`dismiss works on success + next fct 2`] = `
14
+ Array [
15
+ Array [],
16
+ ]
17
+ `;
18
+
19
+ exports[`dismiss works on success 1`] = `
20
+ Array [
21
+ Array [
22
+ CustomEvent {
23
+ "isTrusted": false,
24
+ },
25
+ ],
26
+ ]
27
+ `;
28
+
29
+ exports[`dismiss works with error + next fct 1`] = `
30
+ Array [
31
+ Array [
32
+ CustomEvent {
33
+ "isTrusted": false,
34
+ },
35
+ ],
36
+ ]
37
+ `;
38
+
39
+ exports[`dismiss works with error + next fct 2`] = `
40
+ Array [
41
+ Array [
42
+ "click",
43
+ [MockFunction],
44
+ ],
45
+ ]
46
+ `;
47
+
48
+ exports[`dismiss works with error 1`] = `
49
+ Array [
50
+ Array [
51
+ CustomEvent {
52
+ "isTrusted": false,
53
+ },
54
+ ],
55
+ ]
56
+ `;
@@ -99,8 +99,8 @@ Array [
99
99
  ],
100
100
  "equirectangular",
101
101
  ],
102
- "gvs-arrow-360",
103
- "gvs-arrow-flat",
102
+ "pnx-arrow-360",
103
+ "pnx-arrow-flat",
104
104
  ],
105
105
  ],
106
106
  Array [
@@ -142,8 +142,8 @@ Array [
142
142
  ],
143
143
  "equirectangular",
144
144
  ],
145
- "gvs-arrow-360",
146
- "gvs-arrow-flat",
145
+ "pnx-arrow-360",
146
+ "pnx-arrow-flat",
147
147
  ],
148
148
  ],
149
149
  Array [
@@ -507,45 +507,18 @@ Array [
507
507
  exports[`setBackground works if raster is enabled 1`] = `
508
508
  Array [
509
509
  Array [
510
- "gvs-aerial",
510
+ "pnx-aerial",
511
511
  "visibility",
512
512
  "visible",
513
513
  ],
514
514
  ]
515
515
  `;
516
516
 
517
- exports[`setBackground works if raster is enabled 2`] = `
518
- Array [
519
- Array [
520
- CustomEvent {
521
- "isTrusted": false,
522
- },
523
- ],
524
- ]
525
- `;
526
-
527
517
  exports[`setVisibleUsers works when no users exists 1`] = `Array []`;
528
518
 
529
- exports[`setVisibleUsers works when no users exists 2`] = `
530
- Array [
531
- Array [
532
- CustomEvent {
533
- "isTrusted": false,
534
- },
535
- ],
536
- ]
537
- `;
519
+ exports[`setVisibleUsers works when no users exists 2`] = `Array []`;
538
520
 
539
- exports[`setVisibleUsers works when user already exist but is hidden 1`] = `
540
- Array [
541
- CustomEvent {
542
- "isTrusted": false,
543
- },
544
- CustomEvent {
545
- "isTrusted": false,
546
- },
547
- ]
548
- `;
521
+ exports[`setVisibleUsers works when user already exist but is hidden 1`] = `Array []`;
549
522
 
550
523
  exports[`setVisibleUsers works when user already exist but is hidden 2`] = `
551
524
  Array [
@@ -605,8 +578,8 @@ Array [
605
578
  ],
606
579
  "equirectangular",
607
580
  ],
608
- "gvs-arrow-360",
609
- "gvs-arrow-flat",
581
+ "pnx-arrow-360",
582
+ "pnx-arrow-flat",
610
583
  ],
611
584
  ],
612
585
  Array [
@@ -648,8 +621,8 @@ Array [
648
621
  ],
649
622
  "equirectangular",
650
623
  ],
651
- "gvs-arrow-360",
652
- "gvs-arrow-flat",
624
+ "pnx-arrow-360",
625
+ "pnx-arrow-flat",
653
626
  ],
654
627
  ],
655
628
  Array [
@@ -7,7 +7,9 @@ Object {
7
7
  "toLocaleDateString": [Function],
8
8
  },
9
9
  "license": "proprietary",
10
- "producer": "User",
10
+ "producer": Array [
11
+ "User",
12
+ ],
11
13
  },
12
14
  "gps": Array [
13
15
  2.1822941,
@@ -57,6 +59,7 @@ Object {
57
59
  "nodeId": "127d9282-d082-46ca-bc09-4b0d8569dd2c",
58
60
  },
59
61
  ],
62
+ "origInstance": undefined,
60
63
  "panorama": Object {
61
64
  "basePanoData": [Function],
62
65
  "baseUrl": "https://geovisio.fr/api/pictures/0005086d-65eb-4a90-9764-86b3661aaa77/sd.webp",
@@ -117,7 +120,9 @@ Object {
117
120
  "toLocaleDateString": [Function],
118
121
  },
119
122
  "license": "proprietary",
120
- "producer": "User",
123
+ "producer": Array [
124
+ "User",
125
+ ],
121
126
  },
122
127
  "gps": Array [
123
128
  2.1822941,
@@ -125,7 +130,49 @@ Object {
125
130
  ],
126
131
  "horizontalFov": 360,
127
132
  "id": "0005086d-65eb-4a90-9764-86b3661aaa77",
128
- "links": Array [],
133
+ "links": Array [
134
+ Object {
135
+ "arrowStyle": Object {
136
+ "element": <img
137
+ alt=""
138
+ src="arrow_triangle.svg"
139
+ />,
140
+ "size": Object {
141
+ "height": 75,
142
+ "width": 75,
143
+ },
144
+ },
145
+ "gps": Array [
146
+ 2.1822633,
147
+ 48.9811134,
148
+ ],
149
+ "linkOffset": Object {
150
+ "yaw": -0,
151
+ },
152
+ "nodeId": "ccf5f468-38b8-4b42-8d79-b97f5391e0a3",
153
+ },
154
+ Object {
155
+ "arrowStyle": Object {
156
+ "element": <img
157
+ alt=""
158
+ src="arrow_triangle.svg"
159
+ />,
160
+ "size": Object {
161
+ "height": 75,
162
+ "width": 75,
163
+ },
164
+ },
165
+ "gps": Array [
166
+ 2.1823272,
167
+ 48.9810024,
168
+ ],
169
+ "linkOffset": Object {
170
+ "yaw": -0,
171
+ },
172
+ "nodeId": "127d9282-d082-46ca-bc09-4b0d8569dd2c",
173
+ },
174
+ ],
175
+ "origInstance": undefined,
129
176
  "panorama": Object {
130
177
  "basePanoData": [Function],
131
178
  "baseUrl": "https://geovisio.fr/api/pictures/0005086d-65eb-4a90-9764-86b3661aaa77/sd.webp",
@@ -188,12 +235,29 @@ Array [
188
235
  ]
189
236
  `;
190
237
 
191
- exports[`setTransitionDuration works 1`] = `
238
+ exports[`setPicturesNavigation works 1`] = `
192
239
  Array [
193
240
  Array [
194
- CustomEvent {
195
- "isTrusted": false,
241
+ Object {
242
+ "value": "pic",
243
+ },
244
+ ],
245
+ Array [
246
+ Object {
247
+ "value": "seq",
248
+ },
249
+ ],
250
+ Array [
251
+ Object {
252
+ "value": "any",
253
+ },
254
+ ],
255
+ Array [
256
+ Object {
257
+ "value": "pic",
196
258
  },
197
259
  ],
198
260
  ]
199
261
  `;
262
+
263
+ exports[`setTransitionDuration works 1`] = `Array []`;