Skip to content

Commit

Permalink
feat(error-codes): Add additional conversion error codes (#1511)
Browse files Browse the repository at this point in the history
* feat(error-codes): Add additional conversion error codes

* feat(error-codes): Add tests

* feat(error-codes): Update variable naming

* feat(error-codes): Update to use new messages

* feat(error-codes): Match KB acronym

* feat(error-codes): Match all files page
  • Loading branch information
patlm authored Dec 12, 2023
1 parent 4616da7 commit 7bb420f
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/i18n/en-US.properties
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,10 @@ error_not_downloadable=Oops! It looks like something is wrong with this file. We
error_flash_not_enabled=We’re sorry, the preview didn’t load because Flash is not enabled on your browser. If possible, please enable Flash and refresh the page.
# Preview error message shown when loading what would be an Office Excel Online file extension in Internet Explorer
error_internet_explorer_office_online=Microsoft 365 apps and services no longer support Internet Explorer 11, therefore, Box users may have a degraded experience.
# Preview error message shown when the preview fails because the file is too large for its extension type
error_large_file=File exceeds supported size for preview. Open or download the file to view.
# Preview error message shown when the preview fails because the file does not contain data
error_zero_byte_file=Cannot preview 0 B file. Open or download the file to view.

# Archive Preview
# Label for filename column name
Expand Down
6 changes: 6 additions & 0 deletions src/lib/RepStatus.js
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,12 @@ class RepStatus extends EventEmitter {
case ERROR_CODE.CONVERSION_UNSUPPORTED_FORMAT:
errorMessage = __('error_bad_file');
break;
case ERROR_CODE.CONVERSION_LARGE_SIZE_FILE:
errorMessage = __('error_large_file');
break;
case ERROR_CODE.CONVERSION_ZERO_BYTE_FILE:
errorMessage = __('error_zero_byte_file');
break;
case ERROR_CODE.CONVERSION_FAILED:
errorMessage = __('error_reupload');
break;
Expand Down
28 changes: 28 additions & 0 deletions src/lib/__tests__/RepStatus-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -228,6 +228,34 @@ describe('lib/RepStatus', () => {
repStatus.handleResponse();
});

test('should reject with the file too big message if the rep status is error due to conversion failure', done => {
sandbox
.mock(repStatus)
.expects('reject')
.callsFake(err => {
expect(err.displayMessage).toBe(__('error_large_file'));
done();
});
repStatus.representation.status.state = 'error';
repStatus.representation.status.code = 'error_large_size_file';

repStatus.handleResponse();
});

test('should reject with the 0 byte file message if the rep status is error due to conversion failure', done => {
sandbox
.mock(repStatus)
.expects('reject')
.callsFake(err => {
expect(err.displayMessage).toBe(__('error_zero_byte_file'));
done();
});
repStatus.representation.status.state = 'error';
repStatus.representation.status.code = 'error_zero_byte_file';

repStatus.handleResponse();
});

test('should reject with the re upload message if the rep status is error due to conversion failure', done => {
sandbox
.mock(repStatus)
Expand Down
2 changes: 2 additions & 0 deletions src/lib/events.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,11 @@ export const ERROR_CODE = {
CONTENT_DOWNLOAD: 'error_content_download',
CONVERSION_FAILED: 'error_conversion_failed',
CONVERSION_GENERIC: 'error_conversion_generic',
CONVERSION_LARGE_SIZE_FILE: 'error_large_size_file',
CONVERSION_PASSWORD_PROTECTED: 'error_password_protected',
CONVERSION_TRY_AGAIN_LATER: 'error_try_again_later',
CONVERSION_UNSUPPORTED_FORMAT: 'error_unsupported_format',
CONVERSION_ZERO_BYTE_FILE: 'error_zero_byte_file',
DELETED_REPS: 'error_deleted_reps',
EXCEEDED_RETRY_LIMIT: 'error_exceeded_retry_limit',
FLASH_NOT_ENABLED: 'error_flash_not_enabled',
Expand Down

0 comments on commit 7bb420f

Please sign in to comment.