mirror of
https://github.com/nextcloud/server.git
synced 2026-05-28 04:32:30 -04:00
chore(tests): Fix using save/restore state in cypress
Signed-off-by: Louis Chemineau <louis@chmn.me>
This commit is contained in:
parent
bb010b233b
commit
2d839d767a
5 changed files with 25 additions and 19 deletions
4
.github/workflows/cypress.yml
vendored
4
.github/workflows/cypress.yml
vendored
|
|
@ -146,7 +146,7 @@ jobs:
|
|||
|
||||
- name: Extract NC logs
|
||||
if: failure() && matrix.containers != 'component'
|
||||
run: docker logs nextcloud-cypress-tests-${{ env.APP_NAME }} > nextcloud.log
|
||||
run: docker logs nextcloud-cypress-tests_${{ env.APP_NAME }} > nextcloud.log
|
||||
|
||||
- name: Upload NC logs
|
||||
uses: actions/upload-artifact@0b2256b8c012f0828dc542b3febcab082c67f72b # v4.3.4
|
||||
|
|
@ -157,7 +157,7 @@ jobs:
|
|||
|
||||
- name: Create data dir archive
|
||||
if: failure() && matrix.containers != 'component'
|
||||
run: docker exec nextcloud-cypress-tests-server tar -cvjf - data > data.tar
|
||||
run: docker exec nextcloud-cypress-tests_${{ env.APP_NAME }} tar -cvjf - data > data.tar
|
||||
|
||||
- name: Upload data dir archive
|
||||
uses: actions/upload-artifact@0b2256b8c012f0828dc542b3febcab082c67f72b # v4.3.4
|
||||
|
|
|
|||
|
|
@ -9,13 +9,13 @@
|
|||
import Docker from 'dockerode'
|
||||
import waitOn from 'wait-on'
|
||||
import { c as createTar } from 'tar'
|
||||
import path from 'path'
|
||||
import path, { basename } from 'path'
|
||||
import { execSync } from 'child_process'
|
||||
import { existsSync } from 'fs'
|
||||
|
||||
export const docker = new Docker()
|
||||
|
||||
const CONTAINER_NAME = 'nextcloud-cypress-tests-server'
|
||||
const CONTAINER_NAME = `nextcloud-cypress-tests_${basename(process.cwd()).replace(' ', '')}`
|
||||
const SERVER_IMAGE = 'ghcr.io/nextcloud/continuous-integration-shallow-server'
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -21,7 +21,7 @@ describe('Versions expiration', () => {
|
|||
})
|
||||
|
||||
it('Expire all versions', () => {
|
||||
cy.runOccCommand('config:system:set versions_retention_obligation --value "0, 0"')
|
||||
cy.runOccCommand("config:system:set versions_retention_obligation --value '0, 0'")
|
||||
cy.runOccCommand('versions:expire')
|
||||
cy.runOccCommand('config:system:set versions_retention_obligation --value auto')
|
||||
cy.visit('/apps/files')
|
||||
|
|
@ -38,7 +38,7 @@ describe('Versions expiration', () => {
|
|||
it('Expire versions v2', () => {
|
||||
nameVersion(2, 'v1')
|
||||
|
||||
cy.runOccCommand('config:system:set versions_retention_obligation --value "0, 0"')
|
||||
cy.runOccCommand("config:system:set versions_retention_obligation --value '0, 0'")
|
||||
cy.runOccCommand('versions:expire')
|
||||
cy.runOccCommand('config:system:set versions_retention_obligation --value auto')
|
||||
cy.visit('/apps/files')
|
||||
|
|
|
|||
|
|
@ -60,11 +60,6 @@ declare global {
|
|||
* **Warning**: Providing a user will reset the previous session.
|
||||
*/
|
||||
resetUserTheming(user?: User): Cypress.Chainable<void>,
|
||||
|
||||
/**
|
||||
* Run an occ command in the docker container.
|
||||
*/
|
||||
runOccCommand(command: string, options?: Partial<Cypress.ExecOptions>): Cypress.Chainable<Cypress.Exec>,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -295,8 +290,3 @@ Cypress.Commands.add('resetUserTheming', (user?: User) => {
|
|||
cy.clearCookies()
|
||||
}
|
||||
})
|
||||
|
||||
Cypress.Commands.add('runOccCommand', (command: string, options?: Partial<Cypress.ExecOptions>) => {
|
||||
const env = Object.entries(options?.env ?? {}).map(([name, value]) => `-e '${name}=${value}'`).join(' ')
|
||||
return cy.exec(`docker exec --user www-data ${env} nextcloud-cypress-tests-server php ./occ ${command}`, options)
|
||||
})
|
||||
|
|
|
|||
|
|
@ -3,6 +3,8 @@
|
|||
* SPDX-License-Identifier: AGPL-3.0-or-later
|
||||
*/
|
||||
|
||||
import { basename } from 'path'
|
||||
|
||||
/**
|
||||
* Get the header navigation bar
|
||||
*/
|
||||
|
|
@ -49,8 +51,12 @@ export function installTestApp() {
|
|||
cy.runOccCommand('-V').then((output) => {
|
||||
const version = output.stdout.match(/(\d\d+)\.\d+\.\d+/)?.[1]
|
||||
cy.wrap(version).should('not.be.undefined')
|
||||
cy.exec(`docker cp '${testAppPath}' nextcloud-cypress-tests-server:/var/www/html/apps`, { log: true })
|
||||
cy.exec(`docker exec nextcloud-cypress-tests-server sed -i -e 's|-version="[0-9]\\+|-version="${version}|g' apps/testapp/appinfo/info.xml`)
|
||||
getContainerName()
|
||||
.then(containerName => {
|
||||
cy.exec(`docker cp '${testAppPath}' ${containerName}:/var/www/html/apps`, { log: true })
|
||||
cy.exec(`docker exec --workdir /var/www/html ${containerName} chown -R www-data:www-data /var/www/html/apps/testapp`)
|
||||
})
|
||||
cy.runCommand(`sed -i -e 's|-version=\\"[0-9]\\+|-version=\\"${version}|g' apps/testapp/appinfo/info.xml`)
|
||||
cy.runOccCommand('app:enable --force testapp')
|
||||
})
|
||||
}
|
||||
|
|
@ -60,5 +66,15 @@ export function installTestApp() {
|
|||
*/
|
||||
export function uninstallTestApp() {
|
||||
cy.runOccCommand('app:remove testapp', { failOnNonZeroExit: false })
|
||||
cy.exec('docker exec nextcloud-cypress-tests-server rm -fr apps/testapp/appinfo/info.xml')
|
||||
cy.runCommand('rm -fr apps/testapp/appinfo/info.xml')
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
export function getContainerName(): Cypress.Chainable<string> {
|
||||
return cy.exec('pwd')
|
||||
.then(({ stdout }) => {
|
||||
return cy.wrap(`nextcloud-cypress-tests_${basename(stdout).replace(' ', '')}`)
|
||||
})
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue