Skip to content

Commit

Permalink
Fix #9014: Crash on new context when expanding search service options (
Browse files Browse the repository at this point in the history
#9027)

* #9014: Fix - Crash on new context when expanding search service options

* Copyright updated
  • Loading branch information
dsuren1 authored Mar 16, 2023
1 parent d47abb9 commit ad7333e
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 5 deletions.
10 changes: 5 additions & 5 deletions web/client/plugins/SearchServicesConfig.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -213,12 +213,12 @@ class SearchServicesConfigPanel extends React.Component {
}

const SearchServicesPlugin = connect(({controls = {}, searchconfig = {}}) => ({
enabled: controls.searchservicesconfig && controls.searchservicesconfig.enabled || false,
enabled: get(controls, "searchservicesconfig.enabled", false),
pages: [ServiceList, WFSServiceProps, ResultsProps, WFSOptionalProps],
page: searchconfig && searchconfig.page || 0,
service: searchconfig && searchconfig.service,
initServiceValues: searchconfig && searchconfig.init_service_values,
textSearchConfig: searchconfig && searchconfig.textSearchConfig,
page: get(searchconfig, "page", 0),
service: get(searchconfig, "service", {}),
initServiceValues: get(searchconfig, "init_service_values", {}),
textSearchConfig: get(searchconfig, "textSearchConfig", {}),
editIdx: searchconfig && searchconfig.editIdx
}), {
toggleControl,
Expand Down
36 changes: 36 additions & 0 deletions web/client/plugins/__tests__/SearchServicesConfig-test.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
/*
* Copyright 2023, GeoSolutions Sas.
* All rights reserved.
*
* This source code is licensed under the BSD-style license found in the
* LICENSE file in the root directory of this source tree.
*/
import expect from 'expect';
import React from 'react';
import ReactDOM from 'react-dom';
import SearchServicesConfigPlugin from '../SearchServicesConfig';
import { getPluginForTest } from './pluginsTestUtils';

describe('SearchServicesConfig Plugin', () => {
beforeEach(() => {
document.body.innerHTML = '<div id="container"></div>';
});

afterEach(() => {
ReactDOM.unmountComponentAtNode(document.getElementById("container"));
document.body.innerHTML = '';
});

it('creates a SearchServicesConfig plugin with default configuration', () => {
const {Plugin} = getPluginForTest(SearchServicesConfigPlugin, {});
ReactDOM.render(<Plugin/>, document.getElementById("container"));
expect(document.getElementById('search-services-config-editor')).toBeFalsy();
});
it('creates a SearchServicesConfig plugin with searchconfig null', () => {
const state = {controls: {searchservicesconfig: {enabled: true}}, searchconfig: null};
const {Plugin} = getPluginForTest(SearchServicesConfigPlugin, state);
ReactDOM.render(<Plugin/>, document.getElementById("container"));
expect(document.getElementById('search-services-config-editor')).toBeTruthy();
expect(document.getElementsByClassName('services-config-editor')[0]).toBeTruthy();
});
});

0 comments on commit ad7333e

Please sign in to comment.