Skip to content

Commit

Permalink
Use axios instead of @nc/axios in e2e tests
Browse files Browse the repository at this point in the history
Signed-off-by: Louis Chemineau <[email protected]>
  • Loading branch information
artonge committed Jan 29, 2024
1 parent e53d598 commit 44bb82f
Showing 1 changed file with 27 additions and 27 deletions.
54 changes: 27 additions & 27 deletions cypress/support/commands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
*
*/
/* eslint-disable n/no-unpublished-import */
import axios from '@nextcloud/axios'
import axios from 'axios'
import { addCommands, User } from '@nextcloud/cypress'
import { basename } from 'path'

Expand Down Expand Up @@ -85,33 +85,33 @@ 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)
.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 => {
cy.log(`Uploaded content as ${fileName}`, response)
})
} catch (error) {
cy.log('error', error)
throw new Error(`Unable to process fixture`)
}
})
// 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 => {
cy.log(`Uploaded content as ${fileName}`, response)
})
} catch (error) {
cy.log('error', error)
throw new Error('Unable to process fixture')
}
})
})

Cypress.Commands.add('runOccCommand', (command: string) => {
Expand Down

0 comments on commit 44bb82f

Please sign in to comment.