|
| 1 | +/** |
| 2 | + * SPDX-FileCopyrightText: 2022 Nextcloud GmbH and Nextcloud contributors |
| 3 | + * SPDX-License-Identifier: AGPL-3.0-or-later |
| 4 | + */ |
| 5 | + |
| 6 | +import { randUser } from '../utils/index.js' |
| 7 | +const user = randUser() |
| 8 | + |
| 9 | +const testPlainInputRule = (chars, expected) => { |
| 10 | + cy.getContent().type(chars) |
| 11 | + cy.getContent().should('contain', expected) |
| 12 | + return cy.closeFile() |
| 13 | +} |
| 14 | + |
| 15 | +describe('input rules', () => { |
| 16 | + before(() => { |
| 17 | + cy.createUser(user) |
| 18 | + }) |
| 19 | + |
| 20 | + beforeEach(() => { |
| 21 | + cy.login(user) |
| 22 | + cy.uploadTestFile() |
| 23 | + cy.visit('/apps/files') |
| 24 | + cy.openTestFile() |
| 25 | + }) |
| 26 | + |
| 27 | + it('unordered list item', () => { |
| 28 | + cy.getContent().type('* item') |
| 29 | + cy.getContent().find('ul').find('li').should('contain', 'item') |
| 30 | + cy.closeFile() |
| 31 | + }) |
| 32 | + |
| 33 | + it('ordered list item', () => { |
| 34 | + cy.getContent().type('1. item') |
| 35 | + cy.getContent().find('ol').find('li').should('contain', 'item') |
| 36 | + cy.closeFile() |
| 37 | + }) |
| 38 | + |
| 39 | + it('task list item', () => { |
| 40 | + cy.getContent().type('* [] item') |
| 41 | + cy.getContent().find('ul').find('li').find('input[type="checkbox"]') |
| 42 | + cy.getContent().find('ul').find('li').should('contain', 'item') |
| 43 | + cy.closeFile() |
| 44 | + }) |
| 45 | + |
| 46 | + it('blockquote', () => { |
| 47 | + cy.getContent().type('> quote') |
| 48 | + cy.getContent().find('blockquote').should('contain', 'uote') |
| 49 | + cy.closeFile() |
| 50 | + }) |
| 51 | + |
| 52 | + it('codeblock', () => { |
| 53 | + cy.getContent().type('```{enter}code') |
| 54 | + cy.getContent().find('pre').should('contain', 'code') |
| 55 | + cy.closeFile() |
| 56 | + }) |
| 57 | + |
| 58 | + it('inline code', () => { |
| 59 | + cy.getContent().type('`code`') |
| 60 | + cy.getContent().find('code').should('contain', 'code') |
| 61 | + cy.closeFile() |
| 62 | + }) |
| 63 | + |
| 64 | + it('link', () => { |
| 65 | + cy.getContent().type('[link](https://nextcloud.com/)') |
| 66 | + cy.getContent().find('a').should('contain', 'link') |
| 67 | + cy.closeFile() |
| 68 | + }) |
| 69 | + |
| 70 | + it('emoji', () => testPlainInputRule(':+1{enter}', '👍')) |
| 71 | + |
| 72 | + it('typography: ellipsis', () => testPlainInputRule('...', '…')) |
| 73 | + it('typography: copyright', () => testPlainInputRule('(c)', '©')) |
| 74 | + it('typography: oneHalf', () => testPlainInputRule('1/2 ', '½')) |
| 75 | + it('typography: superscriptTwo', () => testPlainInputRule('^2', '²')) |
| 76 | + it('typography: emDash', () => testPlainInputRule('-- ', '—')) |
| 77 | + it('typography: leftArrow', () => testPlainInputRule('<- ', '←')) |
| 78 | + it('typography: rightArrow', () => testPlainInputRule('->', '→')) |
| 79 | + it('typography: leftRightArrow', () => testPlainInputRule('<->', '↔')) |
| 80 | + it('typography: leftRightDoubleArrow', () => testPlainInputRule('<=>', '⇔')) |
| 81 | + it('typography: leftRightLongArrow', () => testPlainInputRule('<-->', '⟷')) |
| 82 | +}) |
0 commit comments