Skip to content

Commit

Permalink
Merge branch 'main' into next
Browse files Browse the repository at this point in the history
  • Loading branch information
dnlkoch committed Oct 21, 2024
2 parents 52bc2b2 + 4b3533c commit 1c57d55
Show file tree
Hide file tree
Showing 48 changed files with 4,367 additions and 1,716 deletions.
8 changes: 5 additions & 3 deletions .github/workflows/on-push-main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,9 @@ jobs:
echo "sonar.projectVersion=$(node -pe "require('./package.json').version")" >> ./sonar-project.properties
- name: SonarQube Scan 🔬
uses: kitabisa/sonarqube-action@v1.2.1
uses: SonarSource/sonarqube-scan-action@v3.0.0
with:
host: ${{ secrets.SONARQUBE_HOST }}
login: ${{ secrets.SONARQUBE_TOKEN }}
projectBaseDir: .
env:
SONAR_TOKEN: ${{ secrets.SONARQUBE_TOKEN }}
SONAR_HOST_URL: ${{ secrets.SONARQUBE_HOST }}
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
![nodejs](https://github.com/terrestris/shogun-admin/actions/workflows/nodejs.yml/badge.svg)

![release](https://github.com/terrestris/shogun-admin/actions/workflows/release.yaml/badge.svg)

# shogun-admin

## An UI for handling SHOGun entities like users, applications, and layers
Expand Down
3,191 changes: 1,536 additions & 1,655 deletions package-lock.json

Large diffs are not rendered by default.

68 changes: 34 additions & 34 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,90 +34,90 @@
},
"homepage": "https://github.com/terrestris/shogun-admin#readme",
"dependencies": {
"@ant-design/icons": "5.3.7",
"@ant-design/icons": "5.5.1",
"@ant-design/pro-components": "^2.7.10",
"@casualbot/jest-sonar-reporter": "2.3.1",
"@casualbot/jest-sonar-reporter": "2.4.0",
"@monaco-editor/react": "4.6.0",
"@terrestris/base-util": "2.0.0",
"@terrestris/ol-util": "19.0.0",
"@terrestris/shogun-util": "8.5.0",
"@terrestris/ol-util": "19.0.1",
"@terrestris/shogun-util": "9.0.0",
"@uiw/react-md-editor": "4.0.4",
"antd": "5.17.2",
"i18next": "23.11.5",
"i18next": "23.15.1",
"i18next-browser-languagedetector": "8.0.0",
"js-logger": "1.6.1",
"js-md5": "0.8.3",
"json-schema": "0.4.0",
"keycloak-js": "25.0.1",
"keycloak-js": "25.0.6",
"lodash": "4.17.21",
"moment": "2.30.1",
"monaco-editor": "0.50.0",
"ol": "9.2.4",
"monaco-editor": "0.52.0",
"ol": "10.2.1",
"react": "18.3.1",
"react-dom": "18.3.1",
"react-hotkeys-hook": "4.5.0",
"react-i18next": "14.1.2",
"react-router-dom": "6.24.0",
"react-hotkeys-hook": "4.5.1",
"react-i18next": "15.0.2",
"react-router-dom": "6.27.0",
"recoil": "0.7.7",
"shapefile.js": "1.1.4"
},
"devDependencies": {
"@babel/core": "7.24.7",
"@babel/core": "7.25.2",
"@babel/plugin-proposal-class-properties": "7.18.6",
"@babel/plugin-proposal-object-rest-spread": "7.20.7",
"@babel/plugin-proposal-optional-chaining": "7.21.0",
"@babel/polyfill": "7.12.1",
"@babel/preset-env": "7.24.7",
"@babel/preset-react": "7.24.7",
"@babel/preset-typescript": "7.24.7",
"@commitlint/cli": "19.3.0",
"@commitlint/config-conventional": "19.2.2",
"@playwright/test": "1.45.0",
"@babel/preset-env": "7.25.8",
"@babel/preset-react": "7.25.7",
"@babel/preset-typescript": "7.25.7",
"@commitlint/cli": "19.5.0",
"@commitlint/config-conventional": "19.5.0",
"@playwright/test": "1.47.2",
"@originjs/vite-plugin-federation": "^1.3.5",
"@semantic-release/changelog": "6.0.3",
"@semantic-release/git": "10.0.1",
"@semantic-release/github": "10.0.6",
"@semantic-release/github": "11.0.0",
"@semantic-release/npm": "12.0.1",
"@semantic-release/release-notes-generator": "14.0.1",
"@terrestris/eslint-config-typescript": "5.0.0",
"@terrestris/eslint-config-typescript-react": "2.0.0",
"@testing-library/jest-dom": "6.4.6",
"@testing-library/react": "16.0.0",
"@types/jest": "29.5.12",
"@types/react": "18.3.3",
"@testing-library/jest-dom": "6.5.0",
"@testing-library/react": "16.0.1",
"@types/jest": "29.5.13",
"@types/react": "18.3.11",
"@types/react-dom": "18.3.0",
"@types/react-redux": "7.1.33",
"@types/react-redux": "7.1.34",
"@types/react-router-dom": "5.3.3",
"@typescript-eslint/eslint-plugin": "7.14.1",
"@typescript-eslint/eslint-plugin": "7.18.0",
"@typescript-eslint/eslint-plugin-tslint": "7.0.2",
"@typescript-eslint/parser": "7.14.1",
"@typescript-eslint/parser": "7.17.0",
"@vitejs/plugin-react": "^4.3.1",
"babel-plugin-import": "^1.13.8",
"buffer": "6.0.3",
"dotenv": "16.4.5",
"eslint": "8.57.0",
"eslint-plugin-import": "2.29.1",
"eslint-plugin-import": "2.30.0",
"eslint-plugin-react-hooks": "4.6.2",
"husky": "9.0.11",
"husky": "9.1.6",
"isomorphic-fetch": "3.0.0",
"jest": "29.7.0",
"jest-dom": "4.0.0",
"jest-environment-jsdom": "29.7.0",
"less": "4.2.0",
"mini-css-extract-plugin": "2.9.0",
"mini-css-extract-plugin": "2.9.1",
"openapi-types": "12.1.3",
"regenerator-runtime": "0.14.1",
"rimraf": "5.0.7",
"semantic-release": "24.0.0",
"typescript": "5.5.2",
"rimraf": "6.0.1",
"semantic-release": "24.1.2",
"typescript": "5.6.3",
"vite": "^5.2.13",
"vite-plugin-externals": "^0.6.2",
"vite-plugin-top-level-await": "^1.4.1",
"vitest": "^1.6.0",
"vitest": "^2.0.5",
"whatwg-fetch": "3.6.20"
},
"optionalDependencies": {
"@rollup/rollup-linux-x64-gnu": "4.18.0"
"@rollup/rollup-linux-x64-gnu": "4.24.0"
},
"@casualbot/jest-sonar-reporter": {
"suiteName": "jest tests",
Expand Down
12 changes: 7 additions & 5 deletions src/App.less
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,11 @@
}

.result-spin {
height: 100%;
width: 100%;
display: block;
position: absolute;
top: 50%;
position: fixed;
inset: 0px;
width: 16rem;
height: 15rem;
max-width: 100vw;
max-height: 90dvh;
margin: auto;
}
46 changes: 46 additions & 0 deletions src/Component/Dashboard/Dashboard.spec.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
import React from 'react';

import {
render,
screen
} from '@testing-library/react';

import { Dashboard } from './Dashboard';

describe('<Dashboard />', () => {
Expand All @@ -6,4 +13,43 @@ describe('<Dashboard />', () => {
expect(Dashboard).not.toBeUndefined();
});

it('can be rendered', () => {
const {
container
} = render(<Dashboard />);
expect(container).toBeVisible();

const dashboardElement = container.querySelector('.dashboard');
expect(dashboardElement).toBeVisible();

const headerElement = container.querySelector('.header');
expect(headerElement).toBeVisible();
});

it('properties are rendered', () => {
const {
container
} = render(
<Dashboard
actions={'test-action'}
icon={'test-icon'}
columns={3}
rows={3}
title={'test-title'}
/>);

const iconElement = screen.getByAltText('test-title icon');
expect(iconElement).toBeVisible();
expect(iconElement).toHaveAttribute('src', 'test-icon');

const titleElement = screen.getByText('test-title');
expect(titleElement).toBeVisible();

const actionsElement = screen.getByText('test-action');
expect(actionsElement).toBeVisible();

const gridElement = container.querySelector('.grid');
expect(gridElement).toBeVisible();
expect(gridElement).toHaveStyle('grid-template-columns: repeat(3, 1fr);');
});
});
43 changes: 43 additions & 0 deletions src/Component/Dashboard/DashboardCard/DashboardCard.spec.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
import React from 'react';

import {
render,
screen
} from '@testing-library/react';

import { DashboardCard } from './DashboardCard';

describe('<DashboardCard />', () => {
Expand All @@ -6,4 +13,40 @@ describe('<DashboardCard />', () => {
expect(DashboardCard).not.toBeUndefined();
});

it('can be rendered', () => {
const {
container
} = render(<DashboardCard />);
expect(container).toBeVisible();

const bodyElement = container.querySelector('.dashboard-card-body');
expect(bodyElement).toBeVisible();
});

it('properties are rendered', () => {
const testActions = ['test-action1', 'test-action2'];
const actionWidth = 100 / testActions.length;

render(
<DashboardCard
actions={testActions}
avatar={'test-avatar'}
description={'test-description'}
title={'test-title'}
/>);
const actionElement = screen.getByText('test-action1');
expect(actionElement).toBeVisible();
expect(actionElement.parentElement).toHaveStyle(`width: ${actionWidth}%;`);
});

it('can be made hoverable', () => {
const {
container
} = render(
<DashboardCard
hoverable={true}
/>);
const cardElement = container.querySelector('.hoverable');
expect(cardElement).toBeVisible();
});
});
Original file line number Diff line number Diff line change
@@ -1,9 +1,98 @@
import React from 'react';

import {
cleanup,
render,
screen,
waitForElementToBeRemoved
} from '@testing-library/react';

import Application from '@terrestris/shogun-util/dist/model/Application';
import Layer from '@terrestris/shogun-util/dist/model/Layer';
import { Page } from '@terrestris/shogun-util/dist/model/Page';
import User from '@terrestris/shogun-util/dist/model/User';
import GenericEntityService from '@terrestris/shogun-util/dist/service/GenericEntityService';
import { PageOpts } from '@terrestris/shogun-util/dist/service/GenericService';

import { DashboardStatistics } from './DashboardStatistics';

const mockGenericEntityService = {
findAllNoPaging: jest.fn(),
findAll: jest.fn() as jest.Mock<Promise<Page<Application | User | Layer>>, [PageOpts?, RequestInit?]>,
findOne: jest.fn(),
add: jest.fn(),
update: jest.fn(),
updatePartial: jest.fn(),
delete: jest.fn(),
isPublic: jest.fn(),
setPublic: jest.fn(),
revokePublic: jest.fn(),
getBasePath: jest.fn()
} as unknown as GenericEntityService<Application | User | Layer>;

describe('<DashboardStatistics />', () => {
let testName: {
singular: string;
plural: string;
};

beforeEach(() => {
testName = {
singular: 'Mock Layer',
plural: 'Mock Layers',
};

const mockEntitiesResponse = {
totalElements: 10,
content: [{
id: 1,
name: 'Mock Layer'
}]
};

(mockGenericEntityService.findAll as jest.Mock).mockResolvedValue(mockEntitiesResponse);
});

afterEach(cleanup);

it('is defined', () => {
expect(DashboardStatistics).not.toBeUndefined();
});

it('can be rendered', async () => {
const {
container
} = render(
<DashboardStatistics
service={mockGenericEntityService}
name={testName}
/>);
expect(container).toBeVisible();
await waitForElementToBeRemoved(() => screen.queryByText(/-1 Mock Layer/i));
});

it('is rendered with statistics', async () => {
const {
container
} = render(
<DashboardStatistics
service={mockGenericEntityService}
name={testName}
/>);
const statisticsElement = container.querySelector('.statistics-card');
expect(statisticsElement).toBeVisible();

const titleElement = screen.getByText('DashboardStatistics.statisticsTitle');
expect(titleElement).toBeVisible();

expect(container.innerHTML).toContain('-1 Mock Layer');
await waitForElementToBeRemoved(() => screen.queryByText(/-1 Mock Layer/i));

expect(mockGenericEntityService.findAll).toHaveBeenCalledWith({
page: 0,
size: 1
});

expect(container.innerHTML).toContain('10 Mock Layers');
});
});
Loading

0 comments on commit 1c57d55

Please sign in to comment.