From 44bb82fca9aaf70b65db5b01a1c690d835728afc Mon Sep 17 00:00:00 2001 From: Louis Chemineau Date: Mon, 29 Jan 2024 18:13:37 +0100 Subject: [PATCH] Use axios instead of @nc/axios in e2e tests Signed-off-by: Louis Chemineau --- cypress/support/commands.ts | 54 ++++++++++++++++++------------------- 1 file changed, 27 insertions(+), 27 deletions(-) diff --git a/cypress/support/commands.ts b/cypress/support/commands.ts index dfc5196eb..c92442ae6 100644 --- a/cypress/support/commands.ts +++ b/cypress/support/commands.ts @@ -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' @@ -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) => {