Skip to content

Commit 70f1005

Browse files
Merge a05bf23 into d35c536
2 parents d35c536 + a05bf23 commit 70f1005

8 files changed

Lines changed: 115 additions & 43 deletions

File tree

.github/workflows/cypress.yml

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -142,12 +142,14 @@ jobs:
142142
uses: actions/upload-artifact@4cec3d8aa04e39d1a68397de0c4cd6fb9dce8ec1 # v4.6.1
143143
if: always()
144144
with:
145-
name: snapshots_${{ matrix.containers }}
146-
path: cypress/snapshots
145+
name: snapshots_videos_${{ matrix.containers }}
146+
path: |
147+
cypress/snapshots
148+
cypress/videos
147149
148150
- name: Extract NC logs
149151
if: failure() && matrix.containers != 'component'
150-
run: docker logs nextcloud-cypress-tests-${{ env.APP_NAME }} > nextcloud.log
152+
run: docker logs nextcloud-cypress-tests_${{ env.APP_NAME }} > nextcloud.log
151153

152154
- name: Upload NC logs
153155
uses: actions/upload-artifact@4cec3d8aa04e39d1a68397de0c4cd6fb9dce8ec1 # v4.6.1

cypress.config.ts

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,16 +11,20 @@ export default defineConfig({
1111
viewportWidth: 1280,
1212
viewportHeight: 720,
1313

14-
// Tries again 2 more times on failure
14+
requestTimeout: 20000,
15+
1516
retries: {
16-
runMode: 2,
17+
runMode: 0,
1718
// do not retry in `cypress open`
1819
openMode: 0,
1920
},
2021

2122
// Needed to trigger `after:run` events with cypress open
2223
experimentalInteractiveRunEvents: true,
2324

25+
// disabled if running in CI but enabled in debug mode
26+
video: !process.env.CI || !!process.env.RUNNER_DEBUG,
27+
2428
// faster video processing
2529
videoCompression: false,
2630

@@ -33,8 +37,6 @@ export default defineConfig({
3337
trashAssetsBeforeRuns: true,
3438

3539
e2e: {
36-
testIsolation: false,
37-
3840
// We've imported your old cypress plugins here.
3941
// You may want to clean this up later by importing these.
4042
async setupNodeEvents(on, config) {
@@ -74,12 +76,14 @@ export default defineConfig({
7476

7577
// Remove container after run
7678
on('after:run', () => {
77-
stopNextcloud()
79+
if (!process.env.CI) {
80+
stopNextcloud()
81+
}
7882
})
7983

8084
// Before the browser launches
8185
// starting Nextcloud testing container
82-
const ip = await startNextcloud(process.env.BRANCH || 'master')
86+
const ip = await startNextcloud(process.env.BRANCH || 'master', undefined, { exposePort: 8080 })
8387
// Setting container's IP as base Url
8488
config.baseUrl = `http://${ip}/index.php`
8589
await waitOnNextcloud(ip)

cypress/e2e/filesUtils.ts

Lines changed: 20 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,12 @@ export const triggerActionForFile = (filename: string, actionId: string) => {
5757
}
5858

5959
export function renameFile(fileName: string, newName: string) {
60+
// The file must exist and the preview loaded as it locks the file
6061
getRowForFile(fileName)
62+
.should('be.visible')
63+
.find('.files-list__row-icon-preview--loaded')
64+
.should('exist')
65+
6166
triggerActionForFile(fileName, 'rename')
6267

6368
// intercept the move so we can wait for it
@@ -99,8 +104,7 @@ export function createFolder (dirName: string) {
99104
}
100105

101106
export function moveFile (fileName: string, dirName: string) {
102-
toggleMenuAction(fileName)
103-
cy.get(`[data-cy-files-list] [data-cy-files-list-row-action="move-copy"]`).click()
107+
toggleMenuAction(fileName, 'move-copy')
104108
cy.get('.file-picker').within(() => {
105109
// intercept the copy so we can wait for it
106110
cy.intercept('MOVE', /\/(remote|public)\.php\/dav\/files\//).as('moveFile')
@@ -128,12 +132,23 @@ export function moveFile (fileName: string, dirName: string) {
128132
})
129133
}
130134

131-
export function toggleMenuAction(fileName: string) {
132-
cy.get(`[data-cy-files-list] [data-cy-files-list-row-name="${CSS.escape(fileName)}"] [data-cy-files-list-row-actions]`)
135+
export function getFileListRow(filename: string) {
136+
return cy.get(`[data-cy-files-list] [data-cy-files-list-row-name="${CSS.escape(filename)}"]`)
137+
}
138+
139+
export function toggleMenuAction(fileName: string, action: 'details'|'favorite'|'move-copy'|'rename') {
140+
getFileListRow(fileName)
141+
.find('[data-cy-files-list-row-actions]')
133142
.should('be.visible')
143+
144+
getFileListRow(fileName)
145+
.find('[data-cy-files-list-row-actions]')
134146
.findByRole('button', { name: 'Actions' })
135147
.should('be.visible')
136148
.click()
137-
cy.get('[data-cy-files-list-row-action]')
149+
150+
cy.get(`[data-cy-files-list-row-action="${CSS.escape(action)}"]`)
138151
.should('be.visible')
152+
.findByRole('menuitem')
153+
.click()
139154
}

cypress/e2e/settings.cy.ts

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,13 +20,19 @@
2020
*
2121
*/
2222

23+
import type { User } from "@nextcloud/cypress"
24+
2325
describe('Check that user\'s settings survive a reload', () => {
26+
let user: User
27+
2428
before(() => {
2529
cy.createRandomUser()
26-
.then((user) => {
27-
cy.login(user)
28-
cy.visit('/settings/user/notifications')
29-
})
30+
.then(_user => user = _user)
31+
})
32+
33+
beforeEach(() => {
34+
cy.login(user)
35+
cy.visit('/settings/user/notifications')
3036
})
3137

3238
it('Form survive a reload', () => {

cypress/e2e/sidebar.cy.ts

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

23-
import { createFolder, moveFile, navigateToFolder, renameFile } from './filesUtils'
24-
import { addComment, addTag, addToFavorites, createPublicShare, removeFromFavorites, showActivityTab } from './sidebarUtils'
23+
import { createFolder, navigateToFolder, moveFile, renameFile, getFileListRow } from './filesUtils'
24+
import { addComment, addTag, addToFavorites, createPublicShare, randHash, removeFromFavorites, showActivityTab } from './sidebarUtils'
2525

2626
describe('Check activity listing in the sidebar', { testIsolation: true }, () => {
2727
beforeEach(function() {
@@ -49,8 +49,9 @@ describe('Check activity listing in the sidebar', { testIsolation: true }, () =>
4949

5050
it('Has share activity', () => {
5151
createPublicShare('welcome.txt')
52-
cy.get('body').contains('Link share created').should('exist')
53-
cy.get('.toast-close').click({ multiple: true })
52+
cy.visit('/apps/files')
53+
getFileListRow('welcome.txt').should('be.visible')
54+
5455
showActivityTab('welcome.txt')
5556
cy.get('.activity-entry').first().should('contains.text', 'Shared as public link')
5657
})
@@ -73,7 +74,8 @@ describe('Check activity listing in the sidebar', { testIsolation: true }, () =>
7374
})
7475

7576
it('Has tag activity', () => {
76-
addTag('welcome.txt', 'my_tag')
77+
addTag('welcome.txt', `my_tag_${randHash()}`)
78+
cy.visit('/apps/files')
7779

7880
showActivityTab('welcome.txt')
7981
cy.get('.activity-entry').first().should('contains.text', 'Added system tag')

cypress/e2e/sidebarUtils.ts

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -24,11 +24,7 @@ import { toggleMenuAction } from './filesUtils'
2424

2525
function showSidebarForFile(fileName: string) {
2626
closeSidebar()
27-
toggleMenuAction(fileName)
28-
cy.get('[data-cy-files-list-row-action="details"]')
29-
.should('be.visible')
30-
.findByRole('menuitem')
31-
.click()
27+
toggleMenuAction(fileName, 'details')
3228
cy.get('#app-sidebar-vue').should('be.visible')
3329
}
3430

@@ -47,20 +43,18 @@ export function showActivityTab(fileName: string) {
4743
cy.intercept('GET', '/ocs/v2.php/apps/activity/api/v2/activity/filter**').as('getActivities')
4844

4945
showSidebarForFile(fileName)
50-
cy.get('#app-sidebar-vue').contains('Activity').click()
46+
cy.get('#app-sidebar-vue').contains('Activity').click({ force: true })
5147

5248
cy.wait('@getActivities')
5349
}
5450

5551
export function addToFavorites(fileName: string) {
56-
toggleMenuAction(fileName)
57-
cy.get('[data-cy-files-list-row-action="favorite"]').should('contain', 'Add to favorites').click()
52+
toggleMenuAction(fileName, 'favorite')
5853
cy.get('.toast-close').click()
5954
}
6055

6156
export function removeFromFavorites(fileName: string) {
62-
toggleMenuAction(fileName)
63-
cy.get('[data-cy-files-list-row-action="favorite"]').should('contain', 'Remove from favorites').click()
57+
toggleMenuAction(fileName, 'favorite')
6458
cy.get('.toast-close').click()
6559
}
6660

@@ -117,3 +111,7 @@ export function addComment(fileName: string, comment: string) {
117111

118112
cy.wait('@comment')
119113
}
114+
115+
export function randHash() {
116+
return Math.random().toString(36).replace(/[^a-z]+/g, '').slice(0, 10)
117+
}

package-lock.json

Lines changed: 54 additions & 9 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
@@ -59,7 +59,7 @@
5959
},
6060
"devDependencies": {
6161
"@nextcloud/browserslist-config": "^3.0.0",
62-
"@nextcloud/cypress": "^1.0.0-beta.14",
62+
"@nextcloud/cypress": "^1.0.0-beta.15",
6363
"@nextcloud/eslint-config": "^8.3.0",
6464
"@nextcloud/stylelint-config": "^2.4.0",
6565
"@nextcloud/vite-config": "^1.2.0",

0 commit comments

Comments
 (0)