@panoramax/web-viewer 3.2.3 → 4.0.0-develop-9f9cf858
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 +56 -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
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
import Viewer from "../../../src/components/core/Viewer";
|
|
2
|
+
import "./BasicMock";
|
|
3
|
+
|
|
4
|
+
jest.mock("../../../src/components/core/PhotoViewer", () => (
|
|
5
|
+
class PhotoViewer extends EventTarget {
|
|
6
|
+
constructor() {
|
|
7
|
+
super();
|
|
8
|
+
this.loader = { setAttribute: jest.fn() };
|
|
9
|
+
this.api = {
|
|
10
|
+
getMapStyle: () => ({}),
|
|
11
|
+
_getMapRequestTransform: () => ({}),
|
|
12
|
+
_endpoints: {},
|
|
13
|
+
};
|
|
14
|
+
this._t = { maplibre: {}, psv: {} };
|
|
15
|
+
this.grid = { appendChild: jest.fn() };
|
|
16
|
+
}
|
|
17
|
+
getAttribute() { return null; }
|
|
18
|
+
isWidthSmall() { return false; }
|
|
19
|
+
isHeightSmall() { return false; }
|
|
20
|
+
getSubComponentsNames() {
|
|
21
|
+
return ["loader", "api", "psv", "grid", "popup", "urlHandler"];
|
|
22
|
+
}
|
|
23
|
+
onceAPIReady() {
|
|
24
|
+
return Promise.resolve();
|
|
25
|
+
}
|
|
26
|
+
static GetJSONConverter() {
|
|
27
|
+
return {};
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
));
|
|
31
|
+
|
|
32
|
+
let comp;
|
|
33
|
+
global.console = { info: jest.fn(), error: jest.fn(), warn: jest.fn(), log: global.console.log };
|
|
34
|
+
|
|
35
|
+
beforeEach(() => comp = new Viewer());
|
|
36
|
+
afterEach(() => jest.clearAllMocks());
|
|
37
|
+
|
|
38
|
+
describe("_initWidgets", () => {
|
|
39
|
+
let initParamsMock;
|
|
40
|
+
|
|
41
|
+
beforeEach(() => {
|
|
42
|
+
comp.grid.appendChild = jest.fn();
|
|
43
|
+
|
|
44
|
+
// Mock the return value of getParentPostInit
|
|
45
|
+
initParamsMock = {
|
|
46
|
+
widgets: "true",
|
|
47
|
+
focus: "pic",
|
|
48
|
+
picture: "somePicture",
|
|
49
|
+
};
|
|
50
|
+
comp._createInitParamsHandler();
|
|
51
|
+
comp._initParams.getParentPostInit = jest.fn();
|
|
52
|
+
comp._initParams.getParentPostInit.mockReturnValue(initParamsMock);
|
|
53
|
+
});
|
|
54
|
+
|
|
55
|
+
it("should not add widgets if widgets is false", () => {
|
|
56
|
+
initParamsMock.widgets = "false";
|
|
57
|
+
comp._initWidgets();
|
|
58
|
+
expect(comp.grid.appendChild).not.toHaveBeenCalled();
|
|
59
|
+
});
|
|
60
|
+
|
|
61
|
+
it("should handle widgets if width is not small", () => {
|
|
62
|
+
comp.isWidthSmall = () => false;
|
|
63
|
+
comp._initWidgets();
|
|
64
|
+
expect(comp.grid.appendChild).toMatchSnapshot();
|
|
65
|
+
});
|
|
66
|
+
|
|
67
|
+
it("should handle widgets if width is small", () => {
|
|
68
|
+
comp.isWidthSmall = () => true;
|
|
69
|
+
comp._initWidgets();
|
|
70
|
+
expect(comp.grid.appendChild).toMatchSnapshot();
|
|
71
|
+
});
|
|
72
|
+
});
|
|
73
|
+
|
|
74
|
+
describe("getClassName", () => {
|
|
75
|
+
it("works", () => {
|
|
76
|
+
expect(comp.getClassName()).toBe("Viewer");
|
|
77
|
+
});
|
|
78
|
+
});
|
|
79
|
+
|
|
80
|
+
describe("getSubComponentsNames", () => {
|
|
81
|
+
it("works", () => {
|
|
82
|
+
expect(comp.getSubComponentsNames()).toEqual(["loader", "api", "psv", "grid", "popup", "urlHandler", "mini", "map"]);
|
|
83
|
+
});
|
|
84
|
+
});
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
|
2
|
+
|
|
3
|
+
exports[`_initWidgets should handle widgets if width is not small 1`] = `
|
|
4
|
+
[MockFunction] {
|
|
5
|
+
"calls": Array [
|
|
6
|
+
Array [
|
|
7
|
+
<pnx-widget-player
|
|
8
|
+
class="pnx-only-psv pnx-print-hidden"
|
|
9
|
+
size="xl"
|
|
10
|
+
slot="top"
|
|
11
|
+
/>,
|
|
12
|
+
],
|
|
13
|
+
Array [
|
|
14
|
+
<pnx-widget-zoom
|
|
15
|
+
class="pnx-print-hidden"
|
|
16
|
+
slot="bottom-right"
|
|
17
|
+
/>,
|
|
18
|
+
],
|
|
19
|
+
Array [
|
|
20
|
+
<pnx-widget-legend
|
|
21
|
+
focus="pic"
|
|
22
|
+
picture="somePicture"
|
|
23
|
+
slot="top-left"
|
|
24
|
+
/>,
|
|
25
|
+
],
|
|
26
|
+
],
|
|
27
|
+
"results": Array [
|
|
28
|
+
Object {
|
|
29
|
+
"type": "return",
|
|
30
|
+
"value": undefined,
|
|
31
|
+
},
|
|
32
|
+
Object {
|
|
33
|
+
"type": "return",
|
|
34
|
+
"value": undefined,
|
|
35
|
+
},
|
|
36
|
+
Object {
|
|
37
|
+
"type": "return",
|
|
38
|
+
"value": undefined,
|
|
39
|
+
},
|
|
40
|
+
],
|
|
41
|
+
}
|
|
42
|
+
`;
|
|
43
|
+
|
|
44
|
+
exports[`_initWidgets should handle widgets if width is small 1`] = `
|
|
45
|
+
[MockFunction] {
|
|
46
|
+
"calls": Array [
|
|
47
|
+
Array [
|
|
48
|
+
<pnx-widget-player
|
|
49
|
+
class="pnx-only-psv pnx-print-hidden"
|
|
50
|
+
size="xl"
|
|
51
|
+
slot="top"
|
|
52
|
+
/>,
|
|
53
|
+
],
|
|
54
|
+
Array [
|
|
55
|
+
<pnx-bottom-drawer
|
|
56
|
+
slot="bottom"
|
|
57
|
+
>
|
|
58
|
+
<pnx-picture-legend />
|
|
59
|
+
</pnx-bottom-drawer>,
|
|
60
|
+
],
|
|
61
|
+
],
|
|
62
|
+
"results": Array [
|
|
63
|
+
Object {
|
|
64
|
+
"type": "return",
|
|
65
|
+
"value": undefined,
|
|
66
|
+
},
|
|
67
|
+
Object {
|
|
68
|
+
"type": "return",
|
|
69
|
+
"value": undefined,
|
|
70
|
+
},
|
|
71
|
+
],
|
|
72
|
+
}
|
|
73
|
+
`;
|
|
@@ -0,0 +1,145 @@
|
|
|
1
|
+
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
|
2
|
+
|
|
3
|
+
exports[`_initWidgets should handle widgets if width is not small 1`] = `
|
|
4
|
+
[MockFunction] {
|
|
5
|
+
"calls": Array [
|
|
6
|
+
Array [
|
|
7
|
+
<pnx-widget-zoom
|
|
8
|
+
class="pnx-print-hidden"
|
|
9
|
+
slot="bottom-right"
|
|
10
|
+
/>,
|
|
11
|
+
],
|
|
12
|
+
Array [
|
|
13
|
+
<pnx-widget-legend
|
|
14
|
+
focus="pic"
|
|
15
|
+
picture="somePicture"
|
|
16
|
+
slot="top-left"
|
|
17
|
+
/>,
|
|
18
|
+
],
|
|
19
|
+
Array [
|
|
20
|
+
<pnx-widget-player
|
|
21
|
+
class="pnx-only-psv pnx-print-hidden"
|
|
22
|
+
size="xl"
|
|
23
|
+
slot="top"
|
|
24
|
+
/>,
|
|
25
|
+
],
|
|
26
|
+
Array [
|
|
27
|
+
<pnx-widget-geosearch
|
|
28
|
+
class="pnx-only-map pnx-print-hidden"
|
|
29
|
+
slot="top-left"
|
|
30
|
+
/>,
|
|
31
|
+
],
|
|
32
|
+
Array [
|
|
33
|
+
<pnx-widget-mapfilters
|
|
34
|
+
class="pnx-only-map pnx-print-hidden"
|
|
35
|
+
slot="top-left"
|
|
36
|
+
user-search="true"
|
|
37
|
+
/>,
|
|
38
|
+
],
|
|
39
|
+
Array [
|
|
40
|
+
<pnx-widget-maplayers
|
|
41
|
+
class="pnx-only-map pnx-print-hidden"
|
|
42
|
+
slot="top-right"
|
|
43
|
+
/>,
|
|
44
|
+
],
|
|
45
|
+
],
|
|
46
|
+
"results": Array [
|
|
47
|
+
Object {
|
|
48
|
+
"type": "return",
|
|
49
|
+
"value": undefined,
|
|
50
|
+
},
|
|
51
|
+
Object {
|
|
52
|
+
"type": "return",
|
|
53
|
+
"value": undefined,
|
|
54
|
+
},
|
|
55
|
+
Object {
|
|
56
|
+
"type": "return",
|
|
57
|
+
"value": undefined,
|
|
58
|
+
},
|
|
59
|
+
Object {
|
|
60
|
+
"type": "return",
|
|
61
|
+
"value": undefined,
|
|
62
|
+
},
|
|
63
|
+
Object {
|
|
64
|
+
"type": "return",
|
|
65
|
+
"value": undefined,
|
|
66
|
+
},
|
|
67
|
+
Object {
|
|
68
|
+
"type": "return",
|
|
69
|
+
"value": undefined,
|
|
70
|
+
},
|
|
71
|
+
],
|
|
72
|
+
}
|
|
73
|
+
`;
|
|
74
|
+
|
|
75
|
+
exports[`_initWidgets should handle widgets if width is small 1`] = `
|
|
76
|
+
[MockFunction] {
|
|
77
|
+
"calls": Array [
|
|
78
|
+
Array [
|
|
79
|
+
<pnx-widget-zoom
|
|
80
|
+
class="pnx-only-map pnx-print-hidden"
|
|
81
|
+
slot="top-left"
|
|
82
|
+
/>,
|
|
83
|
+
],
|
|
84
|
+
Array [
|
|
85
|
+
<pnx-bottom-drawer
|
|
86
|
+
slot="bottom"
|
|
87
|
+
>
|
|
88
|
+
<pnx-picture-legend />
|
|
89
|
+
</pnx-bottom-drawer>,
|
|
90
|
+
],
|
|
91
|
+
Array [
|
|
92
|
+
<pnx-widget-player
|
|
93
|
+
class="pnx-only-psv pnx-print-hidden"
|
|
94
|
+
size="xl"
|
|
95
|
+
slot="top"
|
|
96
|
+
/>,
|
|
97
|
+
],
|
|
98
|
+
Array [
|
|
99
|
+
<pnx-widget-geosearch
|
|
100
|
+
class="pnx-only-map pnx-print-hidden"
|
|
101
|
+
slot="top-right"
|
|
102
|
+
/>,
|
|
103
|
+
],
|
|
104
|
+
Array [
|
|
105
|
+
<pnx-widget-mapfilters
|
|
106
|
+
class="pnx-only-map pnx-print-hidden"
|
|
107
|
+
slot="top-right"
|
|
108
|
+
user-search="true"
|
|
109
|
+
/>,
|
|
110
|
+
],
|
|
111
|
+
Array [
|
|
112
|
+
<pnx-widget-maplayers
|
|
113
|
+
class="pnx-only-map pnx-print-hidden"
|
|
114
|
+
slot="top-right"
|
|
115
|
+
/>,
|
|
116
|
+
],
|
|
117
|
+
],
|
|
118
|
+
"results": Array [
|
|
119
|
+
Object {
|
|
120
|
+
"type": "return",
|
|
121
|
+
"value": undefined,
|
|
122
|
+
},
|
|
123
|
+
Object {
|
|
124
|
+
"type": "return",
|
|
125
|
+
"value": undefined,
|
|
126
|
+
},
|
|
127
|
+
Object {
|
|
128
|
+
"type": "return",
|
|
129
|
+
"value": undefined,
|
|
130
|
+
},
|
|
131
|
+
Object {
|
|
132
|
+
"type": "return",
|
|
133
|
+
"value": undefined,
|
|
134
|
+
},
|
|
135
|
+
Object {
|
|
136
|
+
"type": "return",
|
|
137
|
+
"value": undefined,
|
|
138
|
+
},
|
|
139
|
+
Object {
|
|
140
|
+
"type": "return",
|
|
141
|
+
"value": undefined,
|
|
142
|
+
},
|
|
143
|
+
],
|
|
144
|
+
}
|
|
145
|
+
`;
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import CopyButton from "../../../src/components/ui/CopyButton";
|
|
2
|
+
|
|
3
|
+
window.navigator.clipboard = { writeText: jest.fn() };
|
|
4
|
+
|
|
5
|
+
describe("constructor", () => {
|
|
6
|
+
it("listens to click", () => {
|
|
7
|
+
const cb = new CopyButton();
|
|
8
|
+
expect(cb._handlers).toMatchSnapshot();
|
|
9
|
+
});
|
|
10
|
+
});
|
|
11
|
+
|
|
12
|
+
describe("_onClick", () => {
|
|
13
|
+
it("works with text", () => {
|
|
14
|
+
const cb = new CopyButton();
|
|
15
|
+
cb.text = "I am a copy text";
|
|
16
|
+
cb._onClick();
|
|
17
|
+
expect(cb._active).toBe(true);
|
|
18
|
+
expect(global.navigator.clipboard.writeText.mock.calls).toMatchSnapshot();
|
|
19
|
+
return new Promise(resolve => setTimeout(() => {
|
|
20
|
+
expect(cb._active).toBe(false);
|
|
21
|
+
resolve();
|
|
22
|
+
}, 2000));
|
|
23
|
+
});
|
|
24
|
+
|
|
25
|
+
it("works with input", () => {
|
|
26
|
+
const i = document.createElement("input");
|
|
27
|
+
i.value = "copy me from input";
|
|
28
|
+
i.id = "input-to-copy";
|
|
29
|
+
document.body.appendChild(i);
|
|
30
|
+
|
|
31
|
+
const cb = new CopyButton();
|
|
32
|
+
cb.input = "input-to-copy";
|
|
33
|
+
cb._onClick();
|
|
34
|
+
|
|
35
|
+
expect(cb._active).toBe(true);
|
|
36
|
+
expect(global.navigator.clipboard.writeText.mock.calls).toMatchSnapshot();
|
|
37
|
+
});
|
|
38
|
+
|
|
39
|
+
it("works with textarea", () => {
|
|
40
|
+
const i = document.createElement("textarea");
|
|
41
|
+
i.appendChild(document.createTextNode("copy me from textarea"));
|
|
42
|
+
i.id = "textarea-to-copy";
|
|
43
|
+
document.body.appendChild(i);
|
|
44
|
+
|
|
45
|
+
const cb = new CopyButton();
|
|
46
|
+
cb.input = "textarea-to-copy";
|
|
47
|
+
cb._onClick();
|
|
48
|
+
|
|
49
|
+
expect(cb._active).toBe(true);
|
|
50
|
+
expect(global.navigator.clipboard.writeText.mock.calls).toMatchSnapshot();
|
|
51
|
+
});
|
|
52
|
+
});
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import Loader from "../../../src/components/ui/Loader";
|
|
2
|
+
|
|
3
|
+
describe("constructor", () => {
|
|
4
|
+
it("works", () => {
|
|
5
|
+
const l = new Loader();
|
|
6
|
+
expect(l.isVisible()).toBe(true);
|
|
7
|
+
});
|
|
8
|
+
});
|
|
9
|
+
|
|
10
|
+
describe("dismiss", () => {
|
|
11
|
+
it("works on success", () => {
|
|
12
|
+
const p = { dispatchEvent: jest.fn() };
|
|
13
|
+
const l = new Loader();
|
|
14
|
+
l._parent = p;
|
|
15
|
+
l.dismiss();
|
|
16
|
+
|
|
17
|
+
expect(l.isVisible()).toBe(false);
|
|
18
|
+
expect(p.dispatchEvent.mock.calls).toMatchSnapshot();
|
|
19
|
+
});
|
|
20
|
+
|
|
21
|
+
it("works on success + next fct", () => {
|
|
22
|
+
const p = { dispatchEvent: jest.fn() };
|
|
23
|
+
const n = jest.fn();
|
|
24
|
+
const l = new Loader();
|
|
25
|
+
l._parent = p;
|
|
26
|
+
l.dismiss(null, null, n);
|
|
27
|
+
|
|
28
|
+
expect(l.isVisible()).toBe(false);
|
|
29
|
+
expect(p.dispatchEvent.mock.calls).toMatchSnapshot();
|
|
30
|
+
expect(n.mock.calls).toMatchSnapshot();
|
|
31
|
+
});
|
|
32
|
+
|
|
33
|
+
it("works with error", () => {
|
|
34
|
+
const p = { dispatchEvent: jest.fn(), _t: { pnx: {} } };
|
|
35
|
+
const l = new Loader();
|
|
36
|
+
l._parent = p;
|
|
37
|
+
expect(() => l.dismiss(true, "an error")).toThrow(new Error("an error"))
|
|
38
|
+
|
|
39
|
+
expect(l.isVisible()).toBe(true);
|
|
40
|
+
expect(p.dispatchEvent.mock.calls).toMatchSnapshot();
|
|
41
|
+
});
|
|
42
|
+
|
|
43
|
+
it("works with error + next fct", () => {
|
|
44
|
+
const p = { dispatchEvent: jest.fn(), _t: { pnx: {} } };
|
|
45
|
+
const n = jest.fn();
|
|
46
|
+
const l = new Loader();
|
|
47
|
+
l.addEventListener = jest.fn();
|
|
48
|
+
l._parent = p;
|
|
49
|
+
expect(() => l.dismiss(true, "an error", n)).toThrow(new Error("an error"))
|
|
50
|
+
|
|
51
|
+
expect(l.isVisible()).toBe(true);
|
|
52
|
+
expect(p.dispatchEvent.mock.calls).toMatchSnapshot();
|
|
53
|
+
expect(l.addEventListener.mock.calls).toMatchSnapshot();
|
|
54
|
+
});
|
|
55
|
+
});
|
|
@@ -1,54 +1,13 @@
|
|
|
1
|
-
import Map from "
|
|
2
|
-
|
|
3
|
-
jest.mock("maplibre-gl", () => ({
|
|
4
|
-
addProtocol: jest.fn(),
|
|
5
|
-
AttributionControl: jest.fn(),
|
|
6
|
-
GeolocateControl: class {
|
|
7
|
-
onAdd() {;}
|
|
8
|
-
},
|
|
9
|
-
Marker: jest.fn(),
|
|
10
|
-
Popup: class {
|
|
11
|
-
on() {;}
|
|
12
|
-
},
|
|
13
|
-
Map: class {
|
|
14
|
-
constructor(opts) {
|
|
15
|
-
this._mapOpts = opts;
|
|
16
|
-
}
|
|
17
|
-
getContainer() {
|
|
18
|
-
return this._mapOpts.container;
|
|
19
|
-
}
|
|
20
|
-
addControl() {;}
|
|
21
|
-
addSource() {;}
|
|
22
|
-
addLayer() {;}
|
|
23
|
-
getLayer() {;}
|
|
24
|
-
setLayoutProperty() {;}
|
|
25
|
-
getStyle() {
|
|
26
|
-
return {
|
|
27
|
-
layers: [],
|
|
28
|
-
sources: {},
|
|
29
|
-
metadata: {},
|
|
30
|
-
};
|
|
31
|
-
}
|
|
32
|
-
resize() {;}
|
|
33
|
-
on(type, handler) {
|
|
34
|
-
if(!this._handlers) { this._handlers = {}; }
|
|
35
|
-
if(!this._handlers[type]) { this._handlers[type] = []; }
|
|
36
|
-
this._handlers[type].push(handler);
|
|
37
|
-
}
|
|
38
|
-
_fire(type) {
|
|
39
|
-
this._handlers[type].forEach(f => f());
|
|
40
|
-
}
|
|
41
|
-
},
|
|
42
|
-
}));
|
|
1
|
+
import Map from "../../../src/components/ui/Map";
|
|
43
2
|
|
|
44
3
|
const createParent = () => ({
|
|
45
4
|
addEventListener: jest.fn(),
|
|
46
5
|
dispatchEvent: jest.fn(),
|
|
47
6
|
isWidthSmall: jest.fn(),
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
7
|
+
onceReady: () => Promise.resolve(),
|
|
8
|
+
onceAPIReady: () => Promise.resolve(),
|
|
9
|
+
users: ["geovisio"],
|
|
10
|
+
api: {
|
|
52
11
|
onceReady: () => Promise.resolve(),
|
|
53
12
|
getDataBbox: jest.fn(),
|
|
54
13
|
getPicturesTilesUrl: jest.fn(),
|
|
@@ -61,6 +20,20 @@ const createParent = () => ({
|
|
|
61
20
|
});
|
|
62
21
|
|
|
63
22
|
|
|
23
|
+
describe("_postLoad", () => {
|
|
24
|
+
it("send ready event", async () => {
|
|
25
|
+
const p = createParent();
|
|
26
|
+
const c = document.createElement("div");
|
|
27
|
+
const m = new Map(p, c);
|
|
28
|
+
const listener = jest.fn();
|
|
29
|
+
m.addEventListener("ready", listener, { once: true });
|
|
30
|
+
|
|
31
|
+
await m._postLoad();
|
|
32
|
+
|
|
33
|
+
expect(listener).toHaveBeenCalledTimes(1);
|
|
34
|
+
});
|
|
35
|
+
});
|
|
36
|
+
|
|
64
37
|
describe("reloadVectorTiles", () => {
|
|
65
38
|
it("works", () => {
|
|
66
39
|
const p = createParent();
|
|
@@ -79,7 +52,7 @@ describe("hasTwoBackgrounds", () => {
|
|
|
79
52
|
const p = createParent();
|
|
80
53
|
const c = document.createElement("div");
|
|
81
54
|
const m = new Map(p, c);
|
|
82
|
-
m.getLayer = (id) => id == "
|
|
55
|
+
m.getLayer = (id) => id == "pnx-aerial";
|
|
83
56
|
expect(m.hasTwoBackgrounds()).toBeTruthy();
|
|
84
57
|
});
|
|
85
58
|
|
|
@@ -87,7 +60,7 @@ describe("hasTwoBackgrounds", () => {
|
|
|
87
60
|
const p = createParent();
|
|
88
61
|
const c = document.createElement("div");
|
|
89
62
|
const m = new Map(p, c);
|
|
90
|
-
m.getLayer = (id) => id == "
|
|
63
|
+
m.getLayer = (id) => id == "pnx-aerial" ? undefined : {};
|
|
91
64
|
expect(m.hasTwoBackgrounds()).toBeFalsy();
|
|
92
65
|
});
|
|
93
66
|
});
|
|
@@ -115,14 +88,18 @@ describe("getBackground", () => {
|
|
|
115
88
|
describe("setBackground", () => {
|
|
116
89
|
it("works if raster is enabled", () => {
|
|
117
90
|
const p = createParent();
|
|
118
|
-
p.dispatchEvent = jest.fn();
|
|
119
91
|
const c = document.createElement("div");
|
|
120
92
|
const m = new Map(p, c, { raster: { type: "raster" } });
|
|
121
93
|
m.setLayoutProperty = jest.fn();
|
|
122
94
|
m.getLayer = () => true;
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
95
|
+
return new Promise(resolve => {
|
|
96
|
+
m.on("background-changed", e => {
|
|
97
|
+
expect(m.setLayoutProperty.mock.calls).toMatchSnapshot();
|
|
98
|
+
expect(e.background).toEqual("aerial");
|
|
99
|
+
resolve();
|
|
100
|
+
});
|
|
101
|
+
m.setBackground("aerial");
|
|
102
|
+
})
|
|
126
103
|
});
|
|
127
104
|
|
|
128
105
|
it("skips if setting streets and no raster available", () => {
|
|
@@ -169,7 +146,7 @@ describe("setVisibleUsers", () => {
|
|
|
169
146
|
|
|
170
147
|
it("works when user already exist but is hidden", async () => {
|
|
171
148
|
const p = createParent();
|
|
172
|
-
p.
|
|
149
|
+
p.users = ["blabla", "geovisio"];
|
|
173
150
|
const c = document.createElement("div");
|
|
174
151
|
const m = new Map(p, c);
|
|
175
152
|
m.setPaintProperty = jest.fn();
|
|
@@ -178,12 +155,7 @@ describe("setVisibleUsers", () => {
|
|
|
178
155
|
let cptlCount = 0;
|
|
179
156
|
let deCalls = [];
|
|
180
157
|
return new Promise(async (resolve) => {
|
|
181
|
-
|
|
182
|
-
deCalls.push(e);
|
|
183
|
-
if(e.type == "map:users-changed") {
|
|
184
|
-
resolve();
|
|
185
|
-
}
|
|
186
|
-
};
|
|
158
|
+
m.on("users-changed", resolve);
|
|
187
159
|
await m._postLoad();
|
|
188
160
|
}).then(() => {
|
|
189
161
|
m.setLayoutProperty = jest.fn();
|
|
@@ -201,7 +173,7 @@ describe("setVisibleUsers", () => {
|
|
|
201
173
|
describe("filterUserLayersContent", () => {
|
|
202
174
|
it("works", async () => {
|
|
203
175
|
const p = createParent();
|
|
204
|
-
p.
|
|
176
|
+
p.users = ["blabla", "geovisio"];
|
|
205
177
|
const c = document.createElement("div");
|
|
206
178
|
const m = new Map(p, c);
|
|
207
179
|
m.getSource = () => true;
|
|
@@ -217,7 +189,7 @@ describe("filterUserLayersContent", () => {
|
|
|
217
189
|
describe("reloadLayersStyles", () => {
|
|
218
190
|
it("works", async () => {
|
|
219
191
|
const p = createParent();
|
|
220
|
-
p.
|
|
192
|
+
p.users = ["blabla", "geovisio"];
|
|
221
193
|
const c = document.createElement("div");
|
|
222
194
|
const m = new Map(p, c);
|
|
223
195
|
m.getSource = () => true;
|
|
@@ -230,3 +202,43 @@ describe("reloadLayersStyles", () => {
|
|
|
230
202
|
expect(m.setPaintProperty.mock.calls).toMatchSnapshot();
|
|
231
203
|
});
|
|
232
204
|
});
|
|
205
|
+
|
|
206
|
+
describe("addEventListener", () => {
|
|
207
|
+
let map;
|
|
208
|
+
beforeEach(() => {
|
|
209
|
+
const p = createParent();
|
|
210
|
+
const c = document.createElement("div");
|
|
211
|
+
map = new Map(p, c);
|
|
212
|
+
});
|
|
213
|
+
|
|
214
|
+
it("should add an event listener", () => {
|
|
215
|
+
const listener = jest.fn();
|
|
216
|
+
map.addEventListener("ready", listener);
|
|
217
|
+
map.fire("ready");
|
|
218
|
+
expect(listener).toHaveBeenCalled();
|
|
219
|
+
});
|
|
220
|
+
|
|
221
|
+
it("should add an event listener that only fires once", () => {
|
|
222
|
+
const listener = jest.fn();
|
|
223
|
+
map.addEventListener("ready", listener, { once: true });
|
|
224
|
+
map.fire("ready");
|
|
225
|
+
map.fire("ready");
|
|
226
|
+
expect(listener).toHaveBeenCalledTimes(1);
|
|
227
|
+
});
|
|
228
|
+
|
|
229
|
+
it("should not add an event listener if options.once is false", () => {
|
|
230
|
+
const listener = jest.fn();
|
|
231
|
+
map.addEventListener("ready", listener, { once: false });
|
|
232
|
+
map.fire("ready");
|
|
233
|
+
map.fire("ready");
|
|
234
|
+
expect(listener).toHaveBeenCalledTimes(2);
|
|
235
|
+
});
|
|
236
|
+
|
|
237
|
+
it("should default options.once to false if not provided", () => {
|
|
238
|
+
const listener = jest.fn();
|
|
239
|
+
map.addEventListener("ready", listener);
|
|
240
|
+
map.fire("ready");
|
|
241
|
+
map.fire("ready");
|
|
242
|
+
expect(listener).toHaveBeenCalledTimes(2);
|
|
243
|
+
});
|
|
244
|
+
});
|