-
Notifications
You must be signed in to change notification settings - Fork 81
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' into feat/dcl-and-ens-worlds-views
- Loading branch information
Showing
6 changed files
with
68 additions
and
5 deletions.
There are no files selected for viewing
This file contains 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
28 changes: 28 additions & 0 deletions
28
src/components/Modals/DeployModal/DeployToWorld_WorldsForEnsOwnersFeature/utils.spec.ts
This file contains 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,28 @@ | ||
import { getSizesFromDeploymentError } from './utils' | ||
|
||
describe('when getting the sizes from the deployment error', () => { | ||
let error: string | ||
|
||
describe('when the error is not the expected one', () => { | ||
beforeEach(() => { | ||
error = 'invalid' | ||
}) | ||
|
||
it('should return null', () => { | ||
expect(getSizesFromDeploymentError(error)).toBeNull() | ||
}) | ||
}) | ||
|
||
describe('when the error is the expected one', () => { | ||
beforeEach(() => { | ||
error = `Failed to fetch https://worlds-content-server.decentraland.org/entities. Got status 400. Response was '{"error":"Bad request","message":"Deployment failed: The deployment is too big. The maximum total size allowed is 25 MB for scenes. You can upload up to 26214400 bytes but you tried to upload 37528367."}'` | ||
}) | ||
|
||
it('should return an object with the deployed and max sizes in mbs', () => { | ||
expect(getSizesFromDeploymentError(error)).toEqual({ | ||
deployedSizedMbs: '36', | ||
maxSizeMbs: '25' | ||
}) | ||
}) | ||
}) | ||
}) |
15 changes: 15 additions & 0 deletions
15
src/components/Modals/DeployModal/DeployToWorld_WorldsForEnsOwnersFeature/utils.ts
This file contains 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,15 @@ | ||
export const getSizesFromDeploymentError = (error: string) => { | ||
const pattern = /.*You can upload up to (\d+) bytes but you tried to upload (\d+).*/ | ||
|
||
// eslint-disable-next-line | ||
const match = error.match(pattern) | ||
|
||
if (match?.length !== 3) { | ||
return null | ||
} | ||
|
||
return { | ||
maxSizeMbs: (Number(match[1]) / 1024 / 1024).toFixed(), | ||
deployedSizedMbs: (Number(match[2]) / 1024 / 1024).toFixed() | ||
} | ||
} |
This file contains 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 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 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