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.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); }); diff --git a/src/pages/Commit/Commit.tsx b/src/pages/Commit/Commit.tsx index 679299b..6a45b9a 100644 --- a/src/pages/Commit/Commit.tsx +++ b/src/pages/Commit/Commit.tsx @@ -306,11 +306,15 @@ 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')); + // if this error occurs check the accessToken in GitHubApiClientConfig.kt + toast.showToast(ToastType.ERROR, t('errorServerConfig')); break; default: toast.showToast(ToastType.ERROR, t('errorSubmissionFailed'));