diff options
Diffstat (limited to 'cypress/support/commands.ts')
-rw-r--r-- | cypress/support/commands.ts | 51 |
1 files changed, 25 insertions, 26 deletions
diff --git a/cypress/support/commands.ts b/cypress/support/commands.ts index d214bb2b45e..1a9999343d5 100644 --- a/cypress/support/commands.ts +++ b/cypress/support/commands.ts @@ -99,33 +99,32 @@ Cypress.Commands.add('uploadFile', (user, fixture = 'image.jpg', mimeType = 'ima */ Cypress.Commands.add('uploadContent', (user, blob, mimeType, target) => { cy.clearCookies() - .then(async () => { - const fileName = basename(target) - - // Process paths - const rootPath = `${Cypress.env('baseUrl')}/remote.php/dav/files/${encodeURIComponent(user.userId)}` - const filePath = target.split('/').map(encodeURIComponent).join('/') - try { - const file = new File([blob], fileName, { type: mimeType }) - await axios({ - url: `${rootPath}${filePath}`, - method: 'PUT', - data: file, - headers: { - 'Content-Type': mimeType, - }, - auth: { - username: user.userId, - password: user.password, - }, - }).then(response => { + .then(async () => { + const fileName = basename(target) + + // Process paths + const rootPath = `${Cypress.env('baseUrl')}/remote.php/dav/files/${encodeURIComponent(user.userId)}` + const filePath = target.split('/').map(encodeURIComponent).join('/') + try { + const file = new File([blob], fileName, { type: mimeType }) + const response = await axios({ + url: `${rootPath}${filePath}`, + method: 'PUT', + data: file, + headers: { + 'Content-Type': mimeType, + }, + auth: { + username: user.userId, + password: user.password, + }, + }) cy.log(`Uploaded content as ${fileName}`, response) - }) - } catch (error) { - cy.log('error', error) - throw new Error(`Unable to process fixture`) - } - }) + } catch (error) { + cy.log('error', error) + throw new Error('Unable to process fixture') + } + }) }) /** |