From 18b5b4505e70957f93d7b4e528e2247cd9630423 Mon Sep 17 00:00:00 2001 From: Philippe Torrel Date: Tue, 25 Aug 2026 08:51:34 +0200 Subject: [PATCH] --- .../src/components/lists/ListUser.jsx | 15 ++- .../src/test/ListUser.jsx | 28 ------ .../src/test/ListUser.test.jsx | 91 ++++++++++++++++++ .../src/tests/CategorySection.test.tsx | 4 +- .../src/tests/Footer.test.tsx | 2 +- .../src/tests/ImageGallery.test.tsx | 7 +- .../03_performance-test-inversion.js | 57 +++++++++++ .../tag46/01_inversion/04_README.md | 38 ++++++++ .../tag46/01_inversion/04_README.pdf | Bin 0 -> 177346 bytes 9 files changed, 206 insertions(+), 36 deletions(-) delete mode 100644 05_react/unterricht/tag51/01_react-app-with-tests/src/test/ListUser.jsx create mode 100644 05_react/unterricht/tag51/01_react-app-with-tests/src/test/ListUser.test.jsx create mode 100644 06_js-debug/unterricht/tag46/01_inversion/03_performance-test-inversion.js create mode 100644 06_js-debug/unterricht/tag46/01_inversion/04_README.md create mode 100644 06_js-debug/unterricht/tag46/01_inversion/04_README.pdf diff --git a/05_react/unterricht/tag51/01_react-app-with-tests/src/components/lists/ListUser.jsx b/05_react/unterricht/tag51/01_react-app-with-tests/src/components/lists/ListUser.jsx index 66edae2..442d44f 100644 --- a/05_react/unterricht/tag51/01_react-app-with-tests/src/components/lists/ListUser.jsx +++ b/05_react/unterricht/tag51/01_react-app-with-tests/src/components/lists/ListUser.jsx @@ -5,7 +5,7 @@ const ListUser = (props) => { // const { } = props; const [users, setUsers] = useState([]); const [isLoading, setIsLoading] = useState(false); - // const [error, setError] = useState(null); + const [error, setError] = useState(null); useEffect(() => { const controller = new AbortController(); // 2019 @@ -18,7 +18,8 @@ const ListUser = (props) => { }) .then(({ data }) => { console.log(data); - setUsers(data?.users); + setUsers(data?.users ?? []); + setError(null); }) .catch((err) => { // @@ -27,6 +28,7 @@ const ListUser = (props) => { console.error('Request abgebrochen:', err.message); } else { console.error('Error:', err); + setError(err); } }) .finally(() => { @@ -47,6 +49,15 @@ const ListUser = (props) => { return

is loading users...

; } + if (error) { + const status = error.response?.status; + return ( +

+ {status ? `Failed to load users (HTTP ${status})` : 'Failed to load users'} +

+ ); + } + return (