Skip to content
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
12 changes: 12 additions & 0 deletions frontend/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,15 @@ Currently, two official plugins are available:
## Expanding the ESLint configuration

If you are developing a production application, we recommend using TypeScript with type-aware lint rules enabled. Check out the [TS template](https://github.com/vitejs/vite/tree/main/packages/create-vite/template-react-ts) for information on how to integrate TypeScript and [`typescript-eslint`](https://typescript-eslint.io) in your project.


## Tests

Das Frontend enthält Jest-Tests mit React Testing Library.

```bash
npm install
npm test -- --runInBand
```

Die dokumentierten Testergebnisse stehen in [`TEST_RESULTS.md`](./TEST_RESULTS.md).
57 changes: 57 additions & 0 deletions frontend/TEST_RESULTS.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
# Testergebnisse React-Frontend

Datum: 05.06.2026
Bereich: `frontend`
Testframework: Jest + React Testing Library

## Ausgeführte Befehle

```bash
cd frontend
npm test -- --runInBand
npm run lint
npm run build
```

## Ergebnis

| Prüfung | Ergebnis |
|---|---:|
| Jest Test Suites | 1 passed, 1 total |
| Jest Tests | 3 passed, 3 total |
| Snapshots | 0 total |
| ESLint | erfolgreich, keine Fehler |
| Vite Build | erfolgreich |

## Getestete Funktionen

1. **Aufgaben laden**
- Mockt `GET http://localhost:8080/tasks`.
- Prüft, ob offene und erledigte Aufgaben korrekt angezeigt werden.

2. **Neue Aufgabe erstellen**
- Mockt initiales Laden, `POST http://localhost:8080/tasks` und erneutes Laden.
- Prüft, ob die richtige JSON-Payload gesendet wird.
- Prüft, ob die neue Aufgabe danach in der Liste erscheint.

3. **Leere Eingabe verhindern**
- Prüft, ob bei leerem Formular eine Fehlermeldung angezeigt wird.
- Prüft, dass kein zusätzlicher POST-Request ausgelöst wird.

## Konsolenausgabe

```text
PASS src/App.test.jsx
App
✓ lädt Aufgaben vom Backend und zeigt sie in der Liste an
✓ legt eine neue Aufgabe per POST an und lädt die Liste danach neu
✓ zeigt eine Fehlermeldung, wenn eine leere Aufgabe abgesendet wird

Test Suites: 1 passed, 1 total
Tests: 3 passed, 3 total
Snapshots: 0 total
```

## Bemerkung

Die Tests verwenden gemockte `fetch`-Antworten. Dadurch sind sie unabhängig vom Spring-Boot-Backend und können lokal oder in einer CI-Pipeline stabil ausgeführt werden.
6 changes: 6 additions & 0 deletions frontend/babel.config.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
module.exports = {
presets: [
['@babel/preset-env', { targets: { node: 'current' } }],
['@babel/preset-react', { runtime: 'automatic' }]
]
}
12 changes: 11 additions & 1 deletion frontend/eslint.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import reactHooks from 'eslint-plugin-react-hooks'
import reactRefresh from 'eslint-plugin-react-refresh'

export default [
{ ignores: ['dist'] },
{ ignores: ['dist', 'coverage'] },
{
files: ['**/*.{js,jsx}'],
languageOptions: {
Expand All @@ -30,4 +30,14 @@ export default [
],
},
},
{
files: ['**/*.test.{js,jsx}', 'src/setupTests.js'],
languageOptions: {
globals: {
...globals.browser,
...globals.jest,
...globals.node,
},
},
},
]
11 changes: 11 additions & 0 deletions frontend/jest.config.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
module.exports = {
testEnvironment: 'jsdom',
setupFilesAfterEnv: ['<rootDir>/src/setupTests.js'],
transform: {
'^.+\\.[jt]sx?$': 'babel-jest'
},
moduleNameMapper: {
'\\.(css|less|scss|sass)$': 'identity-obj-proxy',
'\\.(svg|png|jpg|jpeg|gif|webp)$': '<rootDir>/src/__mocks__/fileMock.js'
}
}
Loading
Loading