-
Notifications
You must be signed in to change notification settings - Fork 0
fix: improve handling of Launch deployment file upload size errors #122
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
Merged
+365
−1
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,158 @@ | ||
| import { | ||
| collectLaunchDeploymentErrorCodesFromGraphQLError, | ||
| FILE_UPLOAD_SIZE_LIMIT_USER_MESSAGE, | ||
| isLaunchDeploymentFileSizeRelatedError, | ||
| } from './deployment-errors'; | ||
|
|
||
| describe('deployment-errors', () => { | ||
| it('should expose user message aligned with Launch file upload rules', () => { | ||
| expect(FILE_UPLOAD_SIZE_LIMIT_USER_MESSAGE).toBe( | ||
| 'Please use a file over the size of 1KB and under the size of 100MB.', | ||
| ); | ||
| }); | ||
|
|
||
| it('should collect codes from messages, uploadUid errorObject, and cause graphQLErrors in one flow', () => { | ||
| const error = { | ||
| graphQLErrors: [ | ||
| { | ||
| extensions: { | ||
| exception: { | ||
| messages: ['launch.DEPLOYMENT.INVALID_FILE_SIZE', 'other'], | ||
| errorObject: { | ||
| uploadUid: [{ code: 'launch.DEPLOYMENT.FILE_UPLOAD_FAILED' }], | ||
| }, | ||
| }, | ||
| }, | ||
| }, | ||
| ], | ||
| cause: { | ||
| graphQLErrors: [ | ||
| { | ||
| extensions: { | ||
| exception: { | ||
| messages: ['launch.OTHER.CODE'], | ||
| }, | ||
| }, | ||
| }, | ||
| ], | ||
| }, | ||
| }; | ||
|
|
||
| const codes = collectLaunchDeploymentErrorCodesFromGraphQLError(error); | ||
|
|
||
| expect(codes).toEqual([ | ||
| 'launch.DEPLOYMENT.INVALID_FILE_SIZE', | ||
| 'other', | ||
| 'launch.DEPLOYMENT.FILE_UPLOAD_FAILED', | ||
| 'launch.OTHER.CODE', | ||
| ]); | ||
| expect(isLaunchDeploymentFileSizeRelatedError(error)).toBe(true); | ||
| }); | ||
|
|
||
| it('should return false when graphQL errors have no file size related codes', () => { | ||
| const error = { | ||
| graphQLErrors: [ | ||
| { | ||
| extensions: { | ||
| exception: { | ||
| messages: ['launch.PROJECTS.DUPLICATE_NAME'], | ||
| }, | ||
| }, | ||
| }, | ||
| ], | ||
| }; | ||
|
|
||
| expect(collectLaunchDeploymentErrorCodesFromGraphQLError(error)).toEqual(['launch.PROJECTS.DUPLICATE_NAME']); | ||
| expect(isLaunchDeploymentFileSizeRelatedError(error)).toBe(false); | ||
| }); | ||
|
|
||
| it('should return false for empty or malformed error input', () => { | ||
| expect(collectLaunchDeploymentErrorCodesFromGraphQLError(undefined)).toEqual([]); | ||
| expect(isLaunchDeploymentFileSizeRelatedError(undefined)).toBe(false); | ||
| expect(collectLaunchDeploymentErrorCodesFromGraphQLError({})).toEqual([]); | ||
| expect(isLaunchDeploymentFileSizeRelatedError({})).toBe(false); | ||
| expect( | ||
| collectLaunchDeploymentErrorCodesFromGraphQLError({ | ||
| graphQLErrors: [{ extensions: {} }], | ||
| }), | ||
| ).toEqual([]); | ||
| expect( | ||
| isLaunchDeploymentFileSizeRelatedError({ | ||
| graphQLErrors: [{ extensions: {} }], | ||
| }), | ||
| ).toBe(false); | ||
| }); | ||
|
|
||
| it('should skip non-string entries in messages and still collect string codes', () => { | ||
| const error = { | ||
| graphQLErrors: [ | ||
| { | ||
| extensions: { | ||
| exception: { | ||
| messages: [ | ||
| null, | ||
| 42, | ||
| { nested: 'launch.DEPLOYMENT.INVALID_FILE_SIZE' }, | ||
| 'launch.DEPLOYMENT.INVALID_FILE_SIZE', | ||
| '', | ||
| ' ', | ||
| '\t', | ||
| ], | ||
| }, | ||
| }, | ||
| }, | ||
| ], | ||
| }; | ||
|
|
||
| const codes = collectLaunchDeploymentErrorCodesFromGraphQLError(error); | ||
|
|
||
| expect(codes).toEqual(['launch.DEPLOYMENT.INVALID_FILE_SIZE']); | ||
| expect(isLaunchDeploymentFileSizeRelatedError(error)).toBe(true); | ||
| }); | ||
|
|
||
| it('should skip uploadUid entries without a string code and still collect valid codes', () => { | ||
| const error = { | ||
| graphQLErrors: [ | ||
| { | ||
| extensions: { | ||
| exception: { | ||
| errorObject: { | ||
| uploadUid: [ | ||
| null, | ||
| 'not-an-object', | ||
| {}, | ||
| { code: 123 }, | ||
| { notCode: 'launch.DEPLOYMENT.FILE_UPLOAD_FAILED' }, | ||
| { code: 'launch.DEPLOYMENT.FILE_UPLOAD_FAILED' }, | ||
| ], | ||
| }, | ||
| }, | ||
| }, | ||
| }, | ||
| ], | ||
| }; | ||
|
|
||
| const codes = collectLaunchDeploymentErrorCodesFromGraphQLError(error); | ||
|
|
||
| expect(codes).toEqual(['launch.DEPLOYMENT.FILE_UPLOAD_FAILED']); | ||
| expect(isLaunchDeploymentFileSizeRelatedError(error)).toBe(true); | ||
| }); | ||
|
|
||
| it('should detect FILE_UPLOAD_FAILED only from uploadUid when messages are absent', () => { | ||
| const error = { | ||
| graphQLErrors: [ | ||
| { | ||
| extensions: { | ||
| exception: { | ||
| errorObject: { | ||
| uploadUid: [{ code: 'launch.DEPLOYMENT.FILE_UPLOAD_FAILED' }], | ||
| }, | ||
| }, | ||
| }, | ||
| }, | ||
| ], | ||
| }; | ||
|
|
||
| expect(isLaunchDeploymentFileSizeRelatedError(error)).toBe(true); | ||
| }); | ||
| }); |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.