123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339 |
- /**
- * @copyright Copyright (c) 2023 Ferdinand Thiessen <opensource@fthiessen.de>
- *
- * @author Ferdinand Thiessen <opensource@fthiessen.de>
- *
- * @license AGPL-3.0-or-later
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- *
- */
- import { User } from '@nextcloud/cypress'
- import { installTestApp, uninstallTestApp } from '../../support/commonUtils'
- const admin = new User('admin', 'admin')
- describe('Admin theming set default apps', () => {
- before(function() {
- // Just in case previous test failed
- cy.resetAdminTheming()
- cy.login(admin)
- })
- it('See the current default app is the dashboard', () => {
- cy.visit('/')
- cy.url().should('match', /apps\/dashboard/)
- cy.get('#nextcloud').click()
- cy.url().should('match', /apps\/dashboard/)
- })
- it('See the default app settings', () => {
- cy.visit('/settings/admin/theming')
- cy.get('.settings-section').contains('Navigation bar settings').should('exist')
- cy.get('[data-cy-switch-default-app]').should('exist')
- cy.get('[data-cy-switch-default-app]').scrollIntoView()
- })
- it('Toggle the "use custom default app" switch', () => {
- cy.get('[data-cy-switch-default-app] input').should('not.be.checked')
- cy.get('[data-cy-switch-default-app] label').click()
- cy.get('[data-cy-switch-default-app] input').should('be.checked')
- })
- it('See the default app order selector', () => {
- cy.get('[data-cy-app-order] [data-cy-app-order-element]').each(($el, idx) => {
- if (idx === 0) cy.wrap($el).should('have.attr', 'data-cy-app-order-element', 'dashboard')
- else cy.wrap($el).should('have.attr', 'data-cy-app-order-element', 'files')
- })
- })
- it('Change the default app', () => {
- cy.get('[data-cy-app-order] [data-cy-app-order-element="files"]').scrollIntoView()
- cy.get('[data-cy-app-order] [data-cy-app-order-element="files"] [data-cy-app-order-button="up"]').should('be.visible')
- cy.get('[data-cy-app-order] [data-cy-app-order-element="files"] [data-cy-app-order-button="up"]').click()
- cy.get('[data-cy-app-order] [data-cy-app-order-element="files"] [data-cy-app-order-button="up"]').should('not.be.visible')
- })
- it('See the default app is changed', () => {
- cy.get('[data-cy-app-order] [data-cy-app-order-element]').each(($el, idx) => {
- if (idx === 0) cy.wrap($el).should('have.attr', 'data-cy-app-order-element', 'files')
- else cy.wrap($el).should('have.attr', 'data-cy-app-order-element', 'dashboard')
- })
- cy.get('#nextcloud').click()
- cy.url().should('match', /apps\/files/)
- })
- it('Toggle the "use custom default app" switch back to reset the default apps', () => {
- cy.visit('/settings/admin/theming')
- cy.get('[data-cy-switch-default-app]').scrollIntoView()
- cy.get('[data-cy-switch-default-app] input').should('be.checked')
- cy.get('[data-cy-switch-default-app] label').click()
- cy.get('[data-cy-switch-default-app] input').should('be.not.checked')
- })
- it('See the default app is changed back to default', () => {
- cy.reload()
- cy.get('#nextcloud').click()
- cy.url().should('match', /apps\/dashboard/)
- })
- })
- describe('User theming set app order', () => {
- let user: User
- before(() => {
- cy.resetAdminTheming()
- // Create random user for this test
- cy.createRandomUser().then(($user) => {
- user = $user
- cy.login($user)
- })
- })
- after(() => cy.deleteUser(user))
- it('See the app order settings', () => {
- cy.visit('/settings/user/theming')
- cy.get('.settings-section').contains('Navigation bar settings').should('exist')
- cy.get('[data-cy-app-order]').scrollIntoView()
- })
- it('See that the dashboard app is the first one', () => {
- cy.get('[data-cy-app-order] [data-cy-app-order-element]').each(($el, idx) => {
- if (idx === 0) cy.wrap($el).should('have.attr', 'data-cy-app-order-element', 'dashboard')
- else cy.wrap($el).should('have.attr', 'data-cy-app-order-element', 'files')
- })
- cy.get('.app-menu-main .app-menu-entry').each(($el, idx) => {
- if (idx === 0) cy.wrap($el).should('have.attr', 'data-app-id', 'dashboard')
- else cy.wrap($el).should('have.attr', 'data-app-id', 'files')
- })
- })
- it('Change the app order', () => {
- cy.get('[data-cy-app-order] [data-cy-app-order-element="files"] [data-cy-app-order-button="up"]').should('be.visible')
- cy.get('[data-cy-app-order] [data-cy-app-order-element="files"] [data-cy-app-order-button="up"]').click()
- cy.get('[data-cy-app-order] [data-cy-app-order-element="files"] [data-cy-app-order-button="up"]').should('not.be.visible')
- cy.get('[data-cy-app-order] [data-cy-app-order-element]').each(($el, idx) => {
- if (idx === 0) cy.wrap($el).should('have.attr', 'data-cy-app-order-element', 'files')
- else cy.wrap($el).should('have.attr', 'data-cy-app-order-element', 'dashboard')
- })
- })
- it('See the app menu order is changed', () => {
- cy.reload()
- cy.get('.app-menu-main .app-menu-entry').each(($el, idx) => {
- if (idx === 0) cy.wrap($el).should('have.attr', 'data-app-id', 'files')
- else cy.wrap($el).should('have.attr', 'data-app-id', 'dashboard')
- })
- })
- })
- describe('User theming set app order with default app', () => {
- let user: User
- before(() => {
- cy.resetAdminTheming()
- // install a third app
- installTestApp()
- // set files as default app
- cy.runOccCommand('config:system:set --value "files" defaultapp')
- // Create random user for this test
- cy.createRandomUser().then(($user) => {
- user = $user
- cy.login($user)
- })
- })
- after(() => {
- cy.deleteUser(user)
- uninstallTestApp()
- })
- it('See files is the default app', () => {
- cy.visit('/')
- cy.url().should('match', /apps\/files/)
- cy.get('.app-menu-main .app-menu-entry').each(($el, idx) => {
- if (idx === 0) cy.wrap($el).should('have.attr', 'data-app-id', 'files')
- })
- })
- it('See the app order settings: files is the first one', () => {
- cy.visit('/settings/user/theming')
- cy.get('[data-cy-app-order]').scrollIntoView()
- cy.get('[data-cy-app-order] [data-cy-app-order-element]').should('have.length', 4).each(($el, idx) => {
- if (idx === 0) cy.wrap($el).should('have.attr', 'data-cy-app-order-element', 'files')
- else if (idx === 1) cy.wrap($el).should('have.attr', 'data-cy-app-order-element', 'dashboard')
- })
- })
- it('Can not change the default app', () => {
- cy.get('[data-cy-app-order] [data-cy-app-order-element="files"] [data-cy-app-order-button="up"]').should('not.be.visible')
- cy.get('[data-cy-app-order] [data-cy-app-order-element="files"] [data-cy-app-order-button="down"]').should('not.be.visible')
- cy.get('[data-cy-app-order] [data-cy-app-order-element="dashboard"] [data-cy-app-order-button="up"]').should('not.be.visible')
- cy.get('[data-cy-app-order] [data-cy-app-order-element="dashboard"] [data-cy-app-order-button="down"]').should('be.visible')
- cy.get('[data-cy-app-order] [data-cy-app-order-element="testapp"] [data-cy-app-order-button="up"]').should('be.visible')
- cy.get('[data-cy-app-order] [data-cy-app-order-element="testapp"] [data-cy-app-order-button="down"]').should('not.be.visible')
- })
- it('Change the order of the other apps', () => {
- cy.get('[data-cy-app-order] [data-cy-app-order-element="testapp"] [data-cy-app-order-button="up"]').click()
- cy.get('[data-cy-app-order] [data-cy-app-order-element="testapp"] [data-cy-app-order-button="up"]').click()
- cy.get('[data-cy-app-order] [data-cy-app-order-element="testapp"] [data-cy-app-order-button="up"]').should('not.be.visible')
- cy.get('[data-cy-app-order] [data-cy-app-order-element]').each(($el, idx) => {
- if (idx === 0) cy.wrap($el).should('have.attr', 'data-cy-app-order-element', 'files')
- else if (idx === 1) cy.wrap($el).should('have.attr', 'data-cy-app-order-element', 'testapp')
- else if (idx === 2) cy.wrap($el).should('have.attr', 'data-cy-app-order-element', 'dashboard')
- })
- })
- it('See the app menu order is changed', () => {
- cy.reload()
- cy.get('.app-menu-main .app-menu-entry').each(($el, idx) => {
- if (idx === 0) cy.wrap($el).should('have.attr', 'data-app-id', 'files')
- else if (idx === 1) cy.wrap($el).should('have.attr', 'data-app-id', 'testapp')
- else if (idx === 2) cy.wrap($el).should('have.attr', 'data-app-id', 'dashboard')
- })
- })
- })
- describe('User theming app order list accessibility', () => {
- let user: User
- before(() => {
- cy.resetAdminTheming()
- // Create random user for this test
- cy.createRandomUser().then(($user) => {
- user = $user
- cy.login($user)
- })
- })
- after(() => {
- cy.deleteUser(user)
- })
- it('See the app order settings', () => {
- cy.visit('/settings/user/theming')
- cy.get('[data-cy-app-order]').scrollIntoView()
- cy.get('[data-cy-app-order] [data-cy-app-order-element]').should('have.length', 2)
- })
- it('click the first button', () => {
- cy.get('[data-cy-app-order] [data-cy-app-order-element="dashboard"] [data-cy-app-order-button="down"]').should('be.visible').focus()
- cy.get('[data-cy-app-order] [data-cy-app-order-element="dashboard"] [data-cy-app-order-button="down"]').click()
- })
- it('see the same app kept the focus', () => {
- cy.get('[data-cy-app-order] [data-cy-app-order-element="files"] [data-cy-app-order-button="down"]').should('not.have.focus')
- cy.get('[data-cy-app-order] [data-cy-app-order-element="files"] [data-cy-app-order-button="up"]').should('not.have.focus')
- cy.get('[data-cy-app-order] [data-cy-app-order-element="dashboard"] [data-cy-app-order-button="down"]').should('not.have.focus')
- cy.get('[data-cy-app-order] [data-cy-app-order-element="dashboard"] [data-cy-app-order-button="up"]').should('have.focus')
- })
- it('click the last button', () => {
- cy.get('[data-cy-app-order] [data-cy-app-order-element="dashboard"] [data-cy-app-order-button="up"]').should('be.visible').focus()
- cy.get('[data-cy-app-order] [data-cy-app-order-element="dashboard"] [data-cy-app-order-button="up"]').click()
- })
- it('see the same app kept the focus', () => {
- cy.get('[data-cy-app-order] [data-cy-app-order-element="files"] [data-cy-app-order-button="down"]').should('not.have.focus')
- cy.get('[data-cy-app-order] [data-cy-app-order-element="files"] [data-cy-app-order-button="up"]').should('not.have.focus')
- cy.get('[data-cy-app-order] [data-cy-app-order-element="dashboard"] [data-cy-app-order-button="up"]').should('not.have.focus')
- cy.get('[data-cy-app-order] [data-cy-app-order-element="dashboard"] [data-cy-app-order-button="down"]').should('have.focus')
- })
- })
- describe('User theming reset app order', () => {
- let user: User
- before(() => {
- cy.resetAdminTheming()
- // Create random user for this test
- cy.createRandomUser().then(($user) => {
- user = $user
- cy.login($user)
- })
- })
- after(() => cy.deleteUser(user))
- it('See the app order settings', () => {
- cy.visit('/settings/user/theming')
- cy.get('.settings-section').contains('Navigation bar settings').should('exist')
- cy.get('[data-cy-app-order]').scrollIntoView()
- })
- it('See that the dashboard app is the first one', () => {
- cy.get('[data-cy-app-order] [data-cy-app-order-element]').each(($el, idx) => {
- if (idx === 0) cy.wrap($el).should('have.attr', 'data-cy-app-order-element', 'dashboard')
- else cy.wrap($el).should('have.attr', 'data-cy-app-order-element', 'files')
- })
- cy.get('.app-menu-main .app-menu-entry').each(($el, idx) => {
- if (idx === 0) cy.wrap($el).should('have.attr', 'data-app-id', 'dashboard')
- else cy.wrap($el).should('have.attr', 'data-app-id', 'files')
- })
- })
- it('See the reset button is disabled', () => {
- cy.get('[data-test-id="btn-apporder-reset"]').scrollIntoView()
- cy.get('[data-test-id="btn-apporder-reset"]').should('be.visible').and('have.attr', 'disabled')
- })
- it('Change the app order', () => {
- cy.get('[data-cy-app-order] [data-cy-app-order-element="files"] [data-cy-app-order-button="up"]').should('be.visible')
- cy.get('[data-cy-app-order] [data-cy-app-order-element="files"] [data-cy-app-order-button="up"]').click()
- cy.get('[data-cy-app-order] [data-cy-app-order-element="files"] [data-cy-app-order-button="up"]').should('not.be.visible')
- cy.get('[data-cy-app-order] [data-cy-app-order-element]').each(($el, idx) => {
- if (idx === 0) cy.wrap($el).should('have.attr', 'data-cy-app-order-element', 'files')
- else cy.wrap($el).should('have.attr', 'data-cy-app-order-element', 'dashboard')
- })
- })
- it('See the reset button is no longer disabled', () => {
- cy.get('[data-test-id="btn-apporder-reset"]').scrollIntoView()
- cy.get('[data-test-id="btn-apporder-reset"]').should('be.visible').and('not.have.attr', 'disabled')
- })
- it('Reset the app order', () => {
- cy.get('[data-test-id="btn-apporder-reset"]').click({ force: true })
- })
- it('See the app order is restored', () => {
- cy.get('[data-cy-app-order] [data-cy-app-order-element]').each(($el, idx) => {
- if (idx === 0) cy.wrap($el).should('have.attr', 'data-cy-app-order-element', 'dashboard')
- else cy.wrap($el).should('have.attr', 'data-cy-app-order-element', 'files')
- })
- })
- it('See the reset button is disabled again', () => {
- cy.get('[data-test-id="btn-apporder-reset"]').should('be.visible').and('have.attr', 'disabled')
- })
- })
|