Skip to content

Commit

Permalink
Merge pull request #1458 from nextcloud/feat/migrate-to-nextcloud-cyp…
Browse files Browse the repository at this point in the history
…ress

Migrate to @nextcloud/cypress
  • Loading branch information
skjnldsv authored Nov 11, 2022
2 parents d306e65 + f32c2b8 commit f9ca78e
Show file tree
Hide file tree
Showing 25 changed files with 248 additions and 322 deletions.
5 changes: 4 additions & 1 deletion cypress.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,15 @@ export default defineConfig({
trashAssetsBeforeRuns: true,

e2e: {
// Enable session management and disable isolation
experimentalSessionAndOrigin: true,
testIsolation: 'off',

// We've imported your old cypress plugins here.
// You may want to clean this up later by importing these.
async setupNodeEvents(on, config) {
// Fix browserslist extend https://github.com/cypress-io/cypress/issues/2983#issuecomment-570616682
on('file:preprocessor', browserify())
// on('file:preprocessor', webpackPreprocessor({ webpackOptions }))
getCompareSnapshotsPlugin(on, config)

// Disable spell checking to prevent rendering differences
Expand Down
2 changes: 1 addition & 1 deletion cypress/dockerNode.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,12 @@ import waitOn from 'wait-on'
import path from 'path'

export const docker = new Docker()
const CONTAINER_NAME = 'nextcloud-cypress-tests'

const pkg = require('../package.json');
const APP_PATH = path.resolve(__dirname, '../')
const APP_NAME = pkg.name

const CONTAINER_NAME = 'nextcloud-cypress-tests-' + APP_NAME
const SERVER_IMAGE = 'ghcr.io/nextcloud/continuous-integration-shallow-server'

/**
Expand Down
16 changes: 7 additions & 9 deletions cypress/e2e/actions/delete.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,25 +20,23 @@
*
*/

import { randHash } from '../../utils'
const randUser = randHash()

describe('Delete image.png in viewer', function() {
before(function() {
// Init user
cy.nextcloudCreateUser(randUser)
cy.createRandomUser().then(user => {
// Upload test files
cy.uploadFile(user, 'image.png', 'image/png')

// Upload test files
cy.uploadFile(randUser, 'image.png', 'image/png')
// Visit nextcloud
cy.login(user)
cy.visit('/apps/files')
})
})
after(function() {
cy.logout()
})

it('See image.png in the list', function() {
cy.login(randUser)
cy.visit('/apps/files')

cy.get('.files-fileList tr[data-file="image.png"]', { timeout: 10000 })
.should('contain', 'image.png')
})
Expand Down
15 changes: 7 additions & 8 deletions cypress/e2e/actions/download.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,29 +20,28 @@
*
*/

import { randHash } from '../../utils'
import * as path from 'path'

const randUser = randHash()
const fileName = 'image.png'

describe(`Download ${fileName} in viewer`, function() {
before(function() {
// Init user
cy.nextcloudCreateUser(randUser)
cy.createRandomUser().then(user => {
// Upload test files
cy.uploadFile(user, fileName, 'image/png')

// Upload test files
cy.uploadFile(randUser, fileName, 'image/png')
// Visit nextcloud
cy.login(user)
cy.visit('/apps/files')
})
})

after(function() {
cy.logout()
})

it(`See "${fileName}" in the list`, function() {
cy.login(randUser)
cy.visit('/apps/files')

cy.get(`.files-fileList tr[data-file="${fileName}"]`, { timeout: 10000 })
.should('contain', fileName)
})
Expand Down
24 changes: 11 additions & 13 deletions cypress/e2e/actions/sidebar.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,28 +21,26 @@
*
*/

import { randHash } from '../../utils'
const randUser = randHash()

describe('Open the sidebar from the viewer and open viewer with sidebar already opened', function() {
before(function() {
// Init user
cy.nextcloudCreateUser(randUser)

// Upload test files
cy.uploadFile(randUser, 'image1.jpg', 'image/jpeg')
cy.uploadFile(randUser, 'image2.jpg', 'image/jpeg')
cy.uploadFile(randUser, 'image3.jpg', 'image/jpeg')
cy.uploadFile(randUser, 'image4.jpg', 'image/jpeg')
cy.createRandomUser().then(user => {
// Upload test files
cy.uploadFile(user, 'image1.jpg', 'image/jpeg')
cy.uploadFile(user, 'image2.jpg', 'image/jpeg')
cy.uploadFile(user, 'image3.jpg', 'image/jpeg')
cy.uploadFile(user, 'image4.jpg', 'image/jpeg')

// Visit nextcloud
cy.login(user)
cy.visit('/apps/files')
})
})
after(function() {
cy.logout()
})

it('See images in the list', function() {
cy.login(randUser)
cy.visit('/apps/files')

cy.get('.files-fileList tr[data-file="image1.jpg"]', { timeout: 10000 })
.should('contain', 'image1.jpg')
cy.get('.files-fileList tr[data-file="image2.jpg"]', { timeout: 10000 })
Expand Down
26 changes: 14 additions & 12 deletions cypress/e2e/audios/audios.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,26 +20,28 @@
*
*/

import { randHash } from '../../utils'
const randUser = randHash()

describe('Open mp3 and ogg audio in viewer', function() {
let randUser

before(function() {
// Init user
cy.nextcloudCreateUser(randUser)
cy.createRandomUser().then(user => {
randUser = user

// Upload test file
cy.uploadFile(randUser, 'audio.mp3', 'audio/mpeg')
cy.uploadFile(randUser, 'audio.ogg', 'audio/ogg')
// Upload test files
cy.uploadFile(user, 'audio.mp3', 'audio/mpeg')
cy.uploadFile(user, 'audio.ogg', 'audio/ogg')

// Visit nextcloud
cy.login(user)
cy.visit('/apps/files')
})
})
after(function() {
cy.logout()
})

it('See audios in the list', function() {
cy.login(randUser)
cy.visit('/apps/files')

cy.get('.files-fileList tr[data-file="audio.mp3"]', { timeout: 10000 })
.should('contain', 'audio.mp3')
cy.get('.files-fileList tr[data-file="audio.ogg"]', { timeout: 10000 })
Expand All @@ -66,7 +68,7 @@ describe('Open mp3 and ogg audio in viewer', function() {
it('The audio source is the remote url', function() {
cy.get('body > .viewer .modal-container .viewer__file.viewer__file--active audio')
.should('have.attr', 'src')
.and('contain', `/remote.php/dav/files/${randUser}/audio.mp3`)
.and('contain', `/remote.php/dav/files/${randUser.userId}/audio.mp3`)
})

it('Does not see a loading animation', function() {
Expand All @@ -86,7 +88,7 @@ describe('Open mp3 and ogg audio in viewer', function() {
it('The audio source is the remote url', function() {
cy.get('body > .viewer .modal-container .viewer__file.viewer__file--active audio')
.should('have.attr', 'src')
.and('contain', `/remote.php/dav/files/${randUser}/audio.ogg`)
.and('contain', `/remote.php/dav/files/${randUser.userId}/audio.ogg`)
})

it('Does not see a loading animation', function() {
Expand Down
9 changes: 6 additions & 3 deletions cypress/e2e/files.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,18 +20,21 @@
*
*/

import { User } from '@nextcloud/cypress'

describe('Files default view', function() {
const user = new User('admin', 'admin')

before(function() {
cy.login('admin', 'admin')
cy.login(user)
})

after(function() {
cy.logout()
})

it('See the default files list', function() {
cy.login('admin', 'admin')
cy.visit('/apps/files')

cy.get('.files-fileList tr').should('contain', 'welcome.txt')
})

Expand Down
24 changes: 11 additions & 13 deletions cypress/e2e/images/images-custom-list-loadmore.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,28 +20,26 @@
*
*/

import { randHash } from '../../utils'
const randUser = randHash()

describe('Open custom list of images in viewer with pagination', function() {
before(function() {
// Init user
cy.nextcloudCreateUser(randUser)

// Upload test files
cy.uploadFile(randUser, 'image1.jpg', 'image/jpeg')
cy.uploadFile(randUser, 'image2.jpg', 'image/jpeg')
cy.uploadFile(randUser, 'image3.jpg', 'image/jpeg')
cy.uploadFile(randUser, 'image4.jpg', 'image/jpeg')
cy.createRandomUser().then(user => {
// Upload test files
cy.uploadFile(user, 'image1.jpg', 'image/jpeg')
cy.uploadFile(user, 'image2.jpg', 'image/jpeg')
cy.uploadFile(user, 'image3.jpg', 'image/jpeg')
cy.uploadFile(user, 'image4.jpg', 'image/jpeg')

// Visit nextcloud
cy.login(user)
cy.visit('/apps/files')
})
})
after(function() {
cy.logout()
})

it('See images in the list', function() {
cy.login(randUser)
cy.visit('/apps/files')

cy.get('.files-fileList tr[data-file="image1.jpg"]', { timeout: 10000 })
.should('contain', 'image1.jpg')
cy.get('.files-fileList tr[data-file="image2.jpg"]', { timeout: 10000 })
Expand Down
24 changes: 11 additions & 13 deletions cypress/e2e/images/images-custom-list.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,28 +20,26 @@
*
*/

import { randHash } from '../../utils'
const randUser = randHash()

describe('Open custom images list in viewer', function() {
before(function() {
// Init user
cy.nextcloudCreateUser(randUser)

// Upload test files
cy.uploadFile(randUser, 'image1.jpg', 'image/jpeg')
cy.uploadFile(randUser, 'image2.jpg', 'image/jpeg')
cy.uploadFile(randUser, 'image3.jpg', 'image/jpeg')
cy.uploadFile(randUser, 'image4.jpg', 'image/jpeg')
cy.createRandomUser().then(user => {
// Upload test files
cy.uploadFile(user, 'image1.jpg', 'image/jpeg')
cy.uploadFile(user, 'image2.jpg', 'image/jpeg')
cy.uploadFile(user, 'image3.jpg', 'image/jpeg')
cy.uploadFile(user, 'image4.jpg', 'image/jpeg')

// Visit nextcloud
cy.login(user)
cy.visit('/apps/files')
})
})
after(function() {
cy.logout()
})

it('See images in the list', function() {
cy.login(randUser)
cy.visit('/apps/files')

cy.get('.files-fileList tr[data-file="image1.jpg"]', { timeout: 10000 })
.should('contain', 'image1.jpg')
cy.get('.files-fileList tr[data-file="image2.jpg"]', { timeout: 10000 })
Expand Down
24 changes: 11 additions & 13 deletions cypress/e2e/images/images.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,28 +20,26 @@
*
*/

import { randHash } from '../../utils'
const randUser = randHash()

describe('Open images in viewer', function() {
before(function() {
// Init user
cy.nextcloudCreateUser(randUser)

// Upload test files
cy.uploadFile(randUser, 'image1.jpg', 'image/jpeg')
cy.uploadFile(randUser, 'image2.jpg', 'image/jpeg')
cy.uploadFile(randUser, 'image3.jpg', 'image/jpeg')
cy.uploadFile(randUser, 'image4.jpg', 'image/jpeg')
cy.createRandomUser().then(user => {
// Upload test files
cy.uploadFile(user, 'image1.jpg', 'image/jpeg')
cy.uploadFile(user, 'image2.jpg', 'image/jpeg')
cy.uploadFile(user, 'image3.jpg', 'image/jpeg')
cy.uploadFile(user, 'image4.jpg', 'image/jpeg')

// Visit nextcloud
cy.login(user)
cy.visit('/apps/files')
})
})
after(function() {
cy.logout()
})

it('See images in the list', function() {
cy.login(randUser)
cy.visit('/apps/files')

cy.get('.files-fileList tr[data-file="image1.jpg"]', { timeout: 10000 })
.should('contain', 'image1.jpg')
cy.get('.files-fileList tr[data-file="image2.jpg"]', { timeout: 10000 })
Expand Down
22 changes: 12 additions & 10 deletions cypress/e2e/mixins/audio.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,31 +20,33 @@
*
*/

import { randHash } from '../../utils'
const randUser = randHash()

/**
* Generate an audio cypress test
*
* @param {string} fileName the audio to upload and test against
* @param {string} mimeType the audio mime type
*/
export default function(fileName = 'image1.jpg', mimeType = 'image/jpeg') {
let randUser

before(function() {
// Init user
cy.nextcloudCreateUser(randUser)
cy.createRandomUser().then(user => {
randUser = user

// Upload test files
cy.uploadFile(randUser, fileName, mimeType)
// Upload test files
cy.uploadFile(user, fileName, mimeType)

// Visit nextcloud
cy.login(user)
cy.visit('/apps/files')
})
})
after(function() {
cy.logout()
})

it(`See ${fileName} in the list`, function() {
cy.login(randUser)
cy.visit('/apps/files')

cy.get(`.files-fileList tr[data-file="${fileName}"]`, { timeout: 10000 })
.should('contain', fileName)
})
Expand Down Expand Up @@ -75,6 +77,6 @@ export default function(fileName = 'image1.jpg', mimeType = 'image/jpeg') {
it('The audio source is the remote url', function() {
cy.get('body > .viewer .modal-container .viewer__file.viewer__file--active audio')
.should('have.attr', 'src')
.and('contain', `/remote.php/dav/files/${randUser}/${fileName}`)
.and('contain', `/remote.php/dav/files/${randUser.userId}/${fileName}`)
})
}
Loading

0 comments on commit f9ca78e

Please sign in to comment.