Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

IFC request fails due to proxy issue #10694 #10745

Merged
merged 1 commit into from
Jan 15, 2025
Merged
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
35 changes: 35 additions & 0 deletions web/client/components/map/cesium/__tests__/Layer-test.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,13 @@ import '../plugins/WFSLayer';
import '../plugins/TerrainLayer';
import '../plugins/ElevationLayer';
import '../plugins/ArcGISLayer';
import '../plugins/ModelLayer';

import {setStore} from '../../../../utils/SecurityUtils';
import ConfigUtils from '../../../../utils/ConfigUtils';
import MockAdapter from 'axios-mock-adapter';
import axios from '../../../../libs/ajax';


describe('Cesium layer', () => {
let map;
Expand Down Expand Up @@ -1741,4 +1745,35 @@ describe('Cesium layer', () => {
done();
}).catch(done);
});

it('ensure proxy usage in Model layer', (done) => {
const options = {
type: "model",
// url that fails
url: "https://test-CORS/FontaneMarosegeoreferenziato.ifc",
visibility: true,
format: 'ifc'
};

// Create a mock adapter for axios
const mockAxios = new MockAdapter(axios);

ReactDOM.render(
<CesiumLayer
type={options.type}
options={options}
map={map}
/>, document.getElementById('container'));


setTimeout(() => {
// Check if the API call was made
expect(mockAxios.history.get.length).toBe(1);
// ensure calling from proxy URL (CORS test is performed on fetch before this call)
expect(mockAxios.history.get[0].url.includes('/proxy')).toBe(true); // Check the URL
expect(mockAxios.history.get[0].url.includes('?url=https%3A%2F%2Ftest-cors%2FFontaneMarosegeoreferenziato.ifc')).toBe(true);
mockAxios.restore(); // Restore the original axios instance
done();
}, 1000);
});
});
5 changes: 4 additions & 1 deletion web/client/components/map/cesium/plugins/ModelLayer.js
Original file line number Diff line number Diff line change
Expand Up @@ -189,10 +189,13 @@ const createLayer = (options, map) => {

Layers.registerType('model', {
create: createLayer,
update: (layer, newOptions, oldOptions) => {
update: (layer, newOptions, oldOptions, map) => {
if (layer?.primitives && !isEqual(newOptions?.features?.[0], oldOptions?.features?.[0])) {
updatePrimitivesMatrix(layer?.primitives, newOptions?.features?.[0]);
}
if (newOptions?.forceProxy !== oldOptions?.forceProxy) {
return createLayer(newOptions, map);
}
return null;
}
});
Loading