summaryrefslogtreecommitdiffstats
path: root/cypress
diff options
context:
space:
mode:
authorLouis Chemineau <louis@chmn.me>2023-03-28 12:12:52 +0200
committerLouis Chemineau <louis@chmn.me>2023-03-30 10:09:14 +0200
commitea028a1b01006db484e1acb021abe94b112cd361 (patch)
tree03d8520883d132c50a71605411a001a9a8181532 /cypress
parent186491113e5fb7d81771b01a9dc54f4f5d62178c (diff)
downloadnextcloud-server-ea028a1b01006db484e1acb021abe94b112cd361.tar.gz
nextcloud-server-ea028a1b01006db484e1acb021abe94b112cd361.zip
Use random names in files_version e2e tests
Signed-off-by: Louis Chemineau <louis@chmn.me>
Diffstat (limited to 'cypress')
-rw-r--r--cypress/e2e/files_versions/filesVersionsUtils.ts19
-rw-r--r--cypress/e2e/files_versions/version_creation.cy.ts10
-rw-r--r--cypress/e2e/files_versions/version_download.cy.ts14
-rw-r--r--cypress/e2e/files_versions/version_expiration.cy.ts18
-rw-r--r--cypress/e2e/files_versions/version_naming.cy.ts8
-rw-r--r--cypress/e2e/files_versions/version_restoration.cy.ts14
6 files changed, 52 insertions, 31 deletions
diff --git a/cypress/e2e/files_versions/filesVersionsUtils.ts b/cypress/e2e/files_versions/filesVersionsUtils.ts
index cc3fc04b2e1..87252fc60f1 100644
--- a/cypress/e2e/files_versions/filesVersionsUtils.ts
+++ b/cypress/e2e/files_versions/filesVersionsUtils.ts
@@ -21,16 +21,17 @@
*/
import path from "path"
+import type { User } from "@nextcloud/cypress"
-export function uploadThreeVersions(user) {
+export function uploadThreeVersions(user: User, fileName: string) {
// A new version will not be created if the changes occur
// within less than one second of each other.
// eslint-disable-next-line cypress/no-unnecessary-waiting
- cy.uploadContent(user, new Blob(['v1'], { type: 'text/plain' }), 'text/plain', '/test.txt')
- .wait(10000)
- .uploadContent(user, new Blob(['v2'], { type: 'text/plain' }), 'text/plain', '/test.txt')
- .wait(10000)
- .uploadContent(user, new Blob(['v3'], { type: 'text/plain' }), 'text/plain', '/test.txt')
+ cy.uploadContent(user, new Blob(['v1'], { type: 'text/plain' }), 'text/plain', `/${fileName}`)
+ .wait(1100)
+ .uploadContent(user, new Blob(['v2'], { type: 'text/plain' }), 'text/plain', `/${fileName}`)
+ .wait(1100)
+ .uploadContent(user, new Blob(['v3'], { type: 'text/plain' }), 'text/plain', `/${fileName}`)
cy.login(user)
}
@@ -72,13 +73,13 @@ export function nameVersion(index: number, name: string) {
cy.get(':focused').type(`${name}{enter}`)
}
-export function assertVersionContent(index: number, expectedContent: string) {
+export function assertVersionContent(filename: string, index: number, expectedContent: string) {
const downloadsFolder = Cypress.config('downloadsFolder')
openVersionMenu(index)
clickPopperAction('Download version')
- return cy.readFile(path.join(downloadsFolder, 'test.txt'))
+ return cy.readFile(path.join(downloadsFolder, filename))
.then((versionContent) => expect(versionContent).to.equal(expectedContent))
- .then(() => cy.exec(`rm ${downloadsFolder}/test.txt`))
+ .then(() => cy.exec(`rm ${downloadsFolder}/${filename}`))
} \ No newline at end of file
diff --git a/cypress/e2e/files_versions/version_creation.cy.ts b/cypress/e2e/files_versions/version_creation.cy.ts
index d6655059143..d390d1c4406 100644
--- a/cypress/e2e/files_versions/version_creation.cy.ts
+++ b/cypress/e2e/files_versions/version_creation.cy.ts
@@ -23,18 +23,22 @@
import { openVersionsPanel, uploadThreeVersions } from './filesVersionsUtils'
describe('Versions creation', () => {
+ let randomFileName = ''
+
before(() => {
+ randomFileName = Math.random().toString(36).replace(/[^a-z]+/g, '').substring(0, 10) + '.txt'
+
cy.createRandomUser()
.then((user) => {
- uploadThreeVersions(user)
+ uploadThreeVersions(user, randomFileName)
cy.login(user)
cy.visit('/apps/files')
- openVersionsPanel('test.txt')
+ openVersionsPanel(randomFileName)
})
})
it('Opens the versions panel and sees the versions', () => {
- openVersionsPanel('test.txt')
+ openVersionsPanel(randomFileName)
cy.get('#tab-version_vue').within(() => {
cy.get('[data-files-versions-version]').should('have.length', 3)
diff --git a/cypress/e2e/files_versions/version_download.cy.ts b/cypress/e2e/files_versions/version_download.cy.ts
index 69f46915031..30299e9f8e1 100644
--- a/cypress/e2e/files_versions/version_download.cy.ts
+++ b/cypress/e2e/files_versions/version_download.cy.ts
@@ -23,19 +23,23 @@
import { assertVersionContent, openVersionsPanel, uploadThreeVersions } from './filesVersionsUtils'
describe('Versions download', () => {
+ let randomFileName = ''
+
before(() => {
+ randomFileName = Math.random().toString(36).replace(/[^a-z]+/g, '').substring(0, 10) + '.txt'
+
cy.createRandomUser()
.then((user) => {
- uploadThreeVersions(user)
+ uploadThreeVersions(user, randomFileName)
cy.login(user)
cy.visit('/apps/files')
- openVersionsPanel('test.txt')
+ openVersionsPanel(randomFileName)
})
})
it('Download versions and assert there content', () => {
- assertVersionContent(0, 'v3')
- assertVersionContent(1, 'v2')
- assertVersionContent(2, 'v1')
+ assertVersionContent(randomFileName, 0, 'v3')
+ assertVersionContent(randomFileName, 1, 'v2')
+ assertVersionContent(randomFileName, 2, 'v1')
})
})
diff --git a/cypress/e2e/files_versions/version_expiration.cy.ts b/cypress/e2e/files_versions/version_expiration.cy.ts
index fdac454884d..e0c9e36d529 100644
--- a/cypress/e2e/files_versions/version_expiration.cy.ts
+++ b/cypress/e2e/files_versions/version_expiration.cy.ts
@@ -23,27 +23,31 @@
import { assertVersionContent, nameVersion, openVersionsPanel, uploadThreeVersions } from './filesVersionsUtils'
describe('Versions expiration', () => {
+ let randomFileName = ''
+
beforeEach(() => {
+ randomFileName = Math.random().toString(36).replace(/[^a-z]+/g, '').substring(0, 10) + '.txt'
+
cy.createRandomUser()
.then((user) => {
- uploadThreeVersions(user)
+ uploadThreeVersions(user, randomFileName)
cy.login(user)
cy.visit('/apps/files')
- openVersionsPanel('test.txt')
+ openVersionsPanel(randomFileName)
})
})
it('Expire all versions', () => {
cy.runOccCommand('versions:expire')
cy.visit('/apps/files')
- openVersionsPanel('test.txt')
+ openVersionsPanel(randomFileName)
cy.get('#tab-version_vue').within(() => {
cy.get('[data-files-versions-version]').should('have.length', 1)
cy.get('[data-files-versions-version]').eq(0).contains('Current version')
})
- assertVersionContent(0, 'v3')
+ assertVersionContent(randomFileName, 0, 'v3')
})
it('Expire versions v2', () => {
@@ -51,7 +55,7 @@ describe('Versions expiration', () => {
cy.runOccCommand('versions:expire')
cy.visit('/apps/files')
- openVersionsPanel('test.txt')
+ openVersionsPanel(randomFileName)
cy.get('#tab-version_vue').within(() => {
cy.get('[data-files-versions-version]').should('have.length', 2)
@@ -59,7 +63,7 @@ describe('Versions expiration', () => {
cy.get('[data-files-versions-version]').eq(1).contains('v1')
})
- assertVersionContent(0, 'v3')
- assertVersionContent(1, 'v1')
+ assertVersionContent(randomFileName, 0, 'v3')
+ assertVersionContent(randomFileName, 1, 'v1')
})
})
diff --git a/cypress/e2e/files_versions/version_naming.cy.ts b/cypress/e2e/files_versions/version_naming.cy.ts
index 03edae131b6..4b662e31b94 100644
--- a/cypress/e2e/files_versions/version_naming.cy.ts
+++ b/cypress/e2e/files_versions/version_naming.cy.ts
@@ -23,13 +23,17 @@
import { nameVersion, openVersionsPanel, uploadThreeVersions } from './filesVersionsUtils'
describe('Versions naming', () => {
+ let randomFileName = ''
+
before(() => {
+ randomFileName = Math.random().toString(36).replace(/[^a-z]+/g, '').substring(0, 10) + '.txt'
+
cy.createRandomUser()
.then((user) => {
- uploadThreeVersions(user)
+ uploadThreeVersions(user, randomFileName)
cy.login(user)
cy.visit('/apps/files')
- openVersionsPanel('test.txt')
+ openVersionsPanel(randomFileName)
})
})
diff --git a/cypress/e2e/files_versions/version_restoration.cy.ts b/cypress/e2e/files_versions/version_restoration.cy.ts
index 74bb82c2c2d..115d30caa82 100644
--- a/cypress/e2e/files_versions/version_restoration.cy.ts
+++ b/cypress/e2e/files_versions/version_restoration.cy.ts
@@ -28,13 +28,17 @@ function restoreVersion(index: number) {
}
describe('Versions restoration', () => {
+ let randomFileName = ''
+
before(() => {
+ randomFileName = Math.random().toString(36).replace(/[^a-z]+/g, '').substring(0, 10) + '.txt'
+
cy.createRandomUser()
.then((user) => {
- uploadThreeVersions(user)
+ uploadThreeVersions(user, randomFileName)
cy.login(user)
cy.visit('/apps/files')
- openVersionsPanel('test.txt')
+ openVersionsPanel(randomFileName)
})
})
@@ -48,8 +52,8 @@ describe('Versions restoration', () => {
})
it('Downloads versions and assert there content', () => {
- assertVersionContent(0, 'v1')
- assertVersionContent(1, 'v3')
- assertVersionContent(2, 'v2')
+ assertVersionContent(randomFileName, 0, 'v1')
+ assertVersionContent(randomFileName, 1, 'v3')
+ assertVersionContent(randomFileName, 2, 'v2')
})
})