Skip to content

Commit efbdc88

Browse files
committed
Adjust testing
Signed-off-by: John Molakvoæ <skjnldsv@protonmail.com> Signed-off-by: nextcloud-command <nextcloud-command@users.noreply.github.com>
1 parent 5687f7e commit efbdc88

File tree

7 files changed

+44
-25
lines changed

7 files changed

+44
-25
lines changed

cypress/e2e/mixins/audio.js

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
*
2121
*/
2222

23-
import { randHash } from '../../utils'
23+
import { randHash } from '../../utils/index.js'
2424
const randUser = randHash()
2525

2626
/**
@@ -29,7 +29,7 @@ const randUser = randHash()
2929
* @param {string} fileName the audio to upload and test against
3030
* @param {string} mimeType the audio mime type
3131
*/
32-
export default function(fileName = 'image1.jpg', mimeType = 'image/jpeg') {
32+
export default function(fileName = 'audio.ogg', mimeType = 'audio/ogg') {
3333
before(function() {
3434
// Init user
3535
cy.nextcloudCreateUser(randUser)
@@ -49,12 +49,16 @@ export default function(fileName = 'image1.jpg', mimeType = 'image/jpeg') {
4949
.should('contain', fileName)
5050
})
5151

52-
it('Open the viewer on file click', function() {
52+
it('Open the viewer on file click and wait for loading to end', function() {
53+
// Match audio request
54+
cy.intercept('GET', `/remote.php/dav/files/${randUser.userId}/${fileName}`).as('source')
55+
56+
// Open the file and check Viewer existence
5357
cy.openFile(fileName)
5458
cy.get('body > .viewer').should('be.visible')
55-
})
5659

57-
it('Does not see a loading animation', function() {
60+
// Make sure loading is finished
61+
cy.wait('@source').its('response.statusCode').should('eq', 206)
5862
cy.get('body > .viewer', { timeout: 10000 })
5963
.should('be.visible')
6064
.and('have.class', 'modal-mask')

cypress/e2e/mixins/image.js

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ const randUser = randHash()
3131
* @param {string} source the optional custom source to check against
3232
*/
3333
export default function(fileName = 'image1.jpg', mimeType = 'image/jpeg', source = null) {
34+
let fileId
3435
before(function() {
3536
// Init user
3637
cy.nextcloudCreateUser(randUser)
@@ -48,14 +49,24 @@ export default function(fileName = 'image1.jpg', mimeType = 'image/jpeg', source
4849

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

53-
it('Open the viewer on file click', function() {
57+
it('Open the viewer on file click and wait for loading to end', function() {
58+
// Match image request
59+
const matchRoute = source
60+
? `/remote.php/dav/files/*/${fileName}`
61+
: `/index.php/core/preview*fileId=${fileId}*`
62+
cy.intercept('GET', matchRoute).as('image')
63+
64+
// Open the file and check Viewer existence
5465
cy.openFile(fileName)
5566
cy.get('body > .viewer').should('be.visible')
56-
})
5767

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

76-
it('The image source is the preview url', function() {
87+
it(`The image source is the ${source ? 'remote' : 'preview'} url`, function() {
7788
cy.get('body > .viewer .modal-container img.viewer__file.viewer__file--active')
7889
.should('have.attr', 'src')
7990
.and('contain', source ?? '/index.php/core/preview')

cypress/e2e/mixins/video.js

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
*
2121
*/
2222

23-
import { randHash } from '../../utils'
23+
import { randHash } from '../../utils/index.js'
2424
const randUser = randHash()
2525

2626
/**
@@ -29,7 +29,7 @@ const randUser = randHash()
2929
* @param {string} fileName the video to upload and test against
3030
* @param {string} mimeType the video mime type
3131
*/
32-
export default function(fileName = 'image1.jpg', mimeType = 'image/jpeg') {
32+
export default function(fileName = 'video1.mp4', mimeType = 'video/mp4') {
3333
before(function() {
3434
// Init user
3535
cy.nextcloudCreateUser(randUser)
@@ -49,12 +49,16 @@ export default function(fileName = 'image1.jpg', mimeType = 'image/jpeg') {
4949
.should('contain', fileName)
5050
})
5151

52-
it('Open the viewer on file click', function() {
52+
it('Open the viewer on file click and wait for loading to end', function() {
53+
// Match audio request
54+
cy.intercept('GET', `/remote.php/dav/files/${randUser.userId}/${fileName}`).as('source')
55+
56+
// Open the file and check Viewer existence
5357
cy.openFile(fileName)
5458
cy.get('body > .viewer').should('be.visible')
55-
})
5659

57-
it('Does not see a loading animation', function() {
60+
// Make sure loading is finished
61+
cy.wait('@source').its('response.statusCode').should('eq', 206)
5862
cy.get('body > .viewer', { timeout: 10000 })
5963
.should('be.visible')
6064
.and('have.class', 'modal-mask')

js/viewer-main.js

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

js/viewer-main.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package-lock.json

Lines changed: 7 additions & 7 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@
7878
"@types/dockerode": "^3.3.12",
7979
"@vue/tsconfig": "^0.1.3",
8080
"babel-loader-exclude-node-modules-except": "^1.2.1",
81-
"cypress": "^10.10.0",
81+
"cypress": "^11.1.0",
8282
"cypress-visual-regression": "^1.7.0",
8383
"dockerode": "^3.3.4",
8484
"eslint-plugin-cypress": "^2.12.1",

0 commit comments

Comments
 (0)