Skip to content

Commit 4e1f39d

Browse files
committed
Update cypress test suite
Signed-off-by: John Molakvoæ <skjnldsv@protonmail.com>
1 parent 19bc525 commit 4e1f39d

32 files changed

+413
-344
lines changed

cypress.config.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,11 @@ export default defineConfig({
1313
viewportHeight: 720,
1414

1515
// Tries again 2 more times on failure
16-
retries: 2,
16+
retries: {
17+
runMode: 2,
18+
// do not retry in `cypress open`
19+
openMode: 0,
20+
},
1721

1822
// Needed to trigger `after:run` events with cypress open
1923
experimentalInteractiveRunEvents: true,

cypress/e2e/delete.cy.js renamed to cypress/e2e/actions/delete.cy.js

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -20,27 +20,25 @@
2020
*
2121
*/
2222

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

2626
describe('Delete image.png in viewer', function() {
2727
before(function() {
2828
// Init user
29-
cy.nextcloudCreateUser(randUser, 'password')
30-
cy.login(randUser, 'password')
29+
cy.nextcloudCreateUser(randUser)
3130

3231
// Upload test files
33-
cy.uploadFile('image.png', 'image/png')
34-
cy.visit('/apps/files')
35-
36-
// wait a bit for things to be settled
37-
cy.wait(1000)
32+
cy.uploadFile(randUser, 'image.png', 'image/png')
3833
})
3934
after(function() {
4035
cy.logout()
4136
})
4237

4338
it('See image.png in the list', function() {
39+
cy.login(randUser)
40+
cy.visit('/apps/files')
41+
4442
cy.get('.files-fileList tr[data-file="image.png"]', { timeout: 10000 })
4543
.should('contain', 'image.png')
4644
})

cypress/e2e/download.cy.js renamed to cypress/e2e/actions/download.cy.js

Lines changed: 6 additions & 8 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'
2424
import * as path from 'path'
2525

2626
const randUser = randHash()
@@ -29,22 +29,20 @@ const fileName = 'image.png'
2929
describe(`Download ${fileName} in viewer`, function() {
3030
before(function() {
3131
// Init user
32-
cy.nextcloudCreateUser(randUser, 'password')
33-
cy.login(randUser, 'password')
32+
cy.nextcloudCreateUser(randUser)
3433

3534
// Upload test files
36-
cy.uploadFile(fileName, 'image/png')
37-
cy.visit('/apps/files')
38-
39-
// wait a bit for things to be settled
40-
cy.wait(1000)
35+
cy.uploadFile(randUser, fileName, 'image/png')
4136
})
4237

4338
after(function() {
4439
cy.logout()
4540
})
4641

4742
it(`See "${fileName}" in the list`, function() {
43+
cy.login(randUser)
44+
cy.visit('/apps/files')
45+
4846
cy.get(`.files-fileList tr[data-file="${fileName}"]`, { timeout: 10000 })
4947
.should('contain', fileName)
5048
})

cypress/e2e/sidebar.cy.js renamed to cypress/e2e/actions/sidebar.cy.js

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -21,30 +21,28 @@
2121
*
2222
*/
2323

24-
import { randHash } from '../utils/'
24+
import { randHash } from '../../utils'
2525
const randUser = randHash()
2626

2727
describe('Open the sidebar from the viewer and open viewer with sidebar already opened', function() {
2828
before(function() {
2929
// Init user
30-
cy.nextcloudCreateUser(randUser, 'password')
31-
cy.login(randUser, 'password')
30+
cy.nextcloudCreateUser(randUser)
3231

3332
// Upload test files
34-
cy.uploadFile('image1.jpg', 'image/jpeg')
35-
cy.uploadFile('image2.jpg', 'image/jpeg')
36-
cy.uploadFile('image3.jpg', 'image/jpeg')
37-
cy.uploadFile('image4.jpg', 'image/jpeg')
38-
cy.visit('/apps/files')
39-
40-
// wait a bit for things to be settled
41-
cy.wait(1000)
33+
cy.uploadFile(randUser, 'image1.jpg', 'image/jpeg')
34+
cy.uploadFile(randUser, 'image2.jpg', 'image/jpeg')
35+
cy.uploadFile(randUser, 'image3.jpg', 'image/jpeg')
36+
cy.uploadFile(randUser, 'image4.jpg', 'image/jpeg')
4237
})
4338
after(function() {
4439
cy.logout()
4540
})
4641

4742
it('See images in the list', function() {
43+
cy.login(randUser)
44+
cy.visit('/apps/files')
45+
4846
cy.get('.files-fileList tr[data-file="image1.jpg"]', { timeout: 10000 })
4947
.should('contain', 'image1.jpg')
5048
cy.get('.files-fileList tr[data-file="image2.jpg"]', { timeout: 10000 })

cypress/e2e/audio.mpeg.cy.js renamed to cypress/e2e/audios/audio.mpeg.cy.js

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -20,27 +20,25 @@
2020
*
2121
*/
2222

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

2626
describe('Open audio.mp3 in viewer', function() {
2727
before(function() {
2828
// Init user
29-
cy.nextcloudCreateUser(randUser, 'password')
30-
cy.login(randUser, 'password')
29+
cy.nextcloudCreateUser(randUser)
3130

3231
// Upload test files
33-
cy.uploadFile('audio.mp3', 'audio/mpeg')
34-
cy.visit('/apps/files')
35-
36-
// wait a bit for things to be settled
37-
cy.wait(1000)
32+
cy.uploadFile(randUser, 'audio.mp3', 'audio/mpeg')
3833
})
3934
after(function() {
4035
cy.logout()
4136
})
4237

4338
it('See audio.mp3 in the list', function() {
39+
cy.login(randUser)
40+
cy.visit('/apps/files')
41+
4442
cy.get('.files-fileList tr[data-file="audio.mp3"]', { timeout: 10000 })
4543
.should('contain', 'audio.mp3')
4644
})
@@ -68,9 +66,9 @@ describe('Open audio.mp3 in viewer', function() {
6866
cy.get('body > .viewer button.next').should('not.be.visible')
6967
})
7068

71-
it('Take screenshot', function() {
72-
// video are impossible to match with existing screenshot
73-
// just taking a screenshot to manually compare if needed
74-
cy.screenshot()
69+
it('The audio source is the remote url', function() {
70+
cy.get('body > .viewer .modal-container .viewer__file.viewer__file--active audio')
71+
.should('have.attr', 'src')
72+
.and('contain', `/remote.php/dav/files/${randUser}/audio.mp3`)
7573
})
7674
})

cypress/e2e/audio.ogg.cy.js renamed to cypress/e2e/audios/audio.ogg.cy.js

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -20,27 +20,25 @@
2020
*
2121
*/
2222

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

2626
describe('Open audio.ogg in viewer', function() {
2727
before(function() {
2828
// Init user
29-
cy.nextcloudCreateUser(randUser, 'password')
30-
cy.login(randUser, 'password')
29+
cy.nextcloudCreateUser(randUser)
3130

3231
// Upload test files
33-
cy.uploadFile('audio.ogg', 'audio/mpeg')
34-
cy.visit('/apps/files')
35-
36-
// wait a bit for things to be settled
37-
cy.wait(1000)
32+
cy.uploadFile(randUser, 'audio.ogg', 'audio/mpeg')
3833
})
3934
after(function() {
4035
cy.logout()
4136
})
4237

4338
it('See audio.ogg in the list', function() {
39+
cy.login(randUser)
40+
cy.visit('/apps/files')
41+
4442
cy.get('.files-fileList tr[data-file="audio.ogg"]', { timeout: 10000 })
4543
.should('contain', 'audio.ogg')
4644
})
@@ -68,9 +66,9 @@ describe('Open audio.ogg in viewer', function() {
6866
cy.get('body > .viewer button.next').should('not.be.visible')
6967
})
7068

71-
it('Take screenshot', function() {
72-
// video are impossible to match with existing screenshot
73-
// just taking a screenshot to manually compare if needed
74-
cy.screenshot()
69+
it('The audio source is the remote url', function() {
70+
cy.get('body > .viewer .modal-container .viewer__file.viewer__file--active audio')
71+
.should('have.attr', 'src')
72+
.and('contain', `/remote.php/dav/files/${randUser}/audio.ogg`)
7573
})
7674
})

cypress/e2e/audios.cy.js renamed to cypress/e2e/audios/audios.cy.js

Lines changed: 17 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -20,28 +20,26 @@
2020
*
2121
*/
2222

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

2626
describe('Open mp3 and ogg audio in viewer', function() {
2727
before(function() {
2828
// Init user
29-
cy.nextcloudCreateUser(randUser, 'password')
30-
cy.login(randUser, 'password')
29+
cy.nextcloudCreateUser(randUser)
3130

3231
// Upload test file
33-
cy.uploadFile('audio.mp3', 'audio/mpeg')
34-
cy.uploadFile('audio.ogg', 'audio/ogg')
35-
cy.visit('/apps/files')
36-
37-
// wait a bit for things to be settled
38-
cy.wait(1000)
32+
cy.uploadFile(randUser, 'audio.mp3', 'audio/mpeg')
33+
cy.uploadFile(randUser, 'audio.ogg', 'audio/ogg')
3934
})
4035
after(function() {
4136
cy.logout()
4237
})
4338

4439
it('See audios in the list', function() {
40+
cy.login(randUser)
41+
cy.visit('/apps/files')
42+
4543
cy.get('.files-fileList tr[data-file="audio.mp3"]', { timeout: 10000 })
4644
.should('contain', 'audio.mp3')
4745
cy.get('.files-fileList tr[data-file="audio.ogg"]', { timeout: 10000 })
@@ -61,11 +59,14 @@ describe('Open mp3 and ogg audio in viewer', function() {
6159

6260
it('Does see next navigation arrows', function() {
6361
cy.get('body > .viewer .modal-container audio').should('have.length', 2)
62+
cy.get('body > .viewer button.prev').should('be.visible')
63+
cy.get('body > .viewer button.next').should('be.visible')
64+
})
65+
66+
it('The audio source is the remote url', function() {
6467
cy.get('body > .viewer .modal-container .viewer__file.viewer__file--active audio')
6568
.should('have.attr', 'src')
6669
.and('contain', `/remote.php/dav/files/${randUser}/audio.mp3`)
67-
cy.get('body > .viewer button.next').should('be.visible')
68-
cy.get('body > .viewer button.next').should('be.visible')
6970
})
7071

7172
it('Does not see a loading animation', function() {
@@ -75,18 +76,17 @@ describe('Open mp3 and ogg audio in viewer', function() {
7576
.and('not.have.class', 'icon-loading')
7677
})
7778

78-
it('Take screenshot 1', function() {
79-
cy.screenshot()
80-
})
81-
8279
it('Show audio.ogg on next', function() {
8380
cy.get('body > .viewer button.next').click()
8481
cy.get('body > .viewer .modal-container audio').should('have.length', 2)
82+
cy.get('body > .viewer button.prev').should('be.visible')
83+
cy.get('body > .viewer button.next').should('be.visible')
84+
})
85+
86+
it('The audio source is the remote url', function() {
8587
cy.get('body > .viewer .modal-container .viewer__file.viewer__file--active audio')
8688
.should('have.attr', 'src')
8789
.and('contain', `/remote.php/dav/files/${randUser}/audio.ogg`)
88-
cy.get('body > .viewer button.prev').should('be.visible')
89-
cy.get('body > .viewer button.next').should('be.visible')
9090
})
9191

9292
it('Does not see a loading animation', function() {
@@ -95,8 +95,4 @@ describe('Open mp3 and ogg audio in viewer', function() {
9595
.and('have.class', 'modal-mask')
9696
.and('not.have.class', 'icon-loading')
9797
})
98-
99-
it('Take screenshot 2', function() {
100-
cy.screenshot()
101-
})
10298
})

cypress/e2e/files.cy.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,9 @@ describe('Files default view', function() {
2929
})
3030

3131
it('See the default files list', function() {
32+
cy.login('admin', 'admin')
33+
cy.visit('/apps/files')
34+
3235
cy.get('.files-fileList tr').should('contain', 'welcome.txt')
3336
})
3437

cypress/e2e/image-apng.cy.js renamed to cypress/e2e/images/image-apng.cy.js

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -20,27 +20,25 @@
2020
*
2121
*/
2222

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

2626
describe('Open image-apng.png in viewer', function() {
2727
before(function() {
2828
// Init user
29-
cy.nextcloudCreateUser(randUser, 'password')
30-
cy.login(randUser, 'password')
29+
cy.nextcloudCreateUser(randUser)
3130

3231
// Upload test files
33-
cy.uploadFile('image-apng.png', 'image/png')
34-
cy.visit('/apps/files')
35-
36-
// wait a bit for things to be settled
37-
cy.wait(1000)
32+
cy.uploadFile(randUser, 'image-apng.png', 'image/png')
3833
})
3934
after(function() {
4035
cy.logout()
4136
})
4237

4338
it('See image-apng.png in the list', function() {
39+
cy.login(randUser)
40+
cy.visit('/apps/files')
41+
4442
cy.get('.files-fileList tr[data-file="image-apng.png"]', { timeout: 10000 })
4543
.should('contain', 'image-apng.png')
4644
})
@@ -67,4 +65,10 @@ describe('Open image-apng.png in viewer', function() {
6765
cy.get('body > .viewer button.prev').should('not.be.visible')
6866
cy.get('body > .viewer button.next').should('not.be.visible')
6967
})
68+
69+
it('The image source is the preview url', function() {
70+
cy.get('body > .viewer .modal-container img.viewer__file.viewer__file--active')
71+
.should('have.attr', 'src')
72+
.and('contain', '/index.php/core/preview')
73+
})
7074
})

0 commit comments

Comments
 (0)