Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(frontend): migrate file handler service to Typescript, update frontend test framework and lint #1243

Merged
merged 17 commits into from
Mar 1, 2021

Conversation

karrui
Copy link
Contributor

@karrui karrui commented Feb 25, 2021

Problem

First PR of many more to migrate angularjs services into plain Typescript services!

This PR migrates the old FileHandler angularjs service to FileHandlerService.

Also fixes jest to be able to run on arbitrary *.test.ts* files.

Solution

Features:

  • use new FileHandlerService instead of old client service, remove file-handler.client.service
  • update frontend test runner to allow for typescript
  • test(FileHandlerService): add unit tests

Tests

Unit tests have been added for FileHandlerService.

  • Upload image. Should upload successfully.
  • Upload image. Cancel image upload. Should cancel upload (see network and check cancelled) and show cancel error message
  • Upload logo. Should upload successfully.
  • Upload logo. Cancel logo upload. Should cancel upload (see network and check cancelled) and show cancel error message
  • Create form with attachment field. Should behave the same as usual
    • Upload zip with invalid file extensions, should block
    • Upload file with invalid file extension, should block
    • Upload zip with all valid extensions, should succeed
    • Upload file with valid extension, should succeed.

New dependencies:

// spark-md5 is faster and needs less steps to create an md5 hash.
+ "spark-md5": "^3.0.1",
- "crypto-js": "^4.0.0",

New dev dependencies:

// Mock axios in tests
+ "jest-mock-axios": "^4.3.0",

@karrui
Copy link
Contributor Author

karrui commented Feb 25, 2021

MockAxios seems to have broken axios on the backend even though it's mocked only in public grrrrrrrrrrrrr

@karrui
Copy link
Contributor Author

karrui commented Feb 25, 2021

uploads do not work (on staging) due to the flawed generation of md5, see https://stackoverflow.com/a/48482000 for more information. WIll fix.

also make the code more performant on larger files
@karrui
Copy link
Contributor Author

karrui commented Feb 25, 2021

Tested on staging, upload, cancellation, all works! Appreciate a review.

@karrui karrui merged commit 9d2a1b4 into develop Mar 1, 2021
@karrui karrui deleted the feat/file-handler-service-ts branch March 1, 2021 08:24
@tshuli tshuli mentioned this pull request Mar 10, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants