-
Notifications
You must be signed in to change notification settings - Fork 62
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Show alert before sending file that exceeds nginx limit
Closes getodk/central#178.
- Loading branch information
1 parent
cad1dd1
commit fbfb621
Showing
5 changed files
with
97 additions
and
14 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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
import TestUtilRequest from '../util/components/request.vue'; | ||
|
||
import { mockHttp } from '../util/http'; | ||
import { mount } from '../util/lifecycle'; | ||
|
||
describe('mixins/request', () => { | ||
describe('file size exceeds limit', () => { | ||
const largeFile = (name) => { | ||
const file = new File([''], name); | ||
// At least in Headless Chrome, `file` does not have its own `size` | ||
// property, but rather uses the Blob.prototype.size getter. | ||
Object.prototype.hasOwnProperty.call(file, 'size').should.be.false(); | ||
Object.defineProperty(file, 'size', { value: 100000001 }); | ||
return file; | ||
}; | ||
|
||
it('does not send a request', () => | ||
mockHttp() | ||
.mount(TestUtilRequest) | ||
.testNoRequest(component => { | ||
component.vm.post('/v1/projects/1/forms', largeFile('form.xml')); | ||
})); | ||
|
||
it('shows a danger alert', () => { | ||
const component = mount(TestUtilRequest); | ||
component.vm.post('/v1/projects/1/forms', largeFile('form.xml')); | ||
component.should.alert('danger', (message) => { | ||
message.should.containEql('form.xml'); | ||
}); | ||
}); | ||
|
||
it('returns a rejected promise', () => { | ||
const component = mount(TestUtilRequest); | ||
const result = component.vm.post( | ||
'/v1/projects/1/forms', | ||
largeFile('form.xml') | ||
); | ||
return result.should.be.rejected(); | ||
}); | ||
}); | ||
}); |
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,17 @@ | ||
<template> | ||
<div></div> | ||
</template> | ||
|
||
<script> | ||
import request from '../../../src/mixins/request'; | ||
export default { | ||
name: 'TestUtilRequest', | ||
mixins: [request()], | ||
data() { | ||
return { | ||
awaitingResponse: false | ||
}; | ||
} | ||
}; | ||
</script> |
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