Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nextcloud/text.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJulien Veyssier <eneiluj@posteo.net>2022-01-06 19:33:23 +0300
committerJulien Veyssier <eneiluj@posteo.net>2022-01-07 12:53:00 +0300
commit3f1813437aeea07d3b60aa95db7489b209376a73 (patch)
tree6648946bafe2274f926bff02c33475481a2fba74 /cypress
parent01561918a227f220b4614493c0763f3d0e6116a9 (diff)
refs #2049 cypress test: insert image from files
Signed-off-by: Julien Veyssier <eneiluj@posteo.net>
Diffstat (limited to 'cypress')
-rw-r--r--cypress/fixtures/github.pngbin0 -> 627 bytes
-rw-r--r--cypress/integration/images.spec.js97
2 files changed, 97 insertions, 0 deletions
diff --git a/cypress/fixtures/github.png b/cypress/fixtures/github.png
new file mode 100644
index 000000000..f094efcd6
--- /dev/null
+++ b/cypress/fixtures/github.png
Binary files differ
diff --git a/cypress/integration/images.spec.js b/cypress/integration/images.spec.js
new file mode 100644
index 000000000..74407671b
--- /dev/null
+++ b/cypress/integration/images.spec.js
@@ -0,0 +1,97 @@
+/**
+ * @copyright Copyright (c) 2021 Julien Veyssier <eneiluj@posteo.net>
+ *
+ * @author Julien Veyssier <eneiluj@posteo.net>
+ *
+ * @license GNU AGPL version 3 or any later version
+ *
+ * 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 { randHash } from '../utils/'
+const randUser = randHash()
+
+describe('Open test.md in viewer', function() {
+ before(function() {
+ // Init user
+ cy.nextcloudCreateUser(randUser, 'password')
+ cy.login(randUser, 'password')
+
+ // Upload test files
+ cy.uploadFile('test.md', 'text/markdown')
+ cy.uploadFile('github.png', 'image/png')
+ })
+
+ beforeEach(function() {
+ cy.login(randUser, 'password')
+ })
+
+ it('See test.md in the list', function() {
+ cy.get('#fileList tr[data-file="test.md"]', { timeout: 10000 })
+ .should('contain', 'test.md')
+ })
+
+ it('Insert an image from files', function() {
+ cy.openFile('test.md')
+
+ cy.log('Open submenu')
+ const viewer = cy.get('#viewer')
+ const submenu = viewer.get('.action-item.submenu')
+ submenu.click()
+ submenu.should('have.class', 'action-item--open')
+
+ const trigger = submenu.get('.action-item.submenu > div.v-popover > .trigger')
+ trigger
+ .should('have.class', 'trigger')
+ .invoke('attr','aria-describedby')
+ .should('contain', 'popover_')
+ .as('popoverId')
+
+ cy.get('@popoverId').then(popoverId => {
+ cy.log('Click on action entry')
+ const popover = cy.get('div#' + popoverId)
+ popover.should('have.class', 'open')
+ cy.get('div#' + popoverId + ' li:nth-child(2)').click()
+ cy.log('Select the file')
+ cy.get('#picker-filestable tr[data-entryname="github.png"]').click()
+ cy.log('Press OK')
+ cy.get('.oc-dialog > .oc-dialog-buttonrow button').click()
+
+ cy.log('Check the image is visible and well formed')
+ const editor = cy.get('#editor .ProseMirror')
+ editor.should('contain', 'Hello world')
+ editor.get('h2').should('contain', 'Hello world')
+ editor.get('div.image')
+ .should('be.visible')
+ .invoke('attr', 'data-src')
+ .should('contain', 'github.png')
+ editor.get('div.image img').invoke('attr', 'src')
+ .should('contain', 'apps/text/image?documentId=')
+ .should('contain', 'imageFileName')
+ .should('contain', 'github.png')
+ })
+
+
+ cy.screenshot()
+ })
+
+ it('Closes the editor', function() {
+ cy.openFile('test.md')
+ cy.get('#viewer .modal-header button.header-close').click()
+ cy.get('#viewer').should('not.exist')
+ })
+
+})