Skip to content

Commit 1521ad7

Browse files
committed
fixup! chore: use vite preprocessor for Cypress
1 parent 5abfc6a commit 1521ad7

17 files changed

+79
-46
lines changed

cypress.config.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -146,12 +146,14 @@ export default defineConfig({
146146

147147
// Before the browser launches
148148
// starting Nextcloud testing container
149+
const port = 8042
149150
const ip = await startNextcloud(process.env.BRANCH, false, {
150151
mounts,
152+
exposePort: port,
151153
})
152154

153155
// Setting container's IP as base Url
154-
config.baseUrl = `http://${ip}/index.php`
156+
config.baseUrl = `http://localhost:${port}/index.php`
155157
await waitOnNextcloud(ip)
156158
await configureNextcloud()
157159

cypress/e2e/core/header_contacts-menu.cy.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55

66
import { User } from '@nextcloud/e2e-test-server/cypress'
77
import { clearState, getNextcloudHeader } from '../../support/commonUtils.ts'
8+
import { randomString } from '../../support/utils/randomString.ts'
89

910
const admin = new User('admin', 'admin')
1011

@@ -43,7 +44,7 @@ describe('Header: Contacts menu', { testIsolation: true }, () => {
4344

4445
it('Just added users are seen in the contacts menu', () => {
4546
// I create a new user
46-
const newUserName = (Math.random() + 1).toString(36).substring(7)
47+
const newUserName = randomString(7)
4748
// we can not use createRandomUser as it will invalidate the session
4849
cy.runOccCommand(`user:add --password-from-env '${newUserName}'`, { env: { OC_PASS: '1234567' } })
4950
// I open the Contacts menu

cypress/e2e/core/setup.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
* SPDX-License-Identifier: AGPL-3.0-or-later
44
*/
55

6+
import { randomString } from '../../support/utils/randomString.ts'
7+
68
/**
79
* DO NOT RENAME THIS FILE to .cy.ts ⚠️
810
* This is not following the pattern of the other files in this folder
@@ -110,7 +112,7 @@ describe('Can install Nextcloud', { testIsolation: true, retries: 0 }, () => {
110112
* Shared admin setup function for the Nextcloud setup
111113
*/
112114
function sharedSetup() {
113-
const randAdmin = 'admin-' + Math.random().toString(36).substring(2, 15)
115+
const randAdmin = 'admin-' + randomString(10)
114116

115117
// mock appstore
116118
cy.intercept('**/settings/apps/list', { fixture: 'appstore/apps.json' })

cypress/e2e/files/LivePhotosUtils.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55

66
import type { User } from '@nextcloud/e2e-test-server/cypress'
77

8+
import { randomString } from '../../support/utils/randomString.ts'
9+
810
type SetupInfo = {
911
snapshot: string
1012
jpgFileId: number
@@ -72,7 +74,7 @@ export function setupLivePhotos(): Cypress.Chainable<SetupInfo> {
7274
} else {
7375
let requesttoken: string
7476

75-
setupInfo.fileName = Math.random().toString(36).replace(/[^a-z]+/g, '').substring(0, 10)
77+
setupInfo.fileName = randomString(10)
7678

7779
cy.createRandomUser().then((_user) => {
7880
setupInfo.user = _user

cypress/e2e/files/files-download.cy.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import type { User } from '@nextcloud/e2e-test-server/cypress'
77

88
import { deleteDownloadsFolderBeforeEach } from 'cypress-delete-downloads-folder'
99
import { zipFileContains } from '../../support/utils/assertions.ts'
10+
import { randomString } from '../../support/utils/randomString.ts'
1011
import { getRowForFile, navigateToFolder, triggerActionForFile } from './FilesUtils.ts'
1112

1213
describe('files: Download files using file actions', { testIsolation: true }, () => {
@@ -303,7 +304,6 @@ describe('files: Download files using selection', () => {
303304
* Regression test of https://help.nextcloud.com/t/unable-to-download-files-on-nextcloud-when-multiple-files-selected/221327/5
304305
*/
305306
it('can download selected files with email uid', () => {
306-
const randomString = (length: number) => (Math.random() + 1).toString(36).substring(length)
307307
const name = `${randomString(5)}@${randomString(3)}`
308308
const user: User = { userId: name, password: name, language: 'en' }
309309

cypress/e2e/files_sharing/limit_to_same_group.cy.ts

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55

66
import type { User } from '@nextcloud/e2e-test-server/cypress'
77

8+
import { randomString } from '../../support/utils/randomString.ts'
89
import { createShare } from './FilesSharingUtils.ts'
910

1011
describe('Limit to sharing to people in the same group', () => {
@@ -17,11 +18,11 @@ describe('Limit to sharing to people in the same group', () => {
1718
let randomGroupName3 = ''
1819

1920
before(() => {
20-
randomFileName1 = Math.random().toString(36).replace(/[^a-z]+/g, '').substring(0, 10) + '.txt'
21-
randomFileName2 = Math.random().toString(36).replace(/[^a-z]+/g, '').substring(0, 10) + '.txt'
22-
randomGroupName = Math.random().toString(36).replace(/[^a-z]+/g, '').substring(0, 10)
23-
randomGroupName2 = Math.random().toString(36).replace(/[^a-z]+/g, '').substring(0, 10)
24-
randomGroupName3 = Math.random().toString(36).replace(/[^a-z]+/g, '').substring(0, 10)
21+
randomFileName1 = randomString(10) + '.txt'
22+
randomFileName2 = randomString(10) + '.txt'
23+
randomGroupName = randomString(10)
24+
randomGroupName2 = randomString(10)
25+
randomGroupName3 = randomString(10)
2526

2627
cy.runOccCommand('config:app:set core shareapi_only_share_with_group_members --value yes')
2728

cypress/e2e/files_versions/version_creation.cy.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,14 @@
33
* SPDX-License-Identifier: AGPL-3.0-or-later
44
*/
55

6+
import { randomString } from '../../support/utils/randomString.ts'
67
import { openVersionsPanel, uploadThreeVersions } from './filesVersionsUtils.ts'
78

89
describe('Versions creation', () => {
910
let randomFileName = ''
1011

1112
before(() => {
12-
randomFileName = Math.random().toString(36).replace(/[^a-z]+/g, '').substring(0, 10) + '.txt'
13+
randomFileName = randomString(10) + '.txt'
1314

1415
cy.createRandomUser()
1516
.then((user) => {

cypress/e2e/files_versions/version_cross_share_move_and_copy.cy.ts

Lines changed: 25 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -5,30 +5,10 @@
55

66
import type { User } from '@nextcloud/e2e-test-server/cypress'
77

8+
import { randomString } from '../../support/utils/randomString.ts'
89
import { clickOnBreadcrumbs, closeSidebar, copyFile, moveFile, navigateToFolder } from '../files/FilesUtils.ts'
910
import { assertVersionContent, nameVersion, openVersionsPanel, setupTestSharedFileFromUser, uploadThreeVersions } from './filesVersionsUtils.ts'
1011

11-
/**
12-
*
13-
* @param filePath
14-
*/
15-
function assertVersionsContent(filePath: string) {
16-
const path = filePath.split('/').slice(0, -1).join('/')
17-
18-
clickOnBreadcrumbs('All files')
19-
20-
if (path !== '') {
21-
navigateToFolder(path)
22-
}
23-
24-
openVersionsPanel(filePath)
25-
26-
cy.get('[data-files-versions-version]').should('have.length', 3)
27-
assertVersionContent(0, 'v3')
28-
assertVersionContent(1, 'v2')
29-
assertVersionContent(2, 'v1')
30-
}
31-
3212
describe('Versions cross share move and copy', () => {
3313
let randomSharedFolderName = ''
3414
let randomFileName = ''
@@ -37,7 +17,7 @@ describe('Versions cross share move and copy', () => {
3717
let bob: User
3818

3919
before(() => {
40-
randomSharedFolderName = Math.random().toString(36).replace(/[^a-z]+/g, '').substring(0, 10)
20+
randomSharedFolderName = randomString(10)
4121

4222
cy.createRandomUser()
4323
.then((user) => {
@@ -49,7 +29,7 @@ describe('Versions cross share move and copy', () => {
4929
})
5030

5131
beforeEach(() => {
52-
randomFileName = Math.random().toString(36).replace(/[^a-z]+/g, '').substring(0, 10) + '.txt'
32+
randomFileName = randomString(10) + '.txt'
5333
randomFilePath = `${randomSharedFolderName}/${randomFileName}`
5434
uploadThreeVersions(alice, randomFilePath)
5535

@@ -78,8 +58,8 @@ describe('Versions cross share move and copy', () => {
7858
let randomSubSubFolderName
7959

8060
beforeEach(() => {
81-
randomSubFolderName = Math.random().toString(36).replace(/[^a-z]+/g, '').substring(0, 10)
82-
randomSubSubFolderName = Math.random().toString(36).replace(/[^a-z]+/g, '').substring(0, 10)
61+
randomSubFolderName = randomString(10)
62+
randomSubSubFolderName = randomString(10)
8363
clickOnBreadcrumbs('All files')
8464
cy.mkdir(bob, `/${randomSharedFolderName}/${randomSubFolderName}`)
8565
cy.mkdir(bob, `/${randomSharedFolderName}/${randomSubFolderName}/${randomSubSubFolderName}`)
@@ -101,3 +81,23 @@ describe('Versions cross share move and copy', () => {
10181
})
10282
})
10383
})
84+
85+
/**
86+
* @param filePath
87+
*/
88+
function assertVersionsContent(filePath: string) {
89+
const path = filePath.split('/').slice(0, -1).join('/')
90+
91+
clickOnBreadcrumbs('All files')
92+
93+
if (path !== '') {
94+
navigateToFolder(path)
95+
}
96+
97+
openVersionsPanel(filePath)
98+
99+
cy.get('[data-files-versions-version]').should('have.length', 3)
100+
assertVersionContent(0, 'v3')
101+
assertVersionContent(1, 'v2')
102+
assertVersionContent(2, 'v1')
103+
}

cypress/e2e/files_versions/version_deletion.cy.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,13 @@
55

66
import type { User } from '@nextcloud/e2e-test-server/cypress'
77

8+
import { randomString } from '../../support/utils/randomString.ts'
89
import { getRowForFile, navigateToFolder } from '../files/FilesUtils.ts'
910
import { deleteVersion, doesNotHaveAction, openVersionsPanel, setupTestSharedFileFromUser, uploadThreeVersions } from './filesVersionsUtils.ts'
1011

1112
describe('Versions restoration', () => {
1213
const folderName = 'shared_folder'
13-
const randomFileName = Math.random().toString(36).replace(/[^a-z]+/g, '').substring(0, 10) + '.txt'
14+
const randomFileName = randomString(10) + '.txt'
1415
const randomFilePath = `/${folderName}/${randomFileName}`
1516
let user: User
1617
let versionCount = 0

cypress/e2e/files_versions/version_download.cy.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55

66
import type { User } from '@nextcloud/e2e-test-server/cypress'
77

8+
import { randomString } from '../../support/utils/randomString.ts'
89
import { getRowForFile } from '../files/FilesUtils.ts'
910
import { assertVersionContent, doesNotHaveAction, openVersionsPanel, setupTestSharedFileFromUser, uploadThreeVersions } from './filesVersionsUtils.ts'
1011

@@ -13,7 +14,7 @@ describe('Versions download', () => {
1314
let user: User
1415

1516
before(() => {
16-
randomFileName = Math.random().toString(36).replace(/[^a-z]+/g, '').substring(0, 10) + '.txt'
17+
randomFileName = randomString(10) + '.txt'
1718

1819
cy.runOccCommand('config:app:set --value no core shareapi_allow_view_without_download')
1920
cy.createRandomUser()

0 commit comments

Comments
 (0)