|
19 | 19 | */ |
20 | 20 |
|
21 | 21 | import type { User } from '@nextcloud/cypress' |
| 22 | +import axios from 'axios' |
22 | 23 |
|
23 | | -export function uploadTestMedia(user: User) { |
| 24 | +export function uploadTestMedia(user: User, destination = '/Photos') { |
24 | 25 | cy.exec('ls cypress/fixtures/media') |
25 | 26 | .then((result) => { |
26 | 27 | for (const fileName of result.stdout.split('\n')) { |
27 | | - cy.uploadFile(user, `media/${fileName}`, 'image/png', `/${fileName}`) |
| 28 | + cy.uploadFile(user, `media/${fileName}`, 'image/png', `/${destination}/${fileName}`) |
28 | 29 | } |
29 | 30 | }) |
30 | 31 | } |
@@ -72,3 +73,26 @@ export function deleteSelection() { |
72 | 73 | .click() |
73 | 74 | .wait('@deleteRequests') |
74 | 75 | } |
| 76 | + |
| 77 | +export function mkdir(user: User, target: string) { |
| 78 | + // eslint-disable-next-line cypress/unsafe-to-chain-command |
| 79 | + cy.clearCookies() |
| 80 | + .then({ timeout: 8000 }, async () => { |
| 81 | + try { |
| 82 | + const rootPath = `${Cypress.env('baseUrl')}/remote.php/dav/files/${encodeURIComponent(user.userId)}` |
| 83 | + const filePath = target.split('/').map(encodeURIComponent).join('/') |
| 84 | + const response = await axios({ |
| 85 | + url: `${rootPath}${filePath}`, |
| 86 | + method: 'MKCOL', |
| 87 | + auth: { |
| 88 | + username: user.userId, |
| 89 | + password: user.password, |
| 90 | + }, |
| 91 | + }) |
| 92 | + cy.log(`Created directory ${target}`, response) |
| 93 | + } catch (error) { |
| 94 | + cy.log('error', error) |
| 95 | + throw new Error('Unable to process fixture') |
| 96 | + } |
| 97 | + }) |
| 98 | +} |
0 commit comments