Skip to content

Commit

Permalink
Visibility limits - The resolution option is not retained as Limits t…
Browse files Browse the repository at this point in the history
…ype #10391 (#10598)
  • Loading branch information
rowheat02 authored Oct 11, 2024
1 parent fece9df commit 1e3365b
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 1 deletion.
1 change: 1 addition & 0 deletions web/client/components/TOC/fragments/settings/Display.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -210,6 +210,7 @@ export default class extends React.Component {
projection={this.props.projection}
resolutions={this.props.resolutions}
zoom={this.props.zoom}
defaultLimitsType={this.props.element.visibilityLimitType}
/>
</FormGroup>
</Col>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -392,6 +392,9 @@ function VisibilityLimitsForm({
disabled={disableResolutionLimits || loading}
onChange={({ value }) => {
setLimitsType(value);
onChange({
visibilityLimitType: value
});
clearMessages();
}}
/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
import expect from 'expect';
import React from 'react';
import ReactDOM from 'react-dom';
import { act } from 'react-dom/test-utils';
import ReactTestUtils, { act } from 'react-dom/test-utils';
import VisibilityLimitsForm from '../VisibilityLimitsForm';

describe('VisibilityLimitsForm', () => {
Expand Down Expand Up @@ -96,4 +96,32 @@ describe('VisibilityLimitsForm', () => {
const buttons = document.querySelectorAll('.square-button-md');
expect(buttons.length).toBe(1);
});

it("Should call onChange after visibilityLimitType change ", () => {
const layer = {
type: 'wms'
};
const handlers = {
onChange: () => {}
};
let spyUpdate = expect.spyOn(handlers, "onChange");

act(()=>ReactDOM.render(<VisibilityLimitsForm
layer={layer}
onChange={handlers.onChange}
/>, document.getElementById('container')));

// Simpulate selection
const selectArrow = document.getElementById("container").querySelectorAll('.Select-arrow');
const selectControl = document.getElementById("container").querySelectorAll('.Select-control');
const inputs = document.getElementsByTagName("input");
ReactTestUtils.Simulate.mouseDown(selectArrow[2], { button: 0 });
ReactTestUtils.Simulate.keyDown(selectControl[2], { keyCode: 40, key: 'ArrowDown' });
ReactTestUtils.Simulate.keyDown(inputs[3], { keyCode: 13, key: 'Enter' });
expect(spyUpdate.calls.length).toBe(1);
expect(Object.keys(spyUpdate.calls[0].arguments[0])).toEqual(['visibilityLimitType']);

});


});

0 comments on commit 1e3365b

Please sign in to comment.