Skip to content

Commit 57a2aa1

Browse files
authored
Merge pull request #49403 from nextcloud/artonge/chore/update_nc_cypress_beta.11
chore: Update @nextcloud/cypress to v1.0.0-beta.11
2 parents 446581f + ebda7b4 commit 57a2aa1

File tree

14 files changed

+42
-83
lines changed

14 files changed

+42
-83
lines changed

.github/workflows/cypress.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,7 @@ jobs:
162162

163163
- name: Create data dir archive
164164
if: failure() && matrix.containers != 'component'
165-
run: docker exec nextcloud-cypress-tests-server tar -cvjf - data > data.tar
165+
run: docker exec nextcloud-cypress-tests_server tar -cvjf - data > data.tar
166166

167167
- name: Upload data dir archive
168168
uses: actions/upload-artifact@b4b15b8c7c6ac21ea08fcf65892d2ee8f75cf882 # v4.4.3

cypress/dockerNode.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,13 @@
99
import Docker from 'dockerode'
1010
import waitOn from 'wait-on'
1111
import { c as createTar } from 'tar'
12-
import path from 'path'
12+
import path, { basename } from 'path'
1313
import { execSync } from 'child_process'
1414
import { existsSync } from 'fs'
1515

1616
export const docker = new Docker()
1717

18-
const CONTAINER_NAME = 'nextcloud-cypress-tests-server'
18+
const CONTAINER_NAME = `nextcloud-cypress-tests_${basename(process.cwd()).replace(' ', '')}`
1919
const SERVER_IMAGE = 'ghcr.io/nextcloud/continuous-integration-shallow-server'
2020

2121
/**

cypress/e2e/files_sharing/public-share/setup-public-share.ts

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -92,25 +92,20 @@ export function setupPublicShare(): Cypress.Chainable<string> {
9292
return cy.task('getVariable', { key: 'public-share-data' })
9393
.then((data) => {
9494
// eslint-disable-next-line @typescript-eslint/no-explicit-any
95-
const { dataSnapshot, dbSnapshot, shareUrl } = data as any || {}
96-
if (dataSnapshot && dbSnapshot) {
97-
cy.restoreDB(dbSnapshot)
98-
cy.restoreData(dataSnapshot)
95+
const { dataSnapshot, shareUrl } = data as any || {}
96+
if (dataSnapshot) {
97+
cy.restoreState(dataSnapshot)
9998
url = shareUrl
10099
return cy.wrap(shareUrl as string)
101100
} else {
102-
cy.restoreData()
103-
cy.restoreDB()
104-
105101
const shareData: Record<string, unknown> = {}
106102
return cy.createRandomUser()
107103
.then(($user) => { user = $user })
108104
.then(() => setupData(shareName))
109105
.then(() => createShare(shareName))
110106
.then((value) => { shareData.shareUrl = value })
111107
.then(() => adjustSharePermission())
112-
.then(() => cy.backupDB().then((value) => { shareData.dbSnapshot = value }))
113-
.then(() => cy.backupData([user.userId]).then((value) => { shareData.dataSnapshot = value }))
108+
.then(() => cy.saveState().then((value) => { shareData.dataSnapshot = value }))
114109
.then(() => cy.task('setVariable', { key: 'public-share-data', value: shareData }))
115110
.then(() => cy.log(`Public share setup, URL: ${shareData.shareUrl}`))
116111
.then(() => cy.wrap(url))

cypress/e2e/files_sharing/public-share/view_file-drop.cy.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,7 @@ describe('files_sharing: Public share - File drop', { testIsolation: true }, ()
144144
})
145145

146146
describe('Terms of service', { testIsolation: true }, () => {
147-
before(() => cy.runOccCommand('config:app:set --value "TEST: Some disclaimer text" --type string core shareapi_public_link_disclaimertext'))
147+
before(() => cy.runOccCommand('config:app:set --value \'TEST: Some disclaimer text\' --type string core shareapi_public_link_disclaimertext'))
148148
beforeEach(() => cy.visit(shareUrl))
149149
after(() => cy.runOccCommand('config:app:delete core shareapi_public_link_disclaimertext'))
150150

cypress/e2e/files_versions/version_expiration.cy.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ describe('Versions expiration', () => {
2121
})
2222

2323
it('Expire all versions', () => {
24-
cy.runOccCommand('config:system:set versions_retention_obligation --value "0, 0"')
24+
cy.runOccCommand('config:system:set versions_retention_obligation --value \'0, 0\'')
2525
cy.runOccCommand('versions:expire')
2626
cy.runOccCommand('config:system:set versions_retention_obligation --value auto')
2727
cy.visit('/apps/files')
@@ -38,7 +38,7 @@ describe('Versions expiration', () => {
3838
it('Expire versions v2', () => {
3939
nameVersion(2, 'v1')
4040

41-
cy.runOccCommand('config:system:set versions_retention_obligation --value "0, 0"')
41+
cy.runOccCommand('config:system:set versions_retention_obligation --value \'0, 0\'')
4242
cy.runOccCommand('versions:expire')
4343
cy.runOccCommand('config:system:set versions_retention_obligation --value auto')
4444
cy.visit('/apps/files')

cypress/e2e/settings/personal-info.cy.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ describe('Settings: Change personal information', { testIsolation: true }, () =>
118118
cy.login(user)
119119
cy.visit('/settings/user')
120120

121-
cy.backupDB().then(($snapshot) => {
121+
cy.saveState().then(($snapshot) => {
122122
snapshot = $snapshot
123123
})
124124
})
@@ -136,7 +136,7 @@ describe('Settings: Change personal information', { testIsolation: true }, () =>
136136
})
137137

138138
afterEach(() => {
139-
cy.restoreDB(snapshot)
139+
cy.restoreState(snapshot)
140140
})
141141

142142
it('Can dis- and enable the profile', () => {

cypress/e2e/settings/users_groups.cy.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -213,15 +213,15 @@ describe.only('Settings: Sort groups in the UI', () => {
213213
cy.runOccCommand('group:list --output json').then((output) => {
214214
const groups = Object.keys(JSON.parse(output.stdout)).filter((group) => group !== 'admin')
215215
groups.forEach((group) => {
216-
cy.runOccCommand(`group:delete "${group}"`)
216+
cy.runOccCommand(`group:delete '${group}'`)
217217
})
218218
})
219219

220220
// Add two groups and add one user to group B
221221
cy.runOccCommand('group:add A')
222222
cy.runOccCommand('group:add B')
223223
cy.createRandomUser().then((user) => {
224-
cy.runOccCommand(`group:adduser B "${user.userId}"`)
224+
cy.runOccCommand(`group:adduser B '${user.userId}'`)
225225
})
226226

227227
// Visit the settings as admin

cypress/e2e/theming/a11y-color-contrast.cy.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ describe('Accessibility of Nextcloud theming colors', () => {
110110
before(() => {
111111
cy.createRandomUser().then(($user) => {
112112
// set user theme
113-
cy.runOccCommand(`user:setting -- '${$user.userId}' theming enabled-themes '["${theme}"]'`)
113+
cy.runOccCommand(`user:setting -- '${$user.userId}' theming enabled-themes '[\\"${theme}\\"]'`)
114114
cy.login($user)
115115
cy.visit('/')
116116
cy.injectAxe({ axeCorePath: 'node_modules/axe-core/axe.min.js' })

cypress/e2e/theming/user-settings_app-order.cy.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ describe('User theming set app order with default app', () => {
8383
// install a third app
8484
installTestApp()
8585
// set files as default app
86-
cy.runOccCommand('config:system:set --value "files" defaultapp')
86+
cy.runOccCommand('config:system:set --value \'files\' defaultapp')
8787

8888
// Create random user for this test
8989
cy.createRandomUser().then(($user) => {

cypress/support/commands.ts

Lines changed: 1 addition & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -216,41 +216,9 @@ Cypress.Commands.add('resetUserTheming', (user?: User) => {
216216
}
217217
})
218218

219-
Cypress.Commands.add('runOccCommand', (command: string, options?: Partial<Cypress.ExecOptions>) => {
220-
const env = Object.entries(options?.env ?? {}).map(([name, value]) => `-e '${name}=${value}'`).join(' ')
221-
return cy.exec(`docker exec --user www-data ${env} nextcloud-cypress-tests-server php ./occ ${command}`, options)
222-
})
223-
224219
Cypress.Commands.add('userFileExists', (user: string, path: string) => {
225220
user.replaceAll('"', '\\"')
226221
path.replaceAll('"', '\\"').replaceAll(/^\/+/gm, '')
227-
return cy.exec(`docker exec --user www-data nextcloud-cypress-tests-server stat --printf="%s" "data/${user}/files/${path}"`, { failOnNonZeroExit: true })
222+
return cy.runCommand(`stat --printf="%s" "data/${user}/files/${path}"`, { failOnNonZeroExit: true })
228223
.then((exec) => Number.parseInt(exec.stdout || '0'))
229224
})
230-
231-
Cypress.Commands.add('backupDB', (): Cypress.Chainable<string> => {
232-
const randomString = Math.random().toString(36).substring(7)
233-
cy.exec(`docker exec --user www-data nextcloud-cypress-tests-server cp /var/www/html/data/owncloud.db /var/www/html/data/owncloud.db-${randomString}`)
234-
cy.log(`Created snapshot ${randomString}`)
235-
return cy.wrap(randomString)
236-
})
237-
238-
Cypress.Commands.add('restoreDB', (snapshot: string = 'init') => {
239-
cy.exec(`docker exec --user www-data nextcloud-cypress-tests-server cp /var/www/html/data/owncloud.db-${snapshot} /var/www/html/data/owncloud.db`)
240-
cy.log(`Restored snapshot ${snapshot}`)
241-
})
242-
243-
Cypress.Commands.add('backupData', (users: string[] = ['admin']) => {
244-
const snapshot = Math.random().toString(36).substring(7)
245-
const toBackup = users.map((user) => `'${user.replaceAll('\\', '').replaceAll('\'', '\\\'')}'`).join(' ')
246-
cy.exec(`docker exec --user www-data rm /var/www/html/data/data-${snapshot}.tar`, { failOnNonZeroExit: false })
247-
cy.exec(`docker exec --user www-data --workdir /var/www/html/data nextcloud-cypress-tests-server tar cf /var/www/html/data/data-${snapshot}.tar ${toBackup}`)
248-
return cy.wrap(snapshot as string)
249-
})
250-
251-
Cypress.Commands.add('restoreData', (snapshot?: string) => {
252-
snapshot = snapshot ?? 'init'
253-
snapshot.replaceAll('\\', '').replaceAll('"', '\\"')
254-
cy.exec(`docker exec --user www-data --workdir /var/www/html/data nextcloud-cypress-tests-server rm -vfr $(tar --exclude='*/*' -tf '/var/www/html/data/data-${snapshot}.tar')`)
255-
cy.exec(`docker exec --user www-data --workdir /var/www/html/data nextcloud-cypress-tests-server tar -xf '/var/www/html/data/data-${snapshot}.tar'`)
256-
})

0 commit comments

Comments
 (0)