|
| 1 | +/** |
| 2 | + * @copyright Copyright (c) 2022 |
| 3 | + * |
| 4 | + * @license AGPL-3.0-or-later |
| 5 | + * |
| 6 | + * This program is free software: you can redistribute it and/or modify |
| 7 | + * it under the terms of the GNU Affero General Public License as |
| 8 | + * published by the Free Software Foundation, either version 3 of the |
| 9 | + * License, or (at your option) any later version. |
| 10 | + * |
| 11 | + * This program is distributed in the hope that it will be useful, |
| 12 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 13 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 14 | + * GNU Affero General Public License for more details. |
| 15 | + * |
| 16 | + * You should have received a copy of the GNU Affero General Public License |
| 17 | + * along with this program. If not, see <http://www.gnu.org/licenses/>. |
| 18 | + * |
| 19 | + */ |
| 20 | + |
| 21 | +import { initUserAndFiles, randUser } from '../../utils/index.js' |
| 22 | + |
| 23 | +const user = randUser() |
| 24 | + |
| 25 | +describe('Preview Options', function() { |
| 26 | + before(function() { |
| 27 | + initUserAndFiles(user, 'codeblock.md', 'empty.md') |
| 28 | + }) |
| 29 | + beforeEach(function() { |
| 30 | + cy.login(user) |
| 31 | + cy.isolateTest({ sourceFile: 'empty.md' }) |
| 32 | + cy.openFile('empty.md') |
| 33 | + cy.get('.entry-action__insert-link').click() |
| 34 | + cy.get('li').get('[data-text-action-entry="insert-link-website"]').click() |
| 35 | + cy.get('.input-field__input--trailing-icon').type('nextcloud.com') |
| 36 | + cy.get('.input-field__trailing-button').click() |
| 37 | + cy.get('.preview-options').click() |
| 38 | + }) |
| 39 | + |
| 40 | + it('should render previewOptions correctly', function() { |
| 41 | + cy.get('.action-button__text').contains('Remove link').should('be.visible') |
| 42 | + cy.get('.action-radio__label').each(el => { |
| 43 | + cy.wrap(el).invoke('text').should('match', /Text only|Show link preview/) |
| 44 | + }) |
| 45 | + }) |
| 46 | + |
| 47 | + it('should toggle to Link Preview', function() { |
| 48 | + cy.get('.preview').should('not.exist') |
| 49 | + cy.get('.action-radio__label').each(el => { |
| 50 | + cy.wrap(el).invoke('text').then(text => { |
| 51 | + if (text === 'Show link preview') { |
| 52 | + cy.wrap(el).click() |
| 53 | + } |
| 54 | + }) |
| 55 | + }) |
| 56 | + cy.get('.preview').should('be.visible') |
| 57 | + }) |
| 58 | + |
| 59 | + it('should Remove link', function() { |
| 60 | + cy.get('.paragraph-content').should('have.text', 'nextcloud.com') |
| 61 | + cy.get('.action-button__text').contains('Remove link').click() |
| 62 | + cy.get('.paragraph-content').should('not.have.text', 'nextcloud.com') |
| 63 | + }) |
| 64 | +}) |
0 commit comments