Set category when creating button & icon files

closes MAT-631
flag=rce_buttons_and_icons

Test Plan:
- Create a button and icon and observe the network
  requests being made for the file upload
- Verify a category: "buttons_and_icons" param
  is sent in the post request to the
  "http://rce.canvas.docker/api/upload" endpoint

Change-Id: I21ee4d7af00f6b8642c44c4388497df62759674b
Reviewed-on: https://gerrit.instructure.com/c/canvas-lms/+/283594
Tested-by: Service Cloud Jenkins <svc.cloudjenkins@instructure.com>
Reviewed-by: Joe Hernandez <joe.hernandez@instructure.com>
QA-Review: Joe Hernandez <joe.hernandez@instructure.com>
Product-Review: Weston Dransfield <wdransfield@instructure.com>
This commit is contained in:
Weston Dransfield 2022-01-25 15:56:06 -07:00
parent 23c4ef7fe6
commit 2af540b641
4 changed files with 23 additions and 3 deletions

View File

@ -365,7 +365,8 @@ class RceApiSource {
contextType: apiProps.contextType,
file: fileProps,
no_redirect: true,
onDuplicate: apiProps.onDuplicate
onDuplicate: apiProps.onDuplicate,
category: apiProps.category
}
return this.apiPost(uri, headers, body)

View File

@ -266,7 +266,13 @@ export function uploadToButtonsAndIconsFolder(svg, uploadSettings = {}) {
.then(({folders}) => {
fileMetaProps.parentFolderId = folders[0].id
return source
.preflightUpload(fileMetaProps, {host, contextId, contextType, onDuplicate})
.preflightUpload(fileMetaProps, {
host,
contextId,
contextType,
onDuplicate,
category: 'buttons_and_icons'
})
.then(results => {
return source.uploadFRD(svgAsFile, results)
})

View File

@ -564,6 +564,17 @@ describe('sources/api', () => {
})
})
it('includes "category"', () => {
fetchMock.mock(uri, '{}')
return apiSource
.preflightUpload(fileProps, {category: 'buttons_and_icons'}, apiProps)
.then(() => {
const body = JSON.parse(fetchMock.lastOptions(uri).body)
assert.equal(body.category, 'buttons_and_icons')
})
})
it('includes jwt in Authorization header', () => {
fetchMock.mock(uri, '{}')

View File

@ -230,7 +230,8 @@ describe('Upload data actions', () => {
host: 'http://host:port',
contextId: 101,
contextType: 'course',
onDuplicate: undefined
onDuplicate: undefined,
category: 'buttons_and_icons'
}
return store.dispatch(actions.uploadToButtonsAndIconsFolder(svg)).then(() => {
@ -273,6 +274,7 @@ describe('Upload data actions', () => {
parentFolderId: 2
},
{
category: 'buttons_and_icons',
contextId: 101,
contextType: 'course',
host: 'http://host:port',