|
| 1 | +/** |
| 2 | + * SPDX-FileCopyrightText: 2025 Nextcloud GmbH and Nextcloud contributors |
| 3 | + * SPDX-License-Identifier: AGPL-3.0-or-later |
| 4 | + */ |
| 5 | + |
| 6 | +/** |
| 7 | + * DO NOT RENAME THIS FILE to .cy.ts ⚠️ |
| 8 | + * This is not following the pattern of the other files in this folder |
| 9 | + * because it is manually added to the tests by the cypress config. |
| 10 | + */ |
| 11 | +describe('Can install Nextcloud', { testIsolation: true, retries: 0 }, () => { |
| 12 | + beforeEach(() => { |
| 13 | + // Move the config file and data folder |
| 14 | + cy.runCommand('rm /var/www/html/config/config.php', { failOnNonZeroExit: false }) |
| 15 | + cy.runCommand('rm /var/www/html/data/owncloud.db', { failOnNonZeroExit: false }) |
| 16 | + }) |
| 17 | + |
| 18 | + it('Sqlite', () => { |
| 19 | + cy.visit('/') |
| 20 | + cy.get('[data-cy-setup-form]').should('be.visible') |
| 21 | + cy.get('[data-cy-setup-form-field="adminlogin"]').should('be.visible') |
| 22 | + cy.get('[data-cy-setup-form-field="adminpass"]').should('be.visible') |
| 23 | + cy.get('[data-cy-setup-form-field="directory"]').should('have.value', '/var/www/html/data') |
| 24 | + |
| 25 | + // Select the SQLite database |
| 26 | + cy.get('[data-cy-setup-form-field="dbtype-sqlite"] input').check({ force: true }) |
| 27 | + |
| 28 | + sharedSetup() |
| 29 | + }) |
| 30 | + |
| 31 | + it('MySQL', () => { |
| 32 | + cy.visit('/') |
| 33 | + cy.get('[data-cy-setup-form]').should('be.visible') |
| 34 | + cy.get('[data-cy-setup-form-field="adminlogin"]').should('be.visible') |
| 35 | + cy.get('[data-cy-setup-form-field="adminpass"]').should('be.visible') |
| 36 | + cy.get('[data-cy-setup-form-field="directory"]').should('have.value', '/var/www/html/data') |
| 37 | + |
| 38 | + // Select the SQLite database |
| 39 | + cy.get('[data-cy-setup-form-field="dbtype-mysql"] input').check({ force: true }) |
| 40 | + |
| 41 | + // Fill in the DB form |
| 42 | + cy.get('[data-cy-setup-form-field="dbuser"]').type('{selectAll}oc_autotest') |
| 43 | + cy.get('[data-cy-setup-form-field="dbpass"]').type('{selectAll}nextcloud') |
| 44 | + cy.get('[data-cy-setup-form-field="dbname"]').type('{selectAll}oc_autotest') |
| 45 | + cy.get('[data-cy-setup-form-field="dbhost"]').type('{selectAll}mysql:3306') |
| 46 | + |
| 47 | + sharedSetup() |
| 48 | + }) |
| 49 | + |
| 50 | + it('MariaDB', () => { |
| 51 | + cy.visit('/') |
| 52 | + cy.get('[data-cy-setup-form]').should('be.visible') |
| 53 | + cy.get('[data-cy-setup-form-field="adminlogin"]').should('be.visible') |
| 54 | + cy.get('[data-cy-setup-form-field="adminpass"]').should('be.visible') |
| 55 | + cy.get('[data-cy-setup-form-field="directory"]').should('have.value', '/var/www/html/data') |
| 56 | + |
| 57 | + // Select the SQLite database |
| 58 | + cy.get('[data-cy-setup-form-field="dbtype-mysql"] input').check({ force: true }) |
| 59 | + |
| 60 | + // Fill in the DB form |
| 61 | + cy.get('[data-cy-setup-form-field="dbuser"]').type('{selectAll}oc_autotest') |
| 62 | + cy.get('[data-cy-setup-form-field="dbpass"]').type('{selectAll}nextcloud') |
| 63 | + cy.get('[data-cy-setup-form-field="dbname"]').type('{selectAll}oc_autotest') |
| 64 | + cy.get('[data-cy-setup-form-field="dbhost"]').type('{selectAll}mariadb:3306') |
| 65 | + |
| 66 | + sharedSetup() |
| 67 | + }) |
| 68 | + |
| 69 | + it('PostgreSQL', () => { |
| 70 | + cy.visit('/') |
| 71 | + cy.get('[data-cy-setup-form]').should('be.visible') |
| 72 | + cy.get('[data-cy-setup-form-field="adminlogin"]').should('be.visible') |
| 73 | + cy.get('[data-cy-setup-form-field="adminpass"]').should('be.visible') |
| 74 | + cy.get('[data-cy-setup-form-field="directory"]').should('have.value', '/var/www/html/data') |
| 75 | + |
| 76 | + // Select the SQLite database |
| 77 | + cy.get('[data-cy-setup-form-field="dbtype-pgsql"] input').check({ force: true }) |
| 78 | + |
| 79 | + // Fill in the DB form |
| 80 | + cy.get('[data-cy-setup-form-field="dbuser"]').type('{selectAll}root') |
| 81 | + cy.get('[data-cy-setup-form-field="dbpass"]').type('{selectAll}rootpassword') |
| 82 | + cy.get('[data-cy-setup-form-field="dbname"]').type('{selectAll}nextcloud') |
| 83 | + cy.get('[data-cy-setup-form-field="dbhost"]').type('{selectAll}postgres:5432') |
| 84 | + |
| 85 | + sharedSetup() |
| 86 | + }) |
| 87 | + |
| 88 | +}) |
| 89 | + |
| 90 | +/** |
| 91 | + * Shared admin setup function for the Nextcloud setup |
| 92 | + */ |
| 93 | +function sharedSetup() { |
| 94 | + const randAdmin = 'admin-' + Math.random().toString(36).substring(2, 15) |
| 95 | + |
| 96 | + // Fill in the form |
| 97 | + cy.get('[data-cy-setup-form-field="adminlogin"]').type(randAdmin) |
| 98 | + cy.get('[data-cy-setup-form-field="adminpass"]').type(randAdmin) |
| 99 | + |
| 100 | + // Nothing more to do on sqlite, let's continue |
| 101 | + cy.get('[data-cy-setup-form-submit]').click() |
| 102 | + |
| 103 | + // Wait for the setup to finish |
| 104 | + cy.location('pathname', { timeout: 10000 }) |
| 105 | + .should('include', '/core/apps/recommended') |
| 106 | + |
| 107 | + // Skip the setup apps |
| 108 | + cy.get('[data-cy-setup-recommended-apps]').should('be.visible') |
| 109 | + cy.get('[data-cy-setup-recommended-apps-skip]').click() |
| 110 | + |
| 111 | + // Go to files |
| 112 | + cy.visit('/apps/files/') |
| 113 | + cy.get('[data-cy-files-content]').should('be.visible') |
| 114 | +} |
0 commit comments