aboutsummaryrefslogtreecommitdiffstats
path: root/cypress/e2e/files_external/settings.cy.ts
diff options
context:
space:
mode:
Diffstat (limited to 'cypress/e2e/files_external/settings.cy.ts')
-rw-r--r--cypress/e2e/files_external/settings.cy.ts130
1 files changed, 130 insertions, 0 deletions
diff --git a/cypress/e2e/files_external/settings.cy.ts b/cypress/e2e/files_external/settings.cy.ts
new file mode 100644
index 00000000000..9f017bbf951
--- /dev/null
+++ b/cypress/e2e/files_external/settings.cy.ts
@@ -0,0 +1,130 @@
+/*!
+ * SPDX-FileCopyrightText: 2025 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-License-Identifier: AGPL-3.0-or-later
+ */
+
+describe('files_external settings', () => {
+ before(() => {
+ cy.runOccCommand('app:enable files_external')
+ cy.login({ language: 'en', password: 'admin', userId: 'admin' })
+ })
+
+ beforeEach(() => {
+ cy.runOccCommand('files_external:list --output json')
+ .then((exec) => {
+ const list = JSON.parse(exec.stdout)
+ for (const entry of list) {
+ cy.runOccCommand('files_external:delete ' + entry)
+ }
+ })
+ cy.visit('/settings/admin/externalstorages')
+ })
+
+ it('can see the settings section', () => {
+ cy.findByRole('heading', { name: 'External storage' })
+ .should('be.visible')
+ cy.get('table#externalStorage')
+ .should('be.visible')
+ })
+
+ it('populates the row and creates a new empty one', () => {
+ selectBackend('local')
+
+ // See cell now contains the backend
+ getTable()
+ .findAllByRole('row')
+ .first()
+ .find('.backend')
+ .should('contain.text', 'Local')
+
+ // and the backend select is available but clear
+ getBackendSelect()
+ .should('have.value', null)
+
+ // the suggested mount point name is set to the backend
+ getTable()
+ .findAllByRole('row')
+ .first()
+ .find('input[name="mountPoint"]')
+ .should('have.value', 'Local')
+ })
+
+ it('does not save the storage with missing configuration', function() {
+ selectBackend('local')
+
+ getTable()
+ .findAllByRole('row').first()
+ .should('be.visible')
+ .within(() => {
+ cy.findByRole('checkbox', { name: 'All people' })
+ .check()
+ cy.get('button[title="Save"]')
+ .click()
+ })
+
+ cy.findByRole('dialog', { name: 'Confirm your password' })
+ .should('not.exist')
+ })
+
+ it('does not save the storage with applicable configuration', function() {
+ selectBackend('local')
+
+ getTable()
+ .findAllByRole('row').first()
+ .should('be.visible')
+ .within(() => {
+ cy.get('input[placeholder="Location"]')
+ .type('/tmp')
+ cy.get('button[title="Save"]')
+ .click()
+ })
+
+ cy.findByRole('dialog', { name: 'Confirm your password' })
+ .should('not.exist')
+ })
+
+ it('does save the storage with needed configuration', function() {
+ selectBackend('local')
+
+ getTable()
+ .findAllByRole('row').first()
+ .should('be.visible')
+ .within(() => {
+ cy.findByRole('checkbox', { name: 'All people' })
+ .check()
+ cy.get('input[placeholder="Location"]')
+ .type('/tmp')
+ cy.get('button[title="Save"]')
+ .click()
+ })
+
+ cy.findByRole('dialog', { name: 'Confirm your password' })
+ .should('be.visible')
+ })
+})
+
+/**
+ * Get the external storages table
+ */
+function getTable() {
+ return cy.get('table#externalStorage')
+ .find('tbody')
+}
+
+/**
+ * Get the backend select element
+ */
+function getBackendSelect() {
+ return getTable()
+ .findAllByRole('row')
+ .last()
+ .findByRole('combobox')
+}
+
+/**
+ * @param backend - Backend to select
+ */
+function selectBackend(backend: string): void {
+ getBackendSelect()
+ .select(backend)
+}