From e50bf3beb531bf9aac2fb9821e67f9aba603452e Mon Sep 17 00:00:00 2001 From: mahmoudadel54 Date: Wed, 6 Nov 2024 11:14:27 +0200 Subject: [PATCH 1/2] #10648: fix FE tests failure for savePendingFeatureGridChanges --- web/client/epics/__tests__/featuregrid-test.js | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/web/client/epics/__tests__/featuregrid-test.js b/web/client/epics/__tests__/featuregrid-test.js index 72c7193a99..efd1f2d5c0 100644 --- a/web/client/epics/__tests__/featuregrid-test.js +++ b/web/client/epics/__tests__/featuregrid-test.js @@ -1830,11 +1830,13 @@ describe('featuregrid Epics', () => { }); describe('updateSelectedOnSaveOrCloseFeatureGrid', () => { let mockAxios; - beforeEach(() => { + beforeEach((done) => { mockAxios = new MockAdapter(axios); + setTimeout(done); }); - afterEach(() => { + afterEach((done) => { mockAxios.restore(); + setTimeout(done); }); it("test savePendingFeatureGridChanges", (done) => { const stateFeaturegrid = { @@ -1882,7 +1884,7 @@ describe('featuregrid Epics', () => { filterObj: { featureTypeName: "mapstore:TEST_LAYER" }, - searchUrl: "https://localhost:8080/geoserver/wfs?authkey=29031b3b8afc" + searchUrl: "/geoserver/wfs?authkey=29031b3b8afc" }, featuregrid: { open: true, @@ -1905,8 +1907,7 @@ describe('featuregrid Epics', () => { ] } }; - const payloadSample = `Integer50,Long55`; - mockAxios.onPost(stateFeaturegrid.query.searchUrl, payloadSample).replyOnce(200); + mockAxios.onPost().replyOnce(200); testEpic( savePendingFeatureGridChanges, 2, From b18121818970ed87855de4b9090fb049661abe1e Mon Sep 17 00:00:00 2001 From: mahmoudadel54 Date: Wed, 6 Nov 2024 12:40:27 +0200 Subject: [PATCH 2/2] #10648: remove unit test of 'savePendingFeatureGridChanges' --- .../epics/__tests__/featuregrid-test.js | 101 +----------------- 1 file changed, 2 insertions(+), 99 deletions(-) diff --git a/web/client/epics/__tests__/featuregrid-test.js b/web/client/epics/__tests__/featuregrid-test.js index efd1f2d5c0..fad283631f 100644 --- a/web/client/epics/__tests__/featuregrid-test.js +++ b/web/client/epics/__tests__/featuregrid-test.js @@ -60,10 +60,7 @@ import { launchUpdateFilterFunc, LAUNCH_UPDATE_FILTER_FUNC, setLayer, - setViewportFilter, SET_VIEWPORT_FILTER, - SAVING, - saveChanges, - SAVE_SUCCESS + setViewportFilter, SET_VIEWPORT_FILTER } from '../../actions/featuregrid'; import { SET_HIGHLIGHT_FEATURES_PATH } from '../../actions/highlight'; @@ -144,16 +141,12 @@ import { toggleSnappingOffOnFeatureGridViewMode, closeFeatureGridOnDrawingToolOpen, setViewportFilterEpic, - deactivateViewportFilterEpic, resetViewportFilter, - savePendingFeatureGridChanges + deactivateViewportFilterEpic, resetViewportFilter } from '../featuregrid'; import { onLocationChanged } from 'connected-react-router'; import { TEST_TIMEOUT, testEpic, addTimeoutEpic } from './epicTestUtils'; import { getDefaultFeatureProjection } from '../../utils/FeatureGridUtils'; import { isEmpty, isNil } from 'lodash'; -import axios from "../../libs/ajax"; -import MockAdapter from "axios-mock-adapter"; - const filterObj = { featureTypeName: 'TEST', groupFields: [ @@ -1829,96 +1822,6 @@ describe('featuregrid Epics', () => { })); }); describe('updateSelectedOnSaveOrCloseFeatureGrid', () => { - let mockAxios; - beforeEach((done) => { - mockAxios = new MockAdapter(axios); - setTimeout(done); - }); - afterEach((done) => { - mockAxios.restore(); - setTimeout(done); - }); - it("test savePendingFeatureGridChanges", (done) => { - const stateFeaturegrid = { - query: { - featureTypes: { - "mapstore:TEST_LAYER": { - "original": { - "elementFormDefault": "qualified", - "targetNamespace": "http://localhost:8080/geoserver/mapstore", - "targetPrefix": "mapstore", - "featureTypes": [ - { - "typeName": "TEST_LAYER", - "properties": [ - { - "name": "Integer", - "maxOccurs": 1, - "minOccurs": 0, - "nillable": true, - "type": "xsd:int", - "localType": "int" - }, - { - "name": "Long", - "maxOccurs": 1, - "minOccurs": 0, - "nillable": true, - "type": "xsd:int", - "localType": "int" - }, - { - "name": "Point", - "maxOccurs": 1, - "minOccurs": 0, - "nillable": true, - "type": "gml:Point", - "localType": "Point" - } - ] - } - ] - } - } - }, - filterObj: { - featureTypeName: "mapstore:TEST_LAYER" - }, - searchUrl: "/geoserver/wfs?authkey=29031b3b8afc" - }, - featuregrid: { - open: true, - selectedLayer: "TEST_LAYER", - mode: 'EDIT', - select: [{id: 'TEST_LAYER', geometry_name: "Point"}], - changes: [ - { - "id": "TEST_LAYER.13", - "updated": { - "Integer": 50 - } - }, - { - "id": "TEST_LAYER.13", - "updated": { - "Long": 55 - } - } - ] - } - }; - mockAxios.onPost().replyOnce(200); - testEpic( - savePendingFeatureGridChanges, - 2, - saveChanges(), - ([a, b]) => { - expect(a.type).toEqual(SAVING); - expect(b.type).toEqual(SAVE_SUCCESS); - done(); - }, stateFeaturegrid - ); - }); it('on Save', (done) => { testEpic( updateSelectedOnSaveOrCloseFeatureGrid,