Skip to content

Commit

Permalink
trim announcement text fields
Browse files Browse the repository at this point in the history
  • Loading branch information
goemen committed Sep 24, 2024
1 parent a12f024 commit de83062
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions admin-frontend/src/services/apiService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -519,8 +519,8 @@ export default {

const buildFormData = (data: AnnouncementFormValue) => {
const formData = new FormData();
formData.append('title', data.title);
formData.append('description', data.description);
formData.append('title', data.title.trim());
formData.append('description', data.description.trim());

Check failure on line 523 in admin-frontend/src/services/apiService.ts

View workflow job for this annotation

GitHub Actions / Unit Tests (admin-frontend)

Unhandled error

TypeError: Cannot read properties of undefined (reading 'trim') ❯ buildFormData src/services/apiService.ts:523:51 ❯ Object.updateAnnouncement src/services/apiService.ts:448:22 ❯ src/services/__tests__/apiService.spec.ts:476:33 ❯ node_modules/@vitest/runner/dist/index.js:146:14 ❯ node_modules/@vitest/runner/dist/index.js:61:7 ❯ runTest node_modules/@vitest/runner/dist/index.js:960:17 ❯ processTicksAndRejections node:internal/process/task_queues:95:5 ❯ runSuite node_modules/@vitest/runner/dist/index.js:1116:15 ❯ runSuite node_modules/@vitest/runner/dist/index.js:1116:15 ❯ runSuite node_modules/@vitest/runner/dist/index.js:1116:15 This error originated in "src/services/__tests__/apiService.spec.ts" test file. It doesn't mean the error was thrown inside the file itself, but while it was running. The latest test that might've caused the error is "src/services/__tests__/apiService.spec.ts". It might mean one of the following: - The error was thrown, while Vitest was running this test. - If the error occurred after the test had been completed, this was the last documented test before it was thrown.

Check failure on line 523 in admin-frontend/src/services/apiService.ts

View workflow job for this annotation

GitHub Actions / Unit Tests (admin-frontend)

Unhandled error

TypeError: Cannot read properties of undefined (reading 'trim') ❯ buildFormData src/services/apiService.ts:523:51 ❯ Object.updateAnnouncement src/services/apiService.ts:448:22 ❯ src/services/__tests__/apiService.spec.ts:510:33 ❯ node_modules/@vitest/runner/dist/index.js:146:14 ❯ node_modules/@vitest/runner/dist/index.js:61:7 ❯ runTest node_modules/@vitest/runner/dist/index.js:960:17 ❯ processTicksAndRejections node:internal/process/task_queues:95:5 ❯ runSuite node_modules/@vitest/runner/dist/index.js:1116:15 ❯ runSuite node_modules/@vitest/runner/dist/index.js:1116:15 ❯ runSuite node_modules/@vitest/runner/dist/index.js:1116:15 This error originated in "src/services/__tests__/apiService.spec.ts" test file. It doesn't mean the error was thrown inside the file itself, but while it was running. The latest test that might've caused the error is "src/services/__tests__/apiService.spec.ts". It might mean one of the following: - The error was thrown, while Vitest was running this test. - If the error occurred after the test had been completed, this was the last documented test before it was thrown.
formData.append('status', data.status);
if (data.active_on) {
formData.append('active_on', data.active_on);
Expand All @@ -529,7 +529,7 @@ const buildFormData = (data: AnnouncementFormValue) => {
formData.append('expires_on', data.expires_on);
}
if (data.linkUrl && data.linkDisplayName) {
formData.append('linkUrl', data.linkUrl);
formData.append('linkUrl', data.linkUrl.trim());
formData.append('linkDisplayName', data.linkDisplayName);
}

Expand All @@ -538,7 +538,7 @@ const buildFormData = (data: AnnouncementFormValue) => {
}

if (data.fileDisplayName) {
formData.append('fileDisplayName', data.fileDisplayName);
formData.append('fileDisplayName', data.fileDisplayName.trim());
}

if (data.attachmentId) {
Expand Down

0 comments on commit de83062

Please sign in to comment.