Skip to content

Commit

Permalink
Adjust testing
Browse files Browse the repository at this point in the history
Signed-off-by: John Molakvoæ <skjnldsv@protonmail.com>
Signed-off-by: nextcloud-command <nextcloud-command@users.noreply.github.com>
  • Loading branch information
skjnldsv committed Nov 18, 2022
1 parent 5687f7e commit efbdc88
Show file tree
Hide file tree
Showing 7 changed files with 44 additions and 25 deletions.
14 changes: 9 additions & 5 deletions cypress/e2e/mixins/audio.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
*
*/

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

/**
Expand All @@ -29,7 +29,7 @@ const randUser = randHash()
* @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') {
export default function(fileName = 'audio.ogg', mimeType = 'audio/ogg') {
before(function() {
// Init user
cy.nextcloudCreateUser(randUser)
Expand All @@ -49,12 +49,16 @@ export default function(fileName = 'image1.jpg', mimeType = 'image/jpeg') {
.should('contain', fileName)
})

it('Open the viewer on file click', function() {
it('Open the viewer on file click and wait for loading to end', function() {
// Match audio request
cy.intercept('GET', `/remote.php/dav/files/${randUser.userId}/${fileName}`).as('source')

// Open the file and check Viewer existence
cy.openFile(fileName)
cy.get('body > .viewer').should('be.visible')
})

it('Does not see a loading animation', function() {
// Make sure loading is finished
cy.wait('@source').its('response.statusCode').should('eq', 206)
cy.get('body > .viewer', { timeout: 10000 })
.should('be.visible')
.and('have.class', 'modal-mask')
Expand Down
19 changes: 15 additions & 4 deletions cypress/e2e/mixins/image.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ const randUser = randHash()
* @param {string} source the optional custom source to check against
*/
export default function(fileName = 'image1.jpg', mimeType = 'image/jpeg', source = null) {
let fileId
before(function() {
// Init user
cy.nextcloudCreateUser(randUser)
Expand All @@ -48,14 +49,24 @@ export default function(fileName = 'image1.jpg', mimeType = 'image/jpeg', source

cy.get(`.files-fileList tr[data-file="${fileName}"]`, { timeout: 10000 })
.should('contain', fileName)
.then(row => {
fileId = row[0].dataset.id
})
})

it('Open the viewer on file click', function() {
it('Open the viewer on file click and wait for loading to end', function() {
// Match image request
const matchRoute = source
? `/remote.php/dav/files/*/${fileName}`
: `/index.php/core/preview*fileId=${fileId}*`
cy.intercept('GET', matchRoute).as('image')

// Open the file and check Viewer existence
cy.openFile(fileName)
cy.get('body > .viewer').should('be.visible')
})

it('Does not see a loading animation', function() {
// Make sure loading is finished
cy.wait('@image').its('response.statusCode').should('eq', 200)
cy.get('body > .viewer', { timeout: 10000 })
.should('be.visible')
.and('have.class', 'modal-mask')
Expand All @@ -73,7 +84,7 @@ export default function(fileName = 'image1.jpg', mimeType = 'image/jpeg', source
cy.get('body > .viewer button.next').should('not.be.visible')
})

it('The image source is the preview url', function() {
it(`The image source is the ${source ? 'remote' : 'preview'} url`, function() {
cy.get('body > .viewer .modal-container img.viewer__file.viewer__file--active')
.should('have.attr', 'src')
.and('contain', source ?? '/index.php/core/preview')
Expand Down
14 changes: 9 additions & 5 deletions cypress/e2e/mixins/video.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
*
*/

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

/**
Expand All @@ -29,7 +29,7 @@ const randUser = randHash()
* @param {string} fileName the video to upload and test against
* @param {string} mimeType the video mime type
*/
export default function(fileName = 'image1.jpg', mimeType = 'image/jpeg') {
export default function(fileName = 'video1.mp4', mimeType = 'video/mp4') {
before(function() {
// Init user
cy.nextcloudCreateUser(randUser)
Expand All @@ -49,12 +49,16 @@ export default function(fileName = 'image1.jpg', mimeType = 'image/jpeg') {
.should('contain', fileName)
})

it('Open the viewer on file click', function() {
it('Open the viewer on file click and wait for loading to end', function() {
// Match audio request
cy.intercept('GET', `/remote.php/dav/files/${randUser.userId}/${fileName}`).as('source')

// Open the file and check Viewer existence
cy.openFile(fileName)
cy.get('body > .viewer').should('be.visible')
})

it('Does not see a loading animation', function() {
// Make sure loading is finished
cy.wait('@source').its('response.statusCode').should('eq', 206)
cy.get('body > .viewer', { timeout: 10000 })
.should('be.visible')
.and('have.class', 'modal-mask')
Expand Down
4 changes: 2 additions & 2 deletions js/viewer-main.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion js/viewer-main.js.map

Large diffs are not rendered by default.

14 changes: 7 additions & 7 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@
"@types/dockerode": "^3.3.12",
"@vue/tsconfig": "^0.1.3",
"babel-loader-exclude-node-modules-except": "^1.2.1",
"cypress": "^10.10.0",
"cypress": "^11.1.0",
"cypress-visual-regression": "^1.7.0",
"dockerode": "^3.3.4",
"eslint-plugin-cypress": "^2.12.1",
Expand Down

0 comments on commit efbdc88

Please sign in to comment.