@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.
- package/.gitlab-ci.yml +13 -6
- package/CHANGELOG.md +53 -1
- package/CODE_OF_CONDUCT.md +1 -1
- package/README.md +1 -1
- package/build/editor.html +10 -1
- package/build/index.css +12 -12
- package/build/index.css.map +1 -1
- package/build/index.html +1 -1
- package/build/index.js +2126 -14
- package/build/index.js.map +1 -1
- package/build/map.html +1 -1
- package/build/photo.html +1 -0
- package/build/static/media/atkinson-hyperlegible-next-latin-400-normal..woff +0 -0
- package/build/static/media/atkinson-hyperlegible-next-latin-400-normal..woff2 +0 -0
- package/build/static/media/atkinson-hyperlegible-next-latin-ext-400-normal..woff +0 -0
- package/build/static/media/atkinson-hyperlegible-next-latin-ext-400-normal..woff2 +0 -0
- package/build/viewer.html +12 -1
- package/build/widgets.html +1 -0
- package/config/jest/mocks.js +201 -0
- package/config/paths.js +2 -0
- package/config/webpack.config.js +52 -0
- package/docs/03_URL_settings.md +14 -16
- package/docs/05_Compatibility.md +59 -76
- package/docs/09_Develop.md +46 -11
- package/docs/90_Releases.md +2 -2
- package/docs/images/class_diagram.drawio +60 -45
- package/docs/images/class_diagram.jpg +0 -0
- package/docs/images/screenshot.jpg +0 -0
- package/docs/index.md +135 -0
- package/docs/reference/components/core/Basic.md +196 -0
- package/docs/reference/components/core/CoverageMap.md +210 -0
- package/docs/reference/components/core/Editor.md +224 -0
- package/docs/reference/components/core/PhotoViewer.md +307 -0
- package/docs/reference/components/core/Viewer.md +350 -0
- package/docs/reference/components/layout/BottomDrawer.md +35 -0
- package/docs/reference/components/layout/CorneredGrid.md +29 -0
- package/docs/reference/components/layout/Mini.md +45 -0
- package/docs/reference/components/layout/Tabs.md +45 -0
- package/docs/reference/components/menus/MapBackground.md +32 -0
- package/docs/reference/components/menus/MapFilters.md +15 -0
- package/docs/reference/components/menus/MapLayers.md +15 -0
- package/docs/reference/components/menus/MapLegend.md +15 -0
- package/docs/reference/components/menus/PictureLegend.md +16 -0
- package/docs/reference/components/menus/PictureMetadata.md +15 -0
- package/docs/reference/components/menus/PlayerOptions.md +15 -0
- package/docs/reference/components/menus/QualityScoreDoc.md +15 -0
- package/docs/reference/components/menus/ReportForm.md +15 -0
- package/docs/reference/components/menus/ShareMenu.md +15 -0
- package/docs/reference/components/ui/Button.md +40 -0
- package/docs/reference/components/ui/ButtonGroup.md +36 -0
- package/docs/reference/components/ui/CopyButton.md +38 -0
- package/docs/reference/components/ui/Grade.md +32 -0
- package/docs/reference/components/ui/LinkButton.md +45 -0
- package/docs/reference/components/ui/ListGroup.md +22 -0
- package/docs/reference/components/ui/Loader.md +56 -0
- package/docs/reference/components/ui/Map.md +239 -0
- package/docs/reference/components/ui/MapMore.md +256 -0
- package/docs/reference/components/ui/Photo.md +385 -0
- package/docs/reference/components/ui/Popup.md +56 -0
- package/docs/reference/components/ui/ProgressBar.md +32 -0
- package/docs/reference/components/ui/QualityScore.md +45 -0
- package/docs/reference/components/ui/SearchBar.md +63 -0
- package/docs/reference/components/ui/TogglableGroup.md +39 -0
- package/docs/reference/components/ui/widgets/GeoSearch.md +32 -0
- package/docs/reference/components/ui/widgets/Legend.md +49 -0
- package/docs/reference/components/ui/widgets/MapFiltersButton.md +33 -0
- package/docs/reference/components/ui/widgets/MapLayersButton.md +15 -0
- package/docs/reference/components/ui/widgets/OSMEditors.md +15 -0
- package/docs/reference/components/ui/widgets/PictureLegendActions.md +32 -0
- package/docs/reference/components/ui/widgets/Player.md +33 -0
- package/docs/reference/components/ui/widgets/Zoom.md +15 -0
- package/docs/reference/utils/API.md +334 -0
- package/docs/reference/utils/InitParameters.md +68 -0
- package/docs/reference/utils/URLHandler.md +107 -0
- package/docs/reference.md +79 -0
- package/docs/shortcuts.md +11 -0
- package/docs/tutorials/aerial_imagery.md +19 -0
- package/docs/tutorials/authentication.md +10 -0
- package/docs/tutorials/custom_widgets.md +59 -0
- package/docs/tutorials/map_style.md +39 -0
- package/docs/tutorials/migrate_v4.md +153 -0
- package/docs/tutorials/synced_coverage.md +43 -0
- package/mkdocs.yml +66 -5
- package/package.json +22 -17
- package/public/editor.html +21 -29
- package/public/index.html +17 -12
- package/public/map.html +19 -18
- package/public/photo.html +55 -0
- package/public/viewer.html +22 -26
- package/public/widgets.html +306 -0
- package/scripts/doc.js +79 -0
- package/src/components/core/Basic.css +48 -0
- package/src/components/core/Basic.js +349 -0
- package/src/components/core/CoverageMap.css +9 -0
- package/src/components/core/CoverageMap.js +139 -0
- package/src/components/core/Editor.css +23 -0
- package/src/components/core/Editor.js +390 -0
- package/src/components/core/PhotoViewer.css +48 -0
- package/src/components/core/PhotoViewer.js +499 -0
- package/src/components/core/Viewer.css +98 -0
- package/src/components/core/Viewer.js +564 -0
- package/src/components/core/index.js +12 -0
- package/src/components/index.js +13 -0
- package/src/components/layout/BottomDrawer.js +257 -0
- package/src/components/layout/CorneredGrid.js +112 -0
- package/src/components/layout/Mini.js +117 -0
- package/src/components/layout/Tabs.js +133 -0
- package/src/components/layout/index.js +9 -0
- package/src/components/menus/MapBackground.js +106 -0
- package/src/components/menus/MapFilters.js +400 -0
- package/src/components/menus/MapLayers.js +143 -0
- package/src/components/menus/MapLegend.js +34 -0
- package/src/components/menus/PictureLegend.js +257 -0
- package/src/components/menus/PictureMetadata.js +317 -0
- package/src/components/menus/PlayerOptions.js +95 -0
- package/src/components/menus/QualityScoreDoc.js +36 -0
- package/src/components/menus/ReportForm.js +133 -0
- package/src/components/menus/Share.js +100 -0
- package/src/components/menus/index.js +15 -0
- package/src/components/styles.js +383 -0
- package/src/components/ui/Button.js +77 -0
- package/src/components/ui/ButtonGroup.css +57 -0
- package/src/components/ui/ButtonGroup.js +68 -0
- package/src/components/ui/CopyButton.js +106 -0
- package/src/components/ui/Grade.js +54 -0
- package/src/components/ui/LinkButton.js +67 -0
- package/src/components/ui/ListGroup.js +66 -0
- package/src/components/ui/Loader.js +203 -0
- package/src/components/{Map.css → ui/Map.css} +5 -17
- package/src/components/{Map.js → ui/Map.js} +148 -156
- package/src/components/ui/MapMore.js +324 -0
- package/src/components/{Photo.css → ui/Photo.css} +6 -6
- package/src/components/{Photo.js → ui/Photo.js} +313 -101
- package/src/components/ui/Popup.js +145 -0
- package/src/components/ui/ProgressBar.js +104 -0
- package/src/components/ui/QualityScore.js +147 -0
- package/src/components/ui/SearchBar.js +367 -0
- package/src/components/ui/TogglableGroup.js +157 -0
- package/src/components/ui/index.js +22 -0
- package/src/components/ui/widgets/GeoSearch.css +21 -0
- package/src/components/ui/widgets/GeoSearch.js +139 -0
- package/src/components/ui/widgets/Legend.js +113 -0
- package/src/components/ui/widgets/MapFiltersButton.js +104 -0
- package/src/components/ui/widgets/MapLayersButton.js +79 -0
- package/src/components/ui/widgets/OSMEditors.js +155 -0
- package/src/components/ui/widgets/PictureLegendActions.js +117 -0
- package/src/components/ui/widgets/Player.css +7 -0
- package/src/components/ui/widgets/Player.js +151 -0
- package/src/components/ui/widgets/Zoom.js +82 -0
- package/src/components/ui/widgets/index.js +13 -0
- package/src/img/loader_base.jpg +0 -0
- package/src/img/panoramax.svg +13 -0
- package/src/img/switch_big.svg +20 -10
- package/src/index.js +7 -9
- package/src/translations/br.json +1 -0
- package/src/translations/da.json +38 -15
- package/src/translations/de.json +5 -3
- package/src/translations/en.json +35 -15
- package/src/translations/eo.json +38 -15
- package/src/translations/es.json +1 -1
- package/src/translations/fr.json +36 -16
- package/src/translations/hu.json +1 -1
- package/src/translations/it.json +39 -16
- package/src/translations/ja.json +182 -1
- package/src/translations/nl.json +106 -6
- package/src/translations/pl.json +1 -1
- package/src/translations/sv.json +182 -0
- package/src/translations/zh_Hant.json +35 -14
- package/src/utils/API.js +109 -49
- package/src/utils/InitParameters.js +388 -0
- package/src/utils/PhotoAdapter.js +1 -0
- package/src/utils/URLHandler.js +362 -0
- package/src/utils/geocoder.js +152 -0
- package/src/utils/{I18n.js → i18n.js} +7 -3
- package/src/utils/index.js +11 -0
- package/src/utils/{Map.js → map.js} +256 -77
- package/src/utils/picture.js +442 -0
- package/src/utils/utils.js +324 -0
- package/src/utils/widgets.js +55 -0
- package/tests/components/core/Basic.test.js +121 -0
- package/tests/components/core/BasicMock.js +25 -0
- package/tests/components/core/CoverageMap.test.js +20 -0
- package/tests/components/core/Editor.test.js +20 -0
- package/tests/components/core/PhotoViewer.test.js +57 -0
- package/tests/components/core/Viewer.test.js +84 -0
- package/tests/components/core/__snapshots__/PhotoViewer.test.js.snap +73 -0
- package/tests/components/core/__snapshots__/Viewer.test.js.snap +145 -0
- package/tests/components/ui/CopyButton.test.js +52 -0
- package/tests/components/ui/Loader.test.js +55 -0
- package/tests/components/{Map.test.js → ui/Map.test.js} +73 -61
- package/tests/components/{Photo.test.js → ui/Photo.test.js} +97 -63
- package/tests/components/ui/Popup.test.js +26 -0
- package/tests/components/ui/QualityScore.test.js +18 -0
- package/tests/components/ui/SearchBar.test.js +110 -0
- package/tests/components/ui/__snapshots__/CopyButton.test.js.snap +33 -0
- package/tests/components/ui/__snapshots__/Loader.test.js.snap +56 -0
- package/tests/components/{__snapshots__ → ui/__snapshots__}/Map.test.js.snap +11 -38
- package/tests/components/{__snapshots__ → ui/__snapshots__}/Photo.test.js.snap +70 -6
- package/tests/components/ui/__snapshots__/Popup.test.js.snap +29 -0
- package/tests/components/ui/__snapshots__/QualityScore.test.js.snap +11 -0
- package/tests/components/ui/__snapshots__/SearchBar.test.js.snap +65 -0
- package/tests/utils/API.test.js +83 -83
- package/tests/utils/InitParameters.test.js +499 -0
- package/tests/utils/URLHandler.test.js +401 -0
- package/tests/utils/__snapshots__/API.test.js.snap +10 -0
- package/tests/utils/__snapshots__/URLHandler.test.js.snap +21 -0
- package/tests/utils/__snapshots__/{Map.test.js.snap → geocoder.test.js.snap} +1 -1
- package/tests/utils/__snapshots__/map.test.js.snap +11 -0
- package/tests/utils/__snapshots__/picture.test.js.snap +327 -0
- package/tests/utils/__snapshots__/widgets.test.js.snap +19 -0
- package/tests/utils/geocoder.test.js +37 -0
- package/tests/utils/{I18n.test.js → i18n.test.js} +8 -8
- package/tests/utils/map.test.js +126 -0
- package/tests/utils/picture.test.js +745 -0
- package/tests/utils/utils.test.js +288 -0
- package/tests/utils/widgets.test.js +31 -0
- package/docs/01_Start.md +0 -149
- package/docs/02_Usage.md +0 -831
- package/docs/04_Advanced_examples.md +0 -216
- package/src/Editor.css +0 -37
- package/src/Editor.js +0 -361
- package/src/StandaloneMap.js +0 -114
- package/src/Viewer.css +0 -203
- package/src/Viewer.js +0 -1246
- package/src/components/CoreView.css +0 -70
- package/src/components/CoreView.js +0 -175
- package/src/components/Loader.css +0 -74
- package/src/components/Loader.js +0 -120
- package/src/img/loader_hd.jpg +0 -0
- package/src/utils/Exif.js +0 -193
- package/src/utils/Utils.js +0 -631
- package/src/utils/Widgets.js +0 -562
- package/src/viewer/URLHash.js +0 -469
- package/src/viewer/Widgets.css +0 -880
- package/src/viewer/Widgets.js +0 -1470
- package/tests/Editor.test.js +0 -126
- package/tests/StandaloneMap.test.js +0 -45
- package/tests/Viewer.test.js +0 -366
- package/tests/__snapshots__/Editor.test.js.snap +0 -298
- package/tests/__snapshots__/StandaloneMap.test.js.snap +0 -30
- package/tests/__snapshots__/Viewer.test.js.snap +0 -195
- package/tests/components/CoreView.test.js +0 -92
- package/tests/components/Loader.test.js +0 -38
- package/tests/components/__snapshots__/Loader.test.js.snap +0 -15
- package/tests/utils/Exif.test.js +0 -124
- package/tests/utils/Map.test.js +0 -113
- package/tests/utils/Utils.test.js +0 -300
- package/tests/utils/Widgets.test.js +0 -107
- package/tests/utils/__snapshots__/Exif.test.js.snap +0 -43
- package/tests/utils/__snapshots__/Utils.test.js.snap +0 -41
- package/tests/utils/__snapshots__/Widgets.test.js.snap +0 -44
- package/tests/viewer/URLHash.test.js +0 -559
- package/tests/viewer/Widgets.test.js +0 -127
- package/tests/viewer/__snapshots__/URLHash.test.js.snap +0 -108
- package/tests/viewer/__snapshots__/Widgets.test.js.snap +0 -403
package/tests/Editor.test.js
DELETED
|
@@ -1,126 +0,0 @@
|
|
|
1
|
-
import Editor from "../src/Editor";
|
|
2
|
-
|
|
3
|
-
jest.mock("maplibre-gl", () => ({
|
|
4
|
-
addProtocol: jest.fn(),
|
|
5
|
-
}));
|
|
6
|
-
|
|
7
|
-
jest.mock("@photo-sphere-viewer/core", () => ({
|
|
8
|
-
SYSTEM: {},
|
|
9
|
-
}));
|
|
10
|
-
|
|
11
|
-
jest.mock("../src/components/Photo", () => class {
|
|
12
|
-
constructor() {
|
|
13
|
-
this._myVTour = { datasource: {} };
|
|
14
|
-
this._api = {
|
|
15
|
-
onceReady: () => Promise.resolves(),
|
|
16
|
-
};
|
|
17
|
-
}
|
|
18
|
-
});
|
|
19
|
-
|
|
20
|
-
jest.mock("../src/components/Map", () => class {});
|
|
21
|
-
global.AbortSignal = { timeout: jest.fn() };
|
|
22
|
-
|
|
23
|
-
const API_URL = "http://localhost:5000/api/search";
|
|
24
|
-
|
|
25
|
-
describe("constructor", () => {
|
|
26
|
-
it("works", () => {
|
|
27
|
-
const d = document.createElement("div");
|
|
28
|
-
const ed = new Editor(d, API_URL, { testing: true, selectedSequence: "bla" });
|
|
29
|
-
expect(ed).toBeDefined();
|
|
30
|
-
});
|
|
31
|
-
|
|
32
|
-
it("fails if no sequence is selected", () => {
|
|
33
|
-
global.console = { error: jest.fn() };
|
|
34
|
-
const d = document.createElement("div");
|
|
35
|
-
expect(() => new Editor(d, API_URL, { testing: true })).toThrow("No sequence is selected");
|
|
36
|
-
});
|
|
37
|
-
});
|
|
38
|
-
|
|
39
|
-
describe("_createMapStyle", () => {
|
|
40
|
-
it("works", () => {
|
|
41
|
-
const d = document.createElement("div");
|
|
42
|
-
const ed = new Editor(d, API_URL, { testing: true, selectedSequence: "bla" });
|
|
43
|
-
expect(ed._createMapStyle()).toMatchSnapshot();
|
|
44
|
-
});
|
|
45
|
-
});
|
|
46
|
-
|
|
47
|
-
describe("_bindPicturesEvents", () => {
|
|
48
|
-
it("works", () => {
|
|
49
|
-
const d = document.createElement("div");
|
|
50
|
-
const ed = new Editor(d, API_URL, { testing: true, selectedSequence: "bla" });
|
|
51
|
-
ed.map = { on: jest.fn(), _onPictureClick: jest.fn() };
|
|
52
|
-
ed._bindPicturesEvents();
|
|
53
|
-
expect(ed.map.on.mock.calls).toMatchSnapshot();
|
|
54
|
-
});
|
|
55
|
-
});
|
|
56
|
-
|
|
57
|
-
describe("_getNode", () => {
|
|
58
|
-
it("works", () => {
|
|
59
|
-
const d = document.createElement("div");
|
|
60
|
-
const ed = new Editor(d, API_URL, { testing: true, selectedSequence: "bla" });
|
|
61
|
-
ed._sequenceData = [
|
|
62
|
-
{
|
|
63
|
-
assets: { pic: { roles: ["visual"], type: "image/jpeg", href: "1.jpg" } },
|
|
64
|
-
links: [],
|
|
65
|
-
properties: { id: "1" },
|
|
66
|
-
geometry: { coordinates: [0,0] }
|
|
67
|
-
},
|
|
68
|
-
{
|
|
69
|
-
assets: { pic: { roles: ["visual"], type: "image/jpeg", href: "2.jpg" } },
|
|
70
|
-
links: [],
|
|
71
|
-
properties: { id: "2" },
|
|
72
|
-
geometry: { coordinates: [0.1,0.1] }
|
|
73
|
-
},
|
|
74
|
-
];
|
|
75
|
-
expect(ed._getNode("2")).toMatchSnapshot();
|
|
76
|
-
});
|
|
77
|
-
});
|
|
78
|
-
|
|
79
|
-
describe("_addMapBackgroundWidget", () => {
|
|
80
|
-
it("works", () => {
|
|
81
|
-
const d = document.createElement("div");
|
|
82
|
-
const ed = new Editor(d, API_URL, { testing: true, selectedSequence: "bla" });
|
|
83
|
-
ed.map = { getBackground: jest.fn() };
|
|
84
|
-
ed._addMapBackgroundWidget();
|
|
85
|
-
expect(ed.mapContainer).toMatchSnapshot();
|
|
86
|
-
});
|
|
87
|
-
});
|
|
88
|
-
|
|
89
|
-
describe("previewSequenceHeadingChange", () => {
|
|
90
|
-
it("works when setting preview", () => {
|
|
91
|
-
const d = document.createElement("div");
|
|
92
|
-
const ed = new Editor(d, API_URL, { testing: true, selectedSequence: "bla" });
|
|
93
|
-
ed.psv = { getPictureRelativeHeading: () => 12 };
|
|
94
|
-
ed.map = {
|
|
95
|
-
getLayer: () => undefined,
|
|
96
|
-
addLayer: jest.fn(),
|
|
97
|
-
setLayoutProperty: jest.fn(),
|
|
98
|
-
setFilter: jest.fn(),
|
|
99
|
-
_picMarker: { setRotation: jest.fn() },
|
|
100
|
-
_picMarkerPreview: { remove: jest.fn() },
|
|
101
|
-
};
|
|
102
|
-
ed.previewSequenceHeadingChange(10);
|
|
103
|
-
expect(ed.map.addLayer.mock.calls).toMatchSnapshot();
|
|
104
|
-
expect(ed.map.setLayoutProperty.mock.calls).toMatchSnapshot();
|
|
105
|
-
expect(ed.map.setFilter.mock.calls).toMatchSnapshot();
|
|
106
|
-
});
|
|
107
|
-
|
|
108
|
-
it("works when unsetting", () => {
|
|
109
|
-
const d = document.createElement("div");
|
|
110
|
-
const ed = new Editor(d, API_URL, { testing: true, selectedSequence: "bla" });
|
|
111
|
-
ed.psv = { getPictureRelativeHeading: () => 12 };
|
|
112
|
-
ed.map = {
|
|
113
|
-
getLayer: () => true,
|
|
114
|
-
addLayer: jest.fn(),
|
|
115
|
-
setLayoutProperty: jest.fn(),
|
|
116
|
-
setFilter: jest.fn(),
|
|
117
|
-
_picMarker: { setRotation: jest.fn() },
|
|
118
|
-
_picMarkerPreview: { remove: jest.fn() },
|
|
119
|
-
};
|
|
120
|
-
ed.previewSequenceHeadingChange(10);
|
|
121
|
-
ed.previewSequenceHeadingChange();
|
|
122
|
-
expect(ed.map.addLayer.mock.calls).toMatchSnapshot();
|
|
123
|
-
expect(ed.map.setLayoutProperty.mock.calls).toMatchSnapshot();
|
|
124
|
-
expect(ed.map.setFilter.mock.calls).toMatchSnapshot();
|
|
125
|
-
});
|
|
126
|
-
});
|
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
import StandaloneMap from "../src/StandaloneMap";
|
|
2
|
-
|
|
3
|
-
jest.mock("maplibre-gl", () => ({
|
|
4
|
-
addProtocol: jest.fn(),
|
|
5
|
-
}));
|
|
6
|
-
|
|
7
|
-
jest.mock("../src/components/Map", () => class {});
|
|
8
|
-
global.AbortSignal = { timeout: jest.fn() };
|
|
9
|
-
|
|
10
|
-
const API_URL = "http://localhost:5000/api/search";
|
|
11
|
-
|
|
12
|
-
describe("constructor", () => {
|
|
13
|
-
it("works", () => {
|
|
14
|
-
const d = document.createElement("div");
|
|
15
|
-
const ed = new StandaloneMap(d, API_URL, { testing: true });
|
|
16
|
-
expect(ed).toBeDefined();
|
|
17
|
-
});
|
|
18
|
-
});
|
|
19
|
-
|
|
20
|
-
describe("destroy", () => {
|
|
21
|
-
it("works", () => {
|
|
22
|
-
const d = document.createElement("div");
|
|
23
|
-
const ed = new StandaloneMap(d, API_URL, { testing: true });
|
|
24
|
-
const mapDestroy = jest.fn();
|
|
25
|
-
ed.map = { destroy: mapDestroy };
|
|
26
|
-
ed.destroy();
|
|
27
|
-
expect(mapDestroy.mock.calls).toMatchSnapshot();
|
|
28
|
-
expect(ed.container.innerHTML).toBe("");
|
|
29
|
-
});
|
|
30
|
-
});
|
|
31
|
-
|
|
32
|
-
describe("_onSelect", () => {
|
|
33
|
-
it("works", () => {
|
|
34
|
-
const d = document.createElement("div");
|
|
35
|
-
const ed = new StandaloneMap(d, API_URL, { testing: true });
|
|
36
|
-
ed.map = {
|
|
37
|
-
queryRenderedFeatures: jest.fn(() => ({ features: [ {id: "bla"} ] })),
|
|
38
|
-
_userLayers: new Set(["geovisio", "toto"]),
|
|
39
|
-
_attachPreviewToPictures: jest.fn(),
|
|
40
|
-
};
|
|
41
|
-
ed._onSelect({ detail: { picId: "bla", seqId: "blo" } });
|
|
42
|
-
expect(ed.map.queryRenderedFeatures.mock.calls).toMatchSnapshot();
|
|
43
|
-
expect(ed.map._attachPreviewToPictures.mock.calls).toMatchSnapshot();
|
|
44
|
-
});
|
|
45
|
-
});
|
package/tests/Viewer.test.js
DELETED
|
@@ -1,366 +0,0 @@
|
|
|
1
|
-
import Viewer from "../src/Viewer";
|
|
2
|
-
|
|
3
|
-
jest.mock("@photo-sphere-viewer/core", () => ({
|
|
4
|
-
Viewer: class {},
|
|
5
|
-
SYSTEM: {},
|
|
6
|
-
DEFAULTS: {},
|
|
7
|
-
}));
|
|
8
|
-
|
|
9
|
-
jest.mock("@photo-sphere-viewer/equirectangular-tiles-adapter", () => ({
|
|
10
|
-
EquirectangularTilesAdapter: jest.fn(),
|
|
11
|
-
}));
|
|
12
|
-
|
|
13
|
-
jest.mock("@photo-sphere-viewer/virtual-tour-plugin", () => ({
|
|
14
|
-
VirtualTourPlugin: jest.fn(),
|
|
15
|
-
}));
|
|
16
|
-
|
|
17
|
-
jest.mock("maplibre-gl", () => ({
|
|
18
|
-
addProtocol: jest.fn(),
|
|
19
|
-
Map: class {},
|
|
20
|
-
}));
|
|
21
|
-
|
|
22
|
-
global.AbortSignal = { timeout: jest.fn() };
|
|
23
|
-
|
|
24
|
-
const API_URL = "http://localhost:5000/api/search";
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
describe("constructor", () => {
|
|
28
|
-
it("works", () => {
|
|
29
|
-
const d = document.createElement("div");
|
|
30
|
-
const v = new Viewer(d, API_URL, { testing: true });
|
|
31
|
-
expect(v).toBeDefined();
|
|
32
|
-
});
|
|
33
|
-
});
|
|
34
|
-
|
|
35
|
-
describe("destroy", () => {
|
|
36
|
-
it("works", () => {
|
|
37
|
-
const d = document.createElement("div");
|
|
38
|
-
d.id = "geovisio";
|
|
39
|
-
document.body.appendChild(d);
|
|
40
|
-
const v = new Viewer(d, API_URL, { testing: true });
|
|
41
|
-
v._initContainerStructure("geovisio");
|
|
42
|
-
v._hash = { destroy: jest.fn() };
|
|
43
|
-
v._widgets = { destroy: jest.fn() };
|
|
44
|
-
v.map = { destroy: jest.fn() };
|
|
45
|
-
v.psv = { destroy: jest.fn() };
|
|
46
|
-
|
|
47
|
-
v.destroy();
|
|
48
|
-
|
|
49
|
-
expect(v._api).toBeUndefined();
|
|
50
|
-
expect(v._hash).toBeUndefined();
|
|
51
|
-
expect(v.map).toBeUndefined();
|
|
52
|
-
expect(v.psv).toBeUndefined();
|
|
53
|
-
expect(d.innerHTML).toBe("");
|
|
54
|
-
});
|
|
55
|
-
});
|
|
56
|
-
|
|
57
|
-
describe("_initContainerStructure", () => {
|
|
58
|
-
beforeEach(() => {
|
|
59
|
-
document.body.innerHTML = "";
|
|
60
|
-
});
|
|
61
|
-
|
|
62
|
-
it("works with string", () => {
|
|
63
|
-
const d = document.createElement("div");
|
|
64
|
-
d.id = "geovisio";
|
|
65
|
-
document.body.appendChild(d);
|
|
66
|
-
const v = new Viewer("geovisio", API_URL, { testing: true });
|
|
67
|
-
v._initContainerStructure();
|
|
68
|
-
expect([...d.children].find(n => n.className.includes("gvs-main"))).toBeDefined();
|
|
69
|
-
expect([...d.children].find(n => n.className.includes("gvs-mini"))).toBeDefined();
|
|
70
|
-
expect(d.className).toBe("gvs gvs-viewer");
|
|
71
|
-
});
|
|
72
|
-
|
|
73
|
-
it("works with Element", () => {
|
|
74
|
-
const d = document.createElement("div");
|
|
75
|
-
const v = new Viewer(d, API_URL, { testing: true });
|
|
76
|
-
v._initContainerStructure();
|
|
77
|
-
expect([...d.children].find(n => n.className.includes("gvs-main"))).toBeDefined();
|
|
78
|
-
expect([...d.children].find(n => n.className.includes("gvs-mini"))).toBeDefined();
|
|
79
|
-
expect(d.className).toBe("gvs gvs-viewer");
|
|
80
|
-
});
|
|
81
|
-
});
|
|
82
|
-
|
|
83
|
-
describe("setPopup", () => {
|
|
84
|
-
it("opens", () => {
|
|
85
|
-
const d = document.createElement("div");
|
|
86
|
-
const v = new Viewer(d, API_URL, { testing: true });
|
|
87
|
-
v._initContainerStructure();
|
|
88
|
-
v.psv = {
|
|
89
|
-
startKeyboardControl: jest.fn(),
|
|
90
|
-
stopKeyboardControl: jest.fn(),
|
|
91
|
-
};
|
|
92
|
-
v.setPopup(true, "BLABLABLA");
|
|
93
|
-
expect(v.popupContainer.innerHTML).toMatchSnapshot();
|
|
94
|
-
expect(v.popupContainer.classList.contains("gvs-hidden")).toBeFalsy();
|
|
95
|
-
});
|
|
96
|
-
|
|
97
|
-
it("closes", () => {
|
|
98
|
-
const d = document.createElement("div");
|
|
99
|
-
const v = new Viewer(d, API_URL, { map: false, testing: true });
|
|
100
|
-
v._initContainerStructure();
|
|
101
|
-
v.psv = {
|
|
102
|
-
autoSize: jest.fn(),
|
|
103
|
-
startKeyboardControl: jest.fn(),
|
|
104
|
-
stopKeyboardControl: jest.fn(),
|
|
105
|
-
adapter: { __refresh: jest.fn() },
|
|
106
|
-
needsUpdate: jest.fn(),
|
|
107
|
-
_myVTour: { getCurrentNode: jest.fn() },
|
|
108
|
-
};
|
|
109
|
-
v.setPopup(true, "BLABLABLA");
|
|
110
|
-
v.setPopup(false);
|
|
111
|
-
expect(v.popupContainer.classList.contains("gvs-hidden")).toBeTruthy();
|
|
112
|
-
});
|
|
113
|
-
|
|
114
|
-
it("reopens", () => {
|
|
115
|
-
const d = document.createElement("div");
|
|
116
|
-
const v = new Viewer(d, API_URL, { testing: true });
|
|
117
|
-
v._initContainerStructure();
|
|
118
|
-
v.psv = {
|
|
119
|
-
autoSize: jest.fn(),
|
|
120
|
-
startKeyboardControl: jest.fn(),
|
|
121
|
-
stopKeyboardControl: jest.fn(),
|
|
122
|
-
adapter: { __refresh: jest.fn() },
|
|
123
|
-
needsUpdate: jest.fn(),
|
|
124
|
-
_myVTour: { getCurrentNode: jest.fn() },
|
|
125
|
-
};
|
|
126
|
-
v.setPopup(true, "BLABLABLA");
|
|
127
|
-
v.setPopup(false);
|
|
128
|
-
v.setPopup(true);
|
|
129
|
-
expect(v.popupContainer.innerHTML).toMatchSnapshot();
|
|
130
|
-
expect(v.popupContainer.classList.contains("gvs-hidden")).toBeFalsy();
|
|
131
|
-
});
|
|
132
|
-
});
|
|
133
|
-
|
|
134
|
-
describe("playSequence", () => {
|
|
135
|
-
it("sends event", () => {
|
|
136
|
-
const d = document.createElement("div");
|
|
137
|
-
const v = new Viewer(d, API_URL, { testing: true });
|
|
138
|
-
return expect(new Promise(resolve => {
|
|
139
|
-
v.addEventListener("sequence-playing", resolve);
|
|
140
|
-
v.playSequence();
|
|
141
|
-
})).resolves.toBeDefined();
|
|
142
|
-
});
|
|
143
|
-
});
|
|
144
|
-
|
|
145
|
-
describe("stopSequence", () => {
|
|
146
|
-
it("sends event", async () => {
|
|
147
|
-
const d = document.createElement("div");
|
|
148
|
-
const v = new Viewer(d, API_URL, { testing: true });
|
|
149
|
-
v.psv = {
|
|
150
|
-
adapter: { __refresh: jest.fn() },
|
|
151
|
-
needsUpdate: jest.fn(),
|
|
152
|
-
_myVTour: { getCurrentNode: jest.fn() },
|
|
153
|
-
}
|
|
154
|
-
return expect(new Promise(resolve => {
|
|
155
|
-
v.addEventListener("sequence-stopped", resolve);
|
|
156
|
-
v.stopSequence();
|
|
157
|
-
})).resolves.toBeDefined();
|
|
158
|
-
});
|
|
159
|
-
});
|
|
160
|
-
|
|
161
|
-
describe("isSequencePlaying", () => {
|
|
162
|
-
it("is true when sequence is playing", () => {
|
|
163
|
-
const d = document.createElement("div");
|
|
164
|
-
const v = new Viewer(d, API_URL, { testing: true });
|
|
165
|
-
v.psv = { addEventListener: jest.fn() };
|
|
166
|
-
v.psv.goToNextPicture = jest.fn();
|
|
167
|
-
v.playSequence();
|
|
168
|
-
expect(v.isSequencePlaying()).toBe(true);
|
|
169
|
-
});
|
|
170
|
-
|
|
171
|
-
it("is false when sequence never played", () => {
|
|
172
|
-
const d = document.createElement("div");
|
|
173
|
-
const v = new Viewer(d, API_URL, { testing: true });
|
|
174
|
-
v.psv = { addEventListener: jest.fn() };
|
|
175
|
-
expect(v.isSequencePlaying()).toBe(false);
|
|
176
|
-
});
|
|
177
|
-
|
|
178
|
-
it("is false when sequence stopped", () => {
|
|
179
|
-
const d = document.createElement("div");
|
|
180
|
-
const v = new Viewer(d, API_URL, { testing: true });
|
|
181
|
-
v.psv = {
|
|
182
|
-
addEventListener: jest.fn(),
|
|
183
|
-
adapter: { __refresh: jest.fn() },
|
|
184
|
-
needsUpdate: jest.fn(),
|
|
185
|
-
_myVTour: { getCurrentNode: jest.fn() },
|
|
186
|
-
};
|
|
187
|
-
v.playSequence();
|
|
188
|
-
v.stopSequence();
|
|
189
|
-
expect(v.isSequencePlaying()).toBe(false);
|
|
190
|
-
});
|
|
191
|
-
});
|
|
192
|
-
|
|
193
|
-
describe("isMapWide", () => {
|
|
194
|
-
it("works with map small", () => {
|
|
195
|
-
const d = document.createElement("div");
|
|
196
|
-
const v = new Viewer(d, API_URL, { testing: true });
|
|
197
|
-
v._initContainerStructure(d);
|
|
198
|
-
v.map = {};
|
|
199
|
-
expect(v.isMapWide()).toBe(false);
|
|
200
|
-
});
|
|
201
|
-
|
|
202
|
-
it("works with map wide", () => {
|
|
203
|
-
const d = document.createElement("div");
|
|
204
|
-
const v = new Viewer(d, API_URL, { testing: true });
|
|
205
|
-
v._initContainerStructure(d);
|
|
206
|
-
v.map = {
|
|
207
|
-
keyboard: { enable: jest.fn() },
|
|
208
|
-
resize: jest.fn(),
|
|
209
|
-
getCanvas: () => ({ focus: jest.fn() })
|
|
210
|
-
};
|
|
211
|
-
v.psv = {
|
|
212
|
-
autoSize: jest.fn(),
|
|
213
|
-
stopKeyboardControl: jest.fn(),
|
|
214
|
-
adapter: { __refresh: jest.fn() },
|
|
215
|
-
needsUpdate: jest.fn(),
|
|
216
|
-
_myVTour: { getCurrentNode: jest.fn() },
|
|
217
|
-
};
|
|
218
|
-
v.setFocus("map");
|
|
219
|
-
expect(v.isMapWide()).toBe(true);
|
|
220
|
-
});
|
|
221
|
-
|
|
222
|
-
it("fails if no map set", () => {
|
|
223
|
-
const d = document.createElement("div");
|
|
224
|
-
const v = new Viewer(d, API_URL, { testing: true });
|
|
225
|
-
v._initContainerStructure(d);
|
|
226
|
-
expect(() => v.isMapWide()).toThrow(new Error("Map is not enabled"));
|
|
227
|
-
});
|
|
228
|
-
});
|
|
229
|
-
|
|
230
|
-
describe("setFocus", () => {
|
|
231
|
-
it("changes focus from map to pic", () => {
|
|
232
|
-
const d = document.createElement("div");
|
|
233
|
-
const v = new Viewer(d, API_URL, { testing: true });
|
|
234
|
-
v._initContainerStructure(d);
|
|
235
|
-
v.dispatchEvent = jest.fn();
|
|
236
|
-
v.map = {
|
|
237
|
-
keyboard: { enable: jest.fn(), disable: jest.fn() },
|
|
238
|
-
resize: jest.fn(),
|
|
239
|
-
getCanvas: () => ({ focus: jest.fn() })
|
|
240
|
-
};
|
|
241
|
-
v.psv = {
|
|
242
|
-
autoSize: jest.fn(),
|
|
243
|
-
startKeyboardControl: jest.fn(),
|
|
244
|
-
stopKeyboardControl: jest.fn(),
|
|
245
|
-
adapter: { __refresh: jest.fn() },
|
|
246
|
-
needsUpdate: jest.fn(),
|
|
247
|
-
_myVTour: { getCurrentNode: jest.fn() },
|
|
248
|
-
};
|
|
249
|
-
v.setFocus("map");
|
|
250
|
-
expect(v.isMapWide()).toBe(true);
|
|
251
|
-
});
|
|
252
|
-
|
|
253
|
-
it("changes focus from pic to map", () => {
|
|
254
|
-
const d = document.createElement("div");
|
|
255
|
-
const v = new Viewer(d, API_URL, { testing: true });
|
|
256
|
-
v._initContainerStructure(d);
|
|
257
|
-
v.dispatchEvent = jest.fn();
|
|
258
|
-
v.map = {
|
|
259
|
-
keyboard: { enable: jest.fn(), disable: jest.fn() },
|
|
260
|
-
resize: jest.fn(),
|
|
261
|
-
getCanvas: () => ({ focus: jest.fn() })
|
|
262
|
-
};
|
|
263
|
-
v.psv = {
|
|
264
|
-
autoSize: jest.fn(),
|
|
265
|
-
startKeyboardControl: jest.fn(),
|
|
266
|
-
stopKeyboardControl: jest.fn(),
|
|
267
|
-
adapter: { __refresh: jest.fn() },
|
|
268
|
-
needsUpdate: jest.fn(),
|
|
269
|
-
_myVTour: { getCurrentNode: jest.fn() },
|
|
270
|
-
};
|
|
271
|
-
v.setFocus("pic");
|
|
272
|
-
expect(v.isMapWide()).toBe(false);
|
|
273
|
-
});
|
|
274
|
-
|
|
275
|
-
it("skips event", async () => {
|
|
276
|
-
const d = document.createElement("div");
|
|
277
|
-
const v = new Viewer(d, API_URL, { testing: true });
|
|
278
|
-
v._initContainerStructure(d);
|
|
279
|
-
v.dispatchEvent = jest.fn();
|
|
280
|
-
v.map = {
|
|
281
|
-
keyboard: { enable: jest.fn(), disable: jest.fn() },
|
|
282
|
-
resize: jest.fn(),
|
|
283
|
-
getCanvas: () => ({ focus: jest.fn() })
|
|
284
|
-
};
|
|
285
|
-
v.psv = {
|
|
286
|
-
autoSize: jest.fn(),
|
|
287
|
-
startKeyboardControl: jest.fn(),
|
|
288
|
-
stopKeyboardControl: jest.fn(),
|
|
289
|
-
adapter: { __refresh: jest.fn() },
|
|
290
|
-
needsUpdate: jest.fn(),
|
|
291
|
-
_myVTour: { getCurrentNode: jest.fn() },
|
|
292
|
-
};
|
|
293
|
-
v.setFocus("map", true);
|
|
294
|
-
expect(v.dispatchEvent.mock.calls).toEqual([]);
|
|
295
|
-
});
|
|
296
|
-
|
|
297
|
-
it("fails if param is invalid", () => {
|
|
298
|
-
const d = document.createElement("div");
|
|
299
|
-
const v = new Viewer(d, API_URL, { testing: true });
|
|
300
|
-
expect(() => v.setFocus()).toThrow(new Error("Invalid focus value (should be pic or map)"));
|
|
301
|
-
});
|
|
302
|
-
|
|
303
|
-
it("fails if no map set", () => {
|
|
304
|
-
const d = document.createElement("div");
|
|
305
|
-
const v = new Viewer(d, API_URL, { map: false, testing: true });
|
|
306
|
-
expect(() => v.setFocus("map")).toThrow(new Error("Map is not enabled"));
|
|
307
|
-
});
|
|
308
|
-
});
|
|
309
|
-
|
|
310
|
-
describe("getPicturesNavigation", () => {
|
|
311
|
-
it("works", () => {
|
|
312
|
-
const d = document.createElement("div");
|
|
313
|
-
const v = new Viewer(d, API_URL, { picturesNavigation: "pic", testing: true });
|
|
314
|
-
expect(v.getPicturesNavigation()).toBe("pic");
|
|
315
|
-
v._picNav = "seq";
|
|
316
|
-
expect(v.getPicturesNavigation()).toBe("seq");
|
|
317
|
-
});
|
|
318
|
-
});
|
|
319
|
-
|
|
320
|
-
describe("setPicturesNavigation", () => {
|
|
321
|
-
it("works", () => {
|
|
322
|
-
const d = document.createElement("div");
|
|
323
|
-
const v = new Viewer(d, API_URL, { testing: true });
|
|
324
|
-
const eventWatcher = jest.fn();
|
|
325
|
-
v.addEventListener("pictures-navigation-changed", eventWatcher);
|
|
326
|
-
expect(v.getPicturesNavigation()).toBe("any");
|
|
327
|
-
v.setPicturesNavigation("pic");
|
|
328
|
-
expect(v.getPicturesNavigation()).toBe("pic");
|
|
329
|
-
v.setPicturesNavigation("seq");
|
|
330
|
-
expect(v.getPicturesNavigation()).toBe("seq");
|
|
331
|
-
v.setPicturesNavigation("any");
|
|
332
|
-
expect(v.getPicturesNavigation()).toBe("any");
|
|
333
|
-
expect(eventWatcher.mock.calls).toMatchSnapshot();
|
|
334
|
-
});
|
|
335
|
-
});
|
|
336
|
-
|
|
337
|
-
describe("setFilters", () => {
|
|
338
|
-
it("works", () => {
|
|
339
|
-
const d = document.createElement("div");
|
|
340
|
-
const v = new Viewer(d, API_URL, { testing: true });
|
|
341
|
-
v.map = {
|
|
342
|
-
_userLayers: new Set(["geovisio"]),
|
|
343
|
-
getZoom: jest.fn(),
|
|
344
|
-
reloadLayersStyles: jest.fn(),
|
|
345
|
-
filterUserLayersContent: jest.fn(),
|
|
346
|
-
getVisibleUsers: () => ["geovisio"],
|
|
347
|
-
_hasGridStats: () => false,
|
|
348
|
-
};
|
|
349
|
-
v.dispatchEvent = jest.fn();
|
|
350
|
-
Date.prototype.getDate = () => 8;
|
|
351
|
-
Date.prototype.setDate = jest.fn();
|
|
352
|
-
Date.prototype.toISOString = () => "2023-08-09T00:00:00Z";
|
|
353
|
-
v.setFilters({
|
|
354
|
-
"minDate": "2023-01-01",
|
|
355
|
-
"maxDate": "2023-08-08",
|
|
356
|
-
"camera": "sony",
|
|
357
|
-
"type": "equirectangular",
|
|
358
|
-
"theme": "age",
|
|
359
|
-
});
|
|
360
|
-
v.setFilters({});
|
|
361
|
-
expect(v._mapTheme).toBe("age");
|
|
362
|
-
expect(v.dispatchEvent.mock.calls).toMatchSnapshot();
|
|
363
|
-
expect(v.map.reloadLayersStyles.mock.calls).toMatchSnapshot();
|
|
364
|
-
expect(v.map.filterUserLayersContent.mock.calls).toMatchSnapshot();
|
|
365
|
-
});
|
|
366
|
-
});
|