|
| 1 | +/** |
| 2 | + * @copyright Copyright (c) 2021 Louis Chemineau <louis@chmn.me> |
| 3 | + * |
| 4 | + * @author Louis Chemineau <louis@chmn.me> |
| 5 | + * |
| 6 | + * @license GNU AGPL version 3 or any later version |
| 7 | + * |
| 8 | + * This program is free software: you can redistribute it and/or modify |
| 9 | + * it under the terms of the GNU Affero General Public License as |
| 10 | + * published by the Free Software Foundation, either version 3 of the |
| 11 | + * License, or (at your option) any later version. |
| 12 | + * |
| 13 | + * This program is distributed in the hope that it will be useful, |
| 14 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 15 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 16 | + * GNU Affero General Public License for more details. |
| 17 | + * |
| 18 | + * You should have received a copy of the GNU Affero General Public License |
| 19 | + * along with this program. If not, see <http://www.gnu.org/licenses/>. |
| 20 | + * |
| 21 | + */ |
| 22 | + |
| 23 | +/// <reference types="Cypress" /> |
| 24 | + |
| 25 | +Cypress.Commands.add('createFolder', dirName => { |
| 26 | + cy.get('.files-controls .actions > .button.new').click() |
| 27 | + cy.get('.files-controls .actions .newFileMenu a[data-action="folder"]').click() |
| 28 | + cy.get('.files-controls .actions .newFileMenu a[data-action="folder"] input[type="text"]').type(dirName) |
| 29 | + cy.get('.files-controls .actions .newFileMenu a[data-action="folder"] input.icon-confirm').click() |
| 30 | + cy.log('Created folder', dirName) |
| 31 | + cy.wait(500) |
| 32 | +}) |
| 33 | + |
| 34 | +Cypress.Commands.add('moveFile', (fileName, dirName) => { |
| 35 | + cy.get(`.files-fileList tr[data-file="${fileName}"] .icon-more`).click() |
| 36 | + cy.get(`.files-fileList tr[data-file="${fileName}"] .action-movecopy`).click() |
| 37 | + cy.get(`.oc-dialog tr[data-entryname="${dirName}"]`).click() |
| 38 | + cy.contains(`Move to ${dirName}`).click() |
| 39 | + cy.wait(500) |
| 40 | +}) |
| 41 | + |
| 42 | +Cypress.Commands.add('showSidebarForFile', fileName => { |
| 43 | + cy.hideSidebar('welcome.txt') |
| 44 | + cy.get('.files-fileList tr[data-file="welcome.txt"] .icon-more').click() |
| 45 | + cy.contains('Details').click() |
| 46 | + cy.get('#app-sidebar-vue').contains('Activity').click() |
| 47 | +}) |
| 48 | + |
| 49 | +Cypress.Commands.add('hideSidebar', fileName => { |
| 50 | + cy.get('body') |
| 51 | + .then(($body) => { |
| 52 | + if ($body.find('.app-sidebar__close').length !== 0) { |
| 53 | + cy.get('.app-sidebar__close').click() |
| 54 | + } |
| 55 | + }) |
| 56 | +}) |
| 57 | + |
| 58 | +Cypress.Commands.add('showActivityTab', fileName => { |
| 59 | + cy.showSidebarForFile() |
| 60 | + cy.get('#app-sidebar-vue').contains('Activity').click() |
| 61 | +}) |
| 62 | + |
| 63 | +Cypress.Commands.add('addToFavorites', fileName => { |
| 64 | + cy.get(`.files-fileList tr[data-file="${fileName}"] .icon-more`).click() |
| 65 | + cy.contains('Add to favorites').click() |
| 66 | +}) |
| 67 | + |
| 68 | +Cypress.Commands.add('removeFromFavorites', fileName => { |
| 69 | + cy.get(`.files-fileList tr[data-file="${fileName}"] .icon-more`).click() |
| 70 | + cy.contains('Remove from favorites').click() |
| 71 | +}) |
| 72 | + |
| 73 | +Cypress.Commands.add('createPublicShare', fileName => { |
| 74 | + cy.get(`.files-fileList tr[data-file="${fileName}"] .icon-more`).click() |
| 75 | + cy.contains('Details').click() |
| 76 | + cy.get('#app-sidebar-vue').contains('Sharing').click() |
| 77 | + |
| 78 | + cy.get('#app-sidebar-vue a#sharing').trigger('click') |
| 79 | + cy.get('#app-sidebar-vue button.new-share-link').trigger('click') |
| 80 | + cy.get('#app-sidebar-vue a.sharing-entry__copy') |
| 81 | +}) |
| 82 | + |
| 83 | +Cypress.Commands.add('renameFile', (fileName, newName) => { |
| 84 | + cy.get(`.files-fileList tr[data-file="${fileName}"] .icon-more`).click() |
| 85 | + cy.get(`.files-fileList tr[data-file="${fileName}"] .action-rename`).click() |
| 86 | + cy.get(`.files-fileList tr[data-file="${fileName}"] input.filename`).type(newName).parent().submit() |
| 87 | + cy.wait(500) |
| 88 | +}) |
| 89 | + |
| 90 | +Cypress.Commands.add('goToDir', (dirName) => { |
| 91 | + cy.get(`.files-fileList tr[data-file="${dirName}"]`).click() |
| 92 | + cy.wait(500) |
| 93 | +}) |
| 94 | + |
| 95 | +Cypress.Commands.add('addTag', (fileName, tag) => { |
| 96 | + cy.showSidebarForFile('welcome.txt') |
| 97 | + |
| 98 | + cy.get('.app-sidebar-header__menu .action-item__menutoggle').click() |
| 99 | + cy.get('.action-button__icon.icon-tag').click() |
| 100 | + cy.get('.systemTagsInputField input').type('my_tag{enter}{esc}') |
| 101 | + |
| 102 | + cy.wait(500) |
| 103 | +}) |
| 104 | + |
| 105 | +Cypress.Commands.add('addComment', (fileName, comment) => { |
| 106 | + cy.showSidebarForFile('welcome.txt') |
| 107 | + cy.get('#app-sidebar-vue').contains('Comments').click() |
| 108 | + cy.get('.comment__editor .rich-contenteditable__input').type(comment) |
| 109 | + cy.get('button.comment__submit').click() |
| 110 | + |
| 111 | + cy.wait(500) |
| 112 | +}) |
0 commit comments