Skip to content

Commit

Permalink
Fix geosolutions-it#10513 Print preview state is not aligned with TOC (
Browse files Browse the repository at this point in the history
  • Loading branch information
rowheat02 authored Aug 27, 2024
1 parent 7b1e9b4 commit 04e8784
Show file tree
Hide file tree
Showing 2 changed files with 94 additions and 5 deletions.
11 changes: 6 additions & 5 deletions web/client/plugins/Print.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,14 @@ import Dialog from '../components/misc/Dialog';
import printReducers from '../reducers/print';
import printEpics from '../epics/print';
import { printSpecificationSelector } from "../selectors/print";
import { layersSelector } from '../selectors/layers';
import { layersSelector, rawGroupsSelector } from '../selectors/layers';
import { currentLocaleSelector } from '../selectors/locale';
import { mapSelector, scalesSelector } from '../selectors/map';
import { mapTypeSelector } from '../selectors/maptype';
import { normalizeSRS, convertDegreesToRadian } from '../utils/CoordinatesUtils';
import { getMessageById } from '../utils/LocaleUtils';
import { defaultGetZoomForExtent, getResolutions, mapUpdated, dpi2dpu, DEFAULT_SCREEN_DPI, getScales, reprojectZoom } from '../utils/MapUtils';
import { isInsideResolutionsLimits } from '../utils/LayersUtils';
import { getDerivedLayersVisibility, isInsideResolutionsLimits } from '../utils/LayersUtils';
import { has, includes } from 'lodash';
import {additionalLayersSelector} from "../selectors/additionallayers";
import { MapLibraries } from '../utils/MapTypeUtils';
Expand Down Expand Up @@ -629,16 +629,17 @@ export default {
(state) => state.browser && (!state.browser.ie || state.browser.ie11),
currentLocaleSelector,
mapTypeSelector,
(state) => state.print.map
], (open, capabilities, printSpec, pdfUrl, error, map, layers, additionalLayers, scales, usePreview, currentLocale, mapType, printMap) => ({
(state) => state.print.map,
rawGroupsSelector
], (open, capabilities, printSpec, pdfUrl, error, map, layers, additionalLayers, scales, usePreview, currentLocale, mapType, printMap, groups) => ({
open,
capabilities,
printSpec,
pdfUrl,
error,
map,
layers: [
...layers.filter(filterLayer),
...getDerivedLayersVisibility(layers, groups).filter(filterLayer),
...(printSpec?.additionalLayers ? additionalLayers.map(l => l.options).filter(
l => {
const isVector = l.type === 'vector';
Expand Down
88 changes: 88 additions & 0 deletions web/client/plugins/__tests__/Print-test.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -569,4 +569,92 @@ describe('Print Plugin', () => {
}
});
});
it("test removing visible layers with invisible group", (done) => {
const actions = {
onPrint: () => {}
};
let spy = expect.spyOn(actions, "onPrint");
getPrintPlugin({
layers:
{
flat: [
{
id: 'test:Linea_costa__38262060-608e-11ef-b6d2-f1ba404475c4',
format: 'image/png',
group: 'Default.34a0a320-608e-11ef-b6d2-f1ba404475c4',
search: {
url: '/geoserver/wfs',
type: 'wfs'
},
name: 'test:Linea_costa',
description: '',
title: 'Linea_costa',
type: 'wms',
url: '/geoserver/wms',
visibility: true
},
{
type: 'wms',
format: 'image/png',
featureInfo: null,
url: '/geoserver/wms',
visibility: true,
dimensions: [],
name: 'test:areeverdiPolygon',
title: 'areeverdiPolygon',
id: 'test:areeverdiPolygon__722d7920-608e-11ef-8123-43293ce7e0e8'
}
],
groups: [
{
id: 'Default',
title: 'Default',
name: 'Default',
nodes: [
'test:areeverdiPolygon__722d7920-608e-11ef-8123-43293ce7e0e8',
{
id: 'Default.34a0a320-608e-11ef-b6d2-f1ba404475c4',
title: 'g1',
name: '34a0a320-608e-11ef-b6d2-f1ba404475c4',
nodes: [
'test:Linea_costa__38262060-608e-11ef-b6d2-f1ba404475c4'
],
visibility: false
}
],
visibility: true
}
]
},
projection: "EPSG:4326",
state: {
...initialState,
map: {
...initialState.map,
zoom: 5.1
}
}
}).then(({ Plugin }) => {
try {
ReactDOM.render(<Plugin
pluginCfg={{
onPrint: actions.onPrint
}}
defaultBackground={["osm", "empty"]}
/>, document.getElementById("container"));
const submit = document.getElementsByClassName("print-submit").item(0);
expect(submit).toExist();
ReactTestUtils.Simulate.click(submit);

setTimeout(() => {
expect(spy.calls.length).toBe(1);
expect(spy.calls[0].arguments[1].layers.length).toBe(1);
expect(spy.calls[0].arguments[1].layers[0].layers).toEqual(['test:areeverdiPolygon']);
done();
}, 0);
} catch (ex) {
done(ex);
}
});
});
});

0 comments on commit 04e8784

Please sign in to comment.