Skip to content

Commit

Permalink
geosolutions-it#10487: Custom Tile Grids settings for WMS service are…
Browse files Browse the repository at this point in the history
… not retained when adding a Background layer from Catalog

Description:
- resolve FE failing test
  • Loading branch information
mahmoudadel54 committed Jul 25, 2024
1 parent d4a47a0 commit a1dcd22
Showing 1 changed file with 21 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,23 @@ import BackgroundDialog from '../BackgroundDialog';

import axios from '../../../libs/ajax';
import MockAdapter from 'axios-mock-adapter';
import { waitFor } from '@testing-library/react';
let mockAxios;

describe('test BackgroundDialog', () => {
beforeEach((done) => {
document.body.innerHTML = '<div id="container"></div>';
mockAxios = new MockAdapter(axios);
setTimeout(done);
});

afterEach((done) => {
ReactDOM.unmountComponentAtNode(document.getElementById("container"));
document.body.innerHTML = '';
if (mockAxios) {
mockAxios.restore();
}
mockAxios = null;
setTimeout(done);
});

Expand Down Expand Up @@ -88,8 +94,7 @@ describe('test BackgroundDialog', () => {
expect(wmsCacheOptionsToolbar).toBeTruthy();
});
it('should render with WMS cache options with remoteTileGrids = true', (done) => {
mockAxios = new MockAdapter(axios);
mockAxios.onGet().reply(200, {
mockAxios.onGet().replyOnce(200, {
tileMatrixSets: [],
tileMatrixSetLinks: [],
tileGrids: [],
Expand All @@ -105,18 +110,19 @@ describe('test BackgroundDialog', () => {
}}
/>,
document.getElementById("container"));
setTimeout(() => {
const modalNode = document.querySelector('#ms-resizable-modal');
expect(modalNode).toBeTruthy();
const wmsCacheOptionsContent = document.querySelector('.ms-wms-cache-options-content');
expect(wmsCacheOptionsContent).toBeTruthy();
const wmsCacheOptionsToolbar = document.querySelector('.ms-wms-cache-options-toolbar');
expect(wmsCacheOptionsToolbar).toBeTruthy();
const wmsCacheCustomGridOption = document.querySelector('.ms-wms-cache-options-toolbar button.active span.glyphicon-grid-custom');
expect(wmsCacheCustomGridOption).toBeTruthy();
const wmsCacheRefreshOption = document.querySelector('.ms-wms-cache-options-toolbar .glyphicon-refresh');
expect(wmsCacheRefreshOption).toBeTruthy();
done();
}, 1000);
const modalNode = document.querySelector('#ms-resizable-modal');
expect(modalNode).toBeTruthy();
const wmsCacheOptionsContent = document.querySelector('.ms-wms-cache-options-content');
expect(wmsCacheOptionsContent).toBeTruthy();
const wmsCacheOptionsToolbar = document.querySelector('.ms-wms-cache-options-toolbar');
expect(wmsCacheOptionsToolbar).toBeTruthy();
waitFor(()=>expect(document.querySelector('.ms-wms-cache-options-toolbar button.active span.glyphicon-grid-custom')).toBeTruthy())
.then(()=>{
const wmsCacheCustomGridOption = document.querySelector('.ms-wms-cache-options-toolbar button.active span.glyphicon-grid-custom');
expect(wmsCacheCustomGridOption).toBeTruthy();
const wmsCacheRefreshOption = document.querySelector('.ms-wms-cache-options-toolbar .glyphicon-refresh');
expect(wmsCacheRefreshOption).toBeTruthy();
done();
}).catch(done);
});
});

0 comments on commit a1dcd22

Please sign in to comment.