Skip to content

Commit

Permalink
Merge pull request #1792 from terrestris/fix-merge-conflicts
Browse files Browse the repository at this point in the history
Resolve merge conflicts
  • Loading branch information
dnlkoch authored Jan 10, 2025
2 parents ce722d3 + 91e9bc2 commit 14d5381
Show file tree
Hide file tree
Showing 10 changed files with 461 additions and 27 deletions.
12 changes: 10 additions & 2 deletions .github/workflows/on-pull-request.yml
Original file line number Diff line number Diff line change
Expand Up @@ -62,11 +62,18 @@ jobs:
- name: Construct jest coverage comment input 💬
if: ${{ github.actor != 'dependabot[bot]' }}
id: construct-input
env:
MULTI_LINES_TEXT: |
All, ./coverage/all/coverage-summary.json
only changed, ./coverage/changed/coverage-summary.json
run: |
if [ "${{ env.no_tests_found }}" == "true" ]; then
echo "MULTIPLE_FILES=All, ./coverage/all/coverage-summary.json" >> $GITHUB_ENV
else
echo "MULTIPLE_FILES=All, ./coverage/all/coverage-summary.json\nonly changed, ./coverage/changed/coverage-summary.json" >> $GITHUB_ENV
echo "MULTIPLE_FILES<<EOF" >> $GITHUB_ENV
echo "$MULTI_LINES_TEXT" >> $GITHUB_ENV
echo "EOF" >> $GITHUB_ENV
cat $GITHUB_ENV
fi
- name: Jest Coverage Comment 💬
Expand All @@ -76,7 +83,8 @@ jobs:
hide-comment: false
create-new-comment: false
hide-summary: false
multiple-files: ${{ env.MULTIPLE_FILES }}
multiple-files: |
${{ env.MULTIPLE_FILES }}
- name: Get Coverage Comment Id ➡️
if: ${{ env.no_tests_found == 'true' && github.actor != 'dependabot[bot]' }}
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/on-push-main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ jobs:

- name: Get shogun-gis-client version 🔖
run: |
echo "sonar.projectVersion=$(node -pe "require('./package.json').version")" >> ./sonar-project.properties
echo "sonar.projectVersion=$(git describe --tags --abbrev=0 | sed 's/^v//')" >> ./sonar-project.properties
- name: SonarQube Scan 🔬
uses: SonarSource/[email protected]
Expand Down
19 changes: 19 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,25 @@ In addition webpack has been replaced by rspack.
* update all dependencies to their latest versions ([3cfe3b3](https://github.com/terrestris/shogun-gis-client/commit/3cfe3b334a84cfd668825f34ace637bb414ecbf2))


### Bugfixes

* :lipstick: ([050ef7e](https://github.com/terrestris/shogun-gis-client/commit/050ef7ec6616f4014bcecbc5f30814c2b979e413))
* fixes broken image symbol ([ef955f0](https://github.com/terrestris/shogun-gis-client/commit/ef955f0c3f4481efd0f12f27ee73fef9680857ee))
* fixes bug in case no appID is passed ([95e9a23](https://github.com/terrestris/shogun-gis-client/commit/95e9a23f6c58cf8b8699ee24a03c3a692f297a2e))

## [8.11.1](https://github.com/terrestris/shogun-gis-client/compare/v8.11.0...v8.11.1) (2024-10-18)


### Dependencies

* **deps:** bump SonarSource/sonarqube-scan-action from 2.3.0 to 3.0.0 ([8cbb4e6](https://github.com/terrestris/shogun-gis-client/commit/8cbb4e60ca811f3d32800c4795729a7a58616297))


### Changes in configuration

* enable releases from next and 8.x branches ([069e941](https://github.com/terrestris/shogun-gis-client/commit/069e941aa01cedd23da7d48d939eb9885c3fd234))


### Bugfixes

* :lipstick: ([050ef7e](https://github.com/terrestris/shogun-gis-client/commit/050ef7ec6616f4014bcecbc5f30814c2b979e413))
Expand Down
9 changes: 6 additions & 3 deletions jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,11 @@ module.exports = {
'^.+\\.tsx?$': 'babel-jest'
},
testMatch: ['<rootDir>/src/**/?(*.)(spec).(j|t)s?(x)'],
testPathIgnorePatterns: ['/e2e-tests/'],
collectCoverageFrom: ['src/**/?!(*.ui)*.{tsx,jsx,ts,js}'],
testPathIgnorePatterns: ['<rootDir>/src/e2e-tests/'],
collectCoverageFrom: [
'<rootDir>/src/**/*.{tsx,jsx,ts,js}',
'!<rootDir>/src/e2e-tests/**'
],
setupFilesAfterEnv: [
'<rootDir>/jest.setup.js',
'<rootDir>/jest/matchMediaMock.js',
Expand All @@ -34,6 +37,6 @@ module.exports = {
'default',
'@casualbot/jest-sonar-reporter'
],
coverageReporters: ['json-summary', 'lcov'],
coverageReporters: ['json-summary', 'lcov', 'text'],
coverageDirectory: 'coverage/all'
};
1 change: 1 addition & 0 deletions jest.setup.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import '@testing-library/jest-dom';
import 'jest-canvas-mock';
import {
TextDecoder,
TextEncoder
Expand Down
29 changes: 29 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,7 @@
"husky": "^9.1.7",
"ignore-loader": "^0.1.2",
"jest": "^29.7.0",
"jest-canvas-mock": "^2.5.2",
"jest-environment-jsdom": "^29.7.0",
"less": "^4.2.1",
"less-loader": "^12.2.0",
Expand Down
88 changes: 79 additions & 9 deletions src/components/EditFeatureDrawer/DeleteButton/index.spec.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@ import {
fireEvent,
render,
screen,
waitFor
waitFor,
within
} from '@testing-library/react';

import {
Expand All @@ -19,8 +20,15 @@ import OlMap from 'ol/Map';
import OlSourceTileWMS from 'ol/source/TileWMS';
import OlView from 'ol/View';

import { Provider } from 'react-redux';

import { WmsLayer } from '@terrestris/ol-util/dist/typeUtils/typeUtils';

import { renderInMapContext } from '@terrestris/react-util/dist/Util/rtlTestUtils';

import useExecuteWfsTransaction from '../../../hooks/useExecuteWfsTransaction';
import useWriteWfsTransaction from '../../../hooks/useWriteWfsTransaction';
import { store } from '../../../store/store';
import { createReduxWrapper } from '../../../utils/testUtils';

import DeleteButton from '.';
Expand All @@ -29,6 +37,9 @@ let mockLayer: WmsLayer;
let mockFeature: Feature;
let map: OlMap;

jest.mock('../../../hooks/useWriteWfsTransaction');
jest.mock('../../../hooks/useExecuteWfsTransaction');

describe('<DeleteButton />', () => {

beforeEach(() => {
Expand Down Expand Up @@ -96,14 +107,26 @@ describe('<DeleteButton />', () => {
expect(deleteButton).toBeVisible();
});

it('confirm popover is opened on click', async () => {
render(
<DeleteButton
data-testid='delete'
feature={mockFeature}
layer={mockLayer}
/>,
{ wrapper: createReduxWrapper() }
it('confirm popover is opened on click and delete is successfully executed on confirm', async () => {
const mockSuccessFunction = jest.fn();
const mockTransaction = document.createElement('div');
mockTransaction.textContent = 'Mocked Node';
const mockWriteWfsTransaction = jest.fn().mockResolvedValue(mockTransaction);
const mockExecuteWfsTransaction = jest.fn().mockResolvedValue({});

(useWriteWfsTransaction as jest.Mock).mockReturnValueOnce(mockWriteWfsTransaction);
(useExecuteWfsTransaction as jest.Mock).mockReturnValueOnce(mockExecuteWfsTransaction);

renderInMapContext(
map,
<Provider store={store}>
<DeleteButton
data-testid='delete'
feature={mockFeature}
layer={mockLayer}
onSuccess={mockSuccessFunction}
/>
</Provider>
);

const deleteButton = screen.getByText('DeleteButton.title');
Expand All @@ -117,5 +140,52 @@ describe('<DeleteButton />', () => {
await waitFor(() => {
expect(popover).toBeVisible();
});

const tooltip = within(screen.getByRole('tooltip'));

fireEvent.click(tooltip.getByText('OK'));

await waitFor(() => {
expect(mockWriteWfsTransaction).toHaveBeenCalled();
expect(mockExecuteWfsTransaction).toHaveBeenCalled();
expect(mockSuccessFunction).toHaveBeenCalled();
});
});

it('Error function is called when delete operation can not be executed', async () => {
const mockErrorFunction = jest.fn();

renderInMapContext(
map,
<Provider store={store}>
<DeleteButton
data-testid='delete'
feature={mockFeature}
layer={mockLayer}
onError={mockErrorFunction}
/>
</Provider>
);

const deleteButton = screen.getByText('DeleteButton.title');
expect(deleteButton).toBeVisible();

act(() => {
fireEvent.click(deleteButton);
});

const popover = document.querySelector('.ant-popover-open');
await waitFor(() => {
expect(popover).toBeVisible();
});

const tooltip = within(screen.getByRole('tooltip'));

fireEvent.click(tooltip.getByText('OK'));

await waitFor(() => {
expect(mockErrorFunction).toHaveBeenCalled();
});
});
});

Loading

0 comments on commit 14d5381

Please sign in to comment.