From 34a3b1e280d248c09dfbf3edf275c4cef7babd3b Mon Sep 17 00:00:00 2001 From: David Linhardt <76444188+MysterionAutotronic@users.noreply.github.com> Date: Sun, 9 Jun 2024 20:02:10 +0200 Subject: [PATCH 1/3] add handling for 503 and 413 --- src/locales/de/userProject.json | 3 ++- src/locales/en/userProject.json | 3 ++- src/pages/Commit/Commit.tsx | 5 ++++- 3 files changed, 8 insertions(+), 3 deletions(-) diff --git a/src/locales/de/userProject.json b/src/locales/de/userProject.json index 4ff28a9..9f3120a 100644 --- a/src/locales/de/userProject.json +++ b/src/locales/de/userProject.json @@ -30,5 +30,6 @@ "errorAlreadySubmitted": "Sie haben bereits eine Lösung für diese Challenge eingereicht. Wenn Sie denken, dass dies ein Fehler ist, kontaktieren Sie uns bitte.", "errorZIPBombDetected": "Der Inhalt der ZIP Datei, die sie hochgeladen haben übersteigt die maximale Größe von 100MB oder enthält weitere ZIP Dateien.", "errorZIPFileTooLarge": "Die ZIP Datei, die sie hochgeladen haben übersteigt die maximale Größe von 100MB.", - "linterResult": "Dein Linting Ergebnis" + "linterResult": "Dein Linting Ergebnis", + "errorServerConfig": "Serverkonfigurationsfehler. Bitte kontaktieren Sie einen Administrator." } diff --git a/src/locales/en/userProject.json b/src/locales/en/userProject.json index 589a14f..d9b44ab 100644 --- a/src/locales/en/userProject.json +++ b/src/locales/en/userProject.json @@ -30,5 +30,6 @@ "errorAlreadySubmitted": "You have already submitted this challenge. If you think this is an error, please contact us.", "errorZIPBombDetected": "Your ZIP files content exceeds 100MB or contains nested ZIP files.", "errorZIPFileTooLarge": "Your ZIP file exceeds the maximum size of 100MB.", - "linterResult": "Your linting result" + "linterResult": "Your linting result", + "errorServerConfig": "Server configuration error. Please contact an admin." } diff --git a/src/pages/Commit/Commit.tsx b/src/pages/Commit/Commit.tsx index 679299b..fc3b66b 100644 --- a/src/pages/Commit/Commit.tsx +++ b/src/pages/Commit/Commit.tsx @@ -306,11 +306,14 @@ const Commit = () => { case StatusCodes.GONE: toast.showToast(ToastType.ERROR, t('errorSubmissionExpired')); break; + case StatusCodes.REQUEST_TOO_LONG: + toast.showToast(ToastType.ERROR, t('errorZIPFileTooLarge')); + break; case StatusCodes.UNPROCESSABLE_ENTITY: toast.showToast(ToastType.ERROR, t('errorNoREADME')); break; case StatusCodes.SERVICE_UNAVAILABLE: - toast.showToast(ToastType.ERROR, t('errorZIPFileTooLarge')); + toast.showToast(ToastType.ERROR, t('errorServerConfig')); break; default: toast.showToast(ToastType.ERROR, t('errorSubmissionFailed')); From eea11b444915779438e188f855b5da43e3fe29e6 Mon Sep 17 00:00:00 2001 From: David Linhardt <76444188+MysterionAutotronic@users.noreply.github.com> Date: Sun, 9 Jun 2024 20:08:50 +0200 Subject: [PATCH 2/3] add comment --- src/pages/Commit/Commit.tsx | 1 + 1 file changed, 1 insertion(+) diff --git a/src/pages/Commit/Commit.tsx b/src/pages/Commit/Commit.tsx index fc3b66b..6a45b9a 100644 --- a/src/pages/Commit/Commit.tsx +++ b/src/pages/Commit/Commit.tsx @@ -313,6 +313,7 @@ const Commit = () => { toast.showToast(ToastType.ERROR, t('errorNoREADME')); break; case StatusCodes.SERVICE_UNAVAILABLE: + // if this error occurs check the accessToken in GitHubApiClientConfig.kt toast.showToast(ToastType.ERROR, t('errorServerConfig')); break; default: From b0d71380500ad2fea4f1d72e2eab25fb909b728f Mon Sep 17 00:00:00 2001 From: David Linhardt <76444188+MysterionAutotronic@users.noreply.github.com> Date: Sun, 9 Jun 2024 20:13:09 +0200 Subject: [PATCH 3/3] fix test after updating error handling --- src/pages/Commit/Commit.test.jsx | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/src/pages/Commit/Commit.test.jsx b/src/pages/Commit/Commit.test.jsx index 793fccd..a902128 100644 --- a/src/pages/Commit/Commit.test.jsx +++ b/src/pages/Commit/Commit.test.jsx @@ -399,6 +399,38 @@ describe('Commit', () => { ); await user.click(uploadButton); + await screen.findByText(/Server configuration error/i); + }); + + test('zip file too large', async () => { + server.use( + http.post(`${baseURL}/v1/submission/submit`, () => { + return new HttpResponse(null, { + status: StatusCodes.REQUEST_TOO_LONG, + }); + }) + ); + + renderCommit(); + + const languageInput = await screen.findByLabelText( + /programming language\s*\*:/i + ); + const versionInput = await screen.findByLabelText(/version\s*\*:/i); + const fileUploadInput = await screen.findByTestId('fileUpload'); + const uploadButton = await screen.findByRole('button', { + name: /upload/i, + }); + const user = userEvent.setup(); + + await user.type(languageInput, 'testLanguage'); + await user.type(versionInput, 'testVersion'); + await user.upload( + fileUploadInput, + new File(['test file'], 'test.zip', { type: 'application/zip' }) + ); + await user.click(uploadButton); + await screen.findByText(/Your ZIP file exceeds the maximum size/i); });