Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 27 additions & 0 deletions web/client/epics/__tests__/playback-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -349,6 +349,33 @@ describe('playback Epics', () => {
}
}, ANIMATION_MOCK_STATE);
});
it('setIsIntervalData when one of the nearest values is not available', done => {
mock.onGet('MOCK_DOMAIN_VALUES').replyOnce(500);
mock.onGet('MOCK_DOMAIN_VALUES').reply(200, DOMAIN_INTERVAL_VALUES_RESPONSE);
testEpic(setIsIntervalData, 1, setCurrentTime("2016-09-04T00:00:00.000Z"), ([action]) => {
try {
const { type, timeIntervalData } = action;
expect(type).toBe(SET_INTERVAL_DATA);
expect(timeIntervalData).toBe(true);
done();
} catch (e) {
done(e);
}
}, ANIMATION_MOCK_STATE);
});
it('setIsIntervalData when no nearest value is available', done => {
mock.onGet('MOCK_DOMAIN_VALUES').reply(500);
testEpic(setIsIntervalData, 1, setCurrentTime("2016-09-04T00:00:00.000Z"), ([action]) => {
try {
const { type, timeIntervalData } = action;
expect(type).toBe(SET_INTERVAL_DATA);
expect(timeIntervalData).toBe(false);
done();
} catch (e) {
done(e);
}
}, ANIMATION_MOCK_STATE);
});
it('setIsIntervalData when no time layer selected', done => {
testEpic(addTimeoutEpic(setIsIntervalData, 100), 1, setCurrentTime("2016-09-04T00:00:00.000Z"), ([action]) => {
try {
Expand Down
58 changes: 58 additions & 0 deletions web/client/epics/__tests__/timeline-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -478,6 +478,11 @@ describe('timeline Epics', () => {
});
});
describe("setRangeOnInit", () => {
let mockAxios;
afterEach(() => {
mockAxios?.restore();
mockAxios = null;
});
it("setRangeOnInit on domain and current time", (done) => {
testEpic(setRangeOnInit, 3, initializeRange(), ([action1, action2, action3]) => {
const { time, type } = action1;
Expand Down Expand Up @@ -578,6 +583,59 @@ describe('timeline Epics', () => {
}
});
});
it("setRangeOnInit when one end of the domain is not available", (done) => {
const DOMAIN_START = "2016-09-01T00:00:00.000Z";
mockAxios = new MockAdapter(axios);
// the request for the last value of the domain fails
mockAxios.onGet().reply(({ params }) => params.sort === "asc"
? [200, `<?xml version="1.0" encoding="UTF-8"?><DomainValues xmlns="http://demo.geo-solutions.it/share/wmts-multidim/wmts_multi_dimensional.xsd" xmlns:ows="http://www.opengis.net/ows/1.1"><ows:Identifier>time</ows:Identifier><Limit>1</Limit><Sort>asc</Sort><Domain>${DOMAIN_START}</Domain><Size>1</Size></DomainValues>`]
: [500]);
testEpic(setRangeOnInit, 3, initializeRange(), ([action1, action2, action3]) => {
try {
expect(action1.type).toBe(SET_CURRENT_TIME);
expect(action1.time).toBe(DOMAIN_START);
expect(action2.type).toBe(SET_OFFSET_TIME);
expect(moment(action2.offsetTime).isValid()).toBe(true);
expect(action3.type).toBe(RANGE_CHANGED);
expect(action3.start).toBe(DOMAIN_START);
done();
} catch (e) {
done(e);
}
}, {
timeline: {
selectedLayer: "TEST_LAYER",
settings: {
initialMode: 'range',
initialSnap: 'fullRange'
}
},
dimension: {
currentTime: "2000-01-01T00:00:00.000Z"
},
layers: {
flat: [{
id: 'TEST_LAYER',
name: 'TEST_LAYER',
type: 'wms',
visibility: true,
url: '/geoserver/wms',
dimensions: [
{
source: {
type: 'multidim-extension',
url: '/geoserver/gwc/service/wmts'
},
name: 'time'
}
],
params: {
time: '2000-06-08T00:00:00.000Z'
}
}]
}
});
});
it("setRangeOnInit on empty domain and empty current time", (done) => {
testEpic(setRangeOnInit, 3, initializeRange(), ([action1, action2, action3]) => {
const { time, type } = action1;
Expand Down
5 changes: 3 additions & 2 deletions web/client/epics/playback.js
Original file line number Diff line number Diff line change
Expand Up @@ -381,8 +381,9 @@ export const setIsIntervalData = (action$, { getState = () => { } } = {}) =>
const time = actionTime || currentTimeSelector(getState());
const snapType = snapTypeSelector(getState());
return getNearestTimesObservable(domainArgs, true, getState, snapType, time)
.map(([next, previous]) => {
const isTimeIntervalData = next.indexOf('/') !== -1 || previous.indexOf('/') !== -1;
.map((values) => {
// a value is empty when its request fails or returns no value
const isTimeIntervalData = values.some(value => !!value && value.indexOf('/') !== -1);
return setIntervalData(isTimeIntervalData);
});
});
Expand Down
3 changes: 2 additions & 1 deletion web/client/epics/timeline.js
Original file line number Diff line number Diff line change
Expand Up @@ -225,8 +225,9 @@ const updateRangeOnInit = (state, value, currentTime) => {
} else {
values = value;
}
// an end of the domain is empty when its request fails or returns no value
// if values are intervals (separated by /) spread them in the array
values = values.reduce((acc, v) => acc.concat(v.split('/')), []);
values = values.filter(v => !!v).reduce((acc, v) => acc.concat(v.split('/')), []);
if (values.length > 2) {
values = [values[0], values[values.length - 1]]; // more than 2 values, start and end are the first and last values
}
Expand Down
Loading