зеркало из https://github.com/nextcloud/text.git
Add public share page tests
Signed-off-by: Julius Härtl <jus@bitgrid.net>
This commit is contained in:
Родитель
08386c96cf
Коммит
522efa4d9d
|
@ -3,3 +3,5 @@ build/
|
|||
node_modules/
|
||||
vendor/
|
||||
img/twemoji/
|
||||
cypress/screenshots/
|
||||
cypress/videos/
|
||||
|
|
|
@ -0,0 +1 @@
|
|||
APP_SOURCE=/home/runner/work/text/text
|
|
@ -9,6 +9,6 @@ services:
|
|||
- 8081:80
|
||||
environment:
|
||||
CYPRESS_baseUrl:
|
||||
APP_SOURCE: /home/runner/work/text/text
|
||||
APP_SOURCE:
|
||||
volumes:
|
||||
- $APP_SOURCE:/var/www/html/apps/text
|
||||
- ${APP_SOURCE}:/var/www/html/apps/text
|
||||
|
|
|
@ -0,0 +1,126 @@
|
|||
|
||||
|
||||
/*
|
||||
* @copyright Copyright (c) 2020 Julius Härtl <jus@bitgrid.net>
|
||||
*
|
||||
* @author Julius Härtl <jus@bitgrid.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('test.md', 'text/markdown', 'test2.md')
|
||||
cy.visit('/apps/files')
|
||||
cy.get('#fileList tr[data-file="test.md"]', {timeout: 10000})
|
||||
.should('contain', 'test.md')
|
||||
|
||||
// FIXME: files app is thowing the following error for some reason
|
||||
// Uncaught TypeError: Cannot read property 'protocol' of undefined
|
||||
// Same for appswebroots setting in tests
|
||||
cy.on('uncaught:exception', (err, runnable) => {
|
||||
return false
|
||||
})
|
||||
})
|
||||
after(function () {
|
||||
cy.visit('/apps/files')
|
||||
cy.logout()
|
||||
})
|
||||
|
||||
it('Shares the file as a public read only link', function () {
|
||||
cy.visit('/apps/files')
|
||||
cy.get('#fileList tr[data-file="test.md"] a.action-share', {timeout: 10000}).trigger('click')
|
||||
cy.get('#app-sidebar')
|
||||
.should('be.visible')
|
||||
cy.get('#app-sidebar a#sharing').trigger('click')
|
||||
cy.get('#app-sidebar button.new-share-link').trigger('click')
|
||||
cy.get('#app-sidebar a.sharing-entry__copy')
|
||||
.should('have.attr', 'href').and('include', '/s/')
|
||||
.then((href) => {
|
||||
cy.visit(href)
|
||||
cy.window().then(win => {
|
||||
win.OC.appswebroots['files_texteditor'] = true
|
||||
cy.wait(1000)
|
||||
cy.get('#editor', { timeout: 4000 }).should('be.visible')
|
||||
cy.get('#editor .ProseMirror').should('contain', 'Hello world')
|
||||
cy.get('#editor .ProseMirror h2').should('contain', 'Hello world')
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
it('Shares the file as a public link with write permissions', function () {
|
||||
cy.visit('/apps/files')
|
||||
cy.get('#fileList tr[data-file="test2.md"] a.action-share', {timeout: 10000}).trigger('click')
|
||||
cy.get('#app-sidebar')
|
||||
.should('be.visible')
|
||||
cy.get('#app-sidebar a#sharing').trigger('click')
|
||||
cy.get('#app-sidebar button.new-share-link').trigger('click')
|
||||
cy.get('#app-sidebar .sharing-link-list .action-item__menutoggle').trigger('click')
|
||||
cy.get('#app-sidebar .sharing-link-list .action-item__menu input[type=checkbox]').first().check({ force: true })
|
||||
cy.get('#app-sidebar .sharing-link-list .action-item__menu input[type=checkbox]', { timeout: 4000 }).first().should('be.checked')
|
||||
cy.get('#app-sidebar a.sharing-entry__copy')
|
||||
.should('have.attr', 'href').and('include', '/s/')
|
||||
.then((href) => {
|
||||
cy.visit(href)
|
||||
cy.window().then(win => {
|
||||
win.OC.appswebroots['files_texteditor'] = true
|
||||
cy.wait(1000)
|
||||
cy.get('#editor', {timeout: 10000}).should('be.visible')
|
||||
cy.get('#editor .ProseMirror').should('contain', 'Hello world')
|
||||
cy.get('#editor .ProseMirror h2').should('contain', 'Hello world')
|
||||
cy.get('#editor .menubar .menubar-icons .icon-undo').should('be.visible')
|
||||
cy.get('#editor .menubar .menubar-icons .icon-redo').should('be.visible')
|
||||
cy.get('#editor .menubar .menubar-icons .icon-bold').should('be.visible')
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
it('Opens the editor as guest', function () {
|
||||
cy.visit('/apps/files')
|
||||
cy.get('#fileList tr[data-file="test2.md"] a.action-share', {timeout: 10000}).trigger('click')
|
||||
cy.get('#app-sidebar')
|
||||
.should('be.visible')
|
||||
cy.get('#app-sidebar a#sharing').trigger('click')
|
||||
cy.get('#app-sidebar a.sharing-entry__copy')
|
||||
.should('have.attr', 'href').and('include', '/s/')
|
||||
.then((href) => {
|
||||
cy.logout()
|
||||
cy.visit(href)
|
||||
cy.window().then(win => {
|
||||
win.OC.appswebroots['files_texteditor'] = true
|
||||
cy.wait(1000)
|
||||
cy.get('#editor', {timeout: 10000}).should('be.visible')
|
||||
cy.get('#editor .ProseMirror').should('contain', 'Hello world')
|
||||
cy.get('#editor .ProseMirror h2').should('contain', 'Hello world')
|
||||
cy.get('#editor .menubar .menubar-icons .icon-undo').should('be.visible')
|
||||
cy.get('#editor .menubar .menubar-icons .icon-redo').should('be.visible')
|
||||
cy.get('#editor .menubar .menubar-icons .icon-bold').should('be.visible')
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
|
||||
})
|
|
@ -1,6 +1,7 @@
|
|||
#!/bin/bash
|
||||
git clone https://github.com/nextcloud/viewer /var/www/html/apps/viewer
|
||||
su www-data -c "
|
||||
php occ config:system:set force_language --value en
|
||||
php /var/www/html/occ app:enable viewer
|
||||
php /var/www/html/occ app:enable text
|
||||
php /var/www/html/occ app:list
|
||||
|
|
|
@ -62,18 +62,20 @@ Cypress.Commands.add('nextcloudCreateUser', (user, password) => {
|
|||
headers: {
|
||||
'OCS-ApiRequest': 'true',
|
||||
'Content-Type': 'application/x-www-form-urlencoded',
|
||||
Authorization: 'Basic YWRtaW46YWRtaW4='
|
||||
}
|
||||
}).then(response => {
|
||||
cy.log(`Created user ${user}`, response.status)
|
||||
})
|
||||
})
|
||||
|
||||
Cypress.Commands.add('uploadFile', (fileName, mimeType) => {
|
||||
Cypress.Commands.add('uploadFile', (fileName, mimeType, target) => {
|
||||
cy.fixture(fileName, 'base64')
|
||||
.then(Cypress.Blob.base64StringToBlob)
|
||||
.then(async blob => {
|
||||
const file = new File([blob], fileName, { type: mimeType })
|
||||
if (typeof target !== 'undefined') {
|
||||
fileName = target
|
||||
}
|
||||
await cy.window().then(async window => {
|
||||
await axios.put(`${Cypress.env('baseUrl')}/remote.php/webdav/${fileName}`, file, {
|
||||
headers: {
|
||||
|
|
Загрузка…
Ссылка в новой задаче