Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

use filelist PROPFIND for loading workspace #2193

Merged
merged 8 commits into from
Mar 2, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion .github/workflows/cypress.yml
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,6 @@ jobs:
export OC_PASS=1234561
php occ user:add --password-from-env user1
php occ user:add --password-from-env user2
php occ config:system:set force_language --value en
php occ app:enable viewer
php occ app:enable text
php occ app:list
Expand Down
36 changes: 14 additions & 22 deletions cypress/integration/share.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,30 +31,23 @@ describe('Open test.md in viewer', function() {
cy.nextcloudCreateUser(randUser, 'password')
cy.login(randUser, 'password')

// 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
})

// Upload test files
cy.createFolder('folder')
cy.uploadFile('test.md', 'text/markdown', 'folder/test.md')
cy.uploadFile('test.md', 'text/markdown', 'folder/Readme.md')
cy.uploadFile('test.md', 'text/markdown', 'test2.md')
cy.uploadFile('test.md', 'text/markdown')
cy.wait(1000)
cy.visit('/apps/files')
cy.get('#fileList tr[data-file="test.md"]', {timeout: 10000})
cy.get('#fileList tr[data-file="test.md"]')
.should('contain', 'test.md')
})
beforeEach(function() {
cy.login(randUser, 'password')
})

it('Shares the file as a public read only link', function () {
cy.visit('/apps/files', { timeout: 10000 })
cy.get('#fileList tr[data-file="test.md"] a.action-share', { timeout: 10000 })
cy.visit('/apps/files')
cy.get('#fileList tr[data-file="test.md"] a.action-share')
.click({force: true})
cy.get('#app-sidebar-vue')
.should('be.visible')
Expand All @@ -66,8 +59,7 @@ describe('Open test.md in viewer', function() {
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').should('be.visible')
cy.get('#editor .ProseMirror').should('contain', 'Hello world')
cy.get('#editor .ProseMirror h2').should('contain', 'Hello world')
})
Expand All @@ -76,7 +68,7 @@ describe('Open test.md in viewer', function() {

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})
cy.get('#fileList tr[data-file="test2.md"] a.action-share')
.click({force: true})
cy.get('#app-sidebar-vue')
.should('be.visible')
Expand All @@ -85,14 +77,14 @@ describe('Open test.md in viewer', function() {
cy.get('#app-sidebar-vue .sharing-link-list .action-item__menutoggle').trigger('click')
const checkboxAllowEditing = '.popover.open input[type=checkbox]'
cy.get(checkboxAllowEditing).first().check({ force: true })
cy.get(checkboxAllowEditing, { timeout: 4000 }).first().should('be.checked')
cy.get(checkboxAllowEditing).first().should('be.checked')
cy.get('#app-sidebar-vue 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.get('#editor', {timeout: 10000}).should('be.visible')
cy.get('#editor').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')
Expand All @@ -104,7 +96,7 @@ describe('Open test.md in viewer', function() {

it('Opens the editor as guest', function () {
cy.visit('/apps/files')
cy.get('#fileList tr[data-file="test2.md"] a.action-share', {timeout: 10000})
cy.get('#fileList tr[data-file="test2.md"] a.action-share')
.click({force: true})
cy.get('#app-sidebar-vue')
.should('be.visible')
Expand All @@ -117,7 +109,7 @@ describe('Open test.md in viewer', function() {
cy.window().then(win => {
win.OC.appswebroots['files_texteditor'] = true
cy.wait(1000)
cy.get('#editor', {timeout: 10000}).should('be.visible')
cy.get('#editor').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')
Expand All @@ -128,8 +120,8 @@ describe('Open test.md in viewer', function() {
})

it('Shares a folder as a public read only link', function () {
cy.visit('/apps/files', { timeout: 10000 })
cy.get('#fileList tr[data-file="folder"] a.action-share', {timeout: 10000})
cy.visit('/apps/files')
cy.get('#fileList tr[data-file="folder"] a.action-share')
.click({force: true})
cy.get('#app-sidebar-vue')
.should('be.visible')
Expand All @@ -141,9 +133,9 @@ describe('Open test.md in viewer', function() {
cy.visit(href)
cy.window().then(win => {
win.OC.appswebroots['files_texteditor'] = true
cy.wait(1000)
cy.get('#rich-workspace').should('contain', 'Hello world')
cy.openFile('test.md')
cy.get('#editor-container', { timeout: 4000 }).should('be.visible')
cy.get('#editor-container').should('be.visible')
cy.get('#editor .ProseMirror').should('contain', 'Hello world')
cy.get('#editor .ProseMirror h2').should('contain', 'Hello world')
})
Expand Down
30 changes: 27 additions & 3 deletions cypress/integration/workspace.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,9 @@ describe('Workspace', function() {

beforeEach(function() {
cy.login(randUser, 'password')
cy.visit('/apps/files')
// isolate tests - each happens in it's own folder
cy.createFolder(Cypress.currentTest.title)
cy.openFile(Cypress.currentTest.title)
cy.visit(`apps/files?dir=/${encodeURIComponent(Cypress.currentTest.title)}`)
})

it('adds a Readme.md', function() {
Expand Down Expand Up @@ -105,6 +104,31 @@ describe('Workspace', function() {
})
})

it('takes README.md into account', function() {
cy.uploadFile('test.md', 'text/markdown', `${Cypress.currentTest.title}/README.md`)
cy.reload()
cy.get('#fileList').should('contain', 'README.md')
cy.get('#rich-workspace .ProseMirror')
.should('contain', 'Hello world')
})

it('takes localized file name into account', function() {
cy.nextcloudUpdateUser(randUser, 'password', 'language', 'de_DE')
cy.uploadFile('test.md', 'text/markdown', `${Cypress.currentTest.title}/Anleitung.md`)
cy.reload()
cy.get('#fileList').should('contain', 'Anleitung.md')
cy.get('#rich-workspace .ProseMirror')
.should('contain', 'Hello world')
})

it('ignores localized file name in other language', function() {
cy.nextcloudUpdateUser(randUser, 'password', 'language', 'fr')
cy.uploadFile('test.md', 'text/markdown', `${Cypress.currentTest.title}/Anleitung.md`)
cy.reload()
cy.get('#fileList').should('contain', 'Anleitung.md')
cy.get('.empty-workspace').should('contain', 'Ajoutez des notes, listes ou liens')
})

})

const menuButton = (name) => {
Expand All @@ -118,7 +142,7 @@ const submenuButton = (name) => {
const menuBubbleButton = submenuButton

const openWorkspace = () => {
cy.get('#rich-workspace').click()
cy.get('#rich-workspace .empty-workspace').click()
cy.get('#editor .content-wrapper').click()
return cy.get('#rich-workspace .ProseMirror')
}
1 change: 0 additions & 1 deletion cypress/server.sh
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
#!/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
Expand Down
24 changes: 19 additions & 5 deletions cypress/support/commands.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,22 @@ Cypress.Commands.add('nextcloudCreateUser', (user, password) => {
})
})

Cypress.Commands.add('nextcloudUpdateUser', (user, password, key, value) => {
cy.request({
method: 'PUT',
url: `${Cypress.env('baseUrl')}/ocs/v2.php/cloud/users/${user}`,
form: true,
body: { key, value },
auth: { user, pass: password },
headers: {
'OCS-ApiRequest': 'true',
'Content-Type': 'application/x-www-form-urlencoded',
}
}).then(response => {
cy.log(`Updated user ${user} ${key} to ${value}`, response.status)
})
})

Cypress.Commands.add('nextcloudDeleteUser', (user) => {
cy.clearCookies()
cy.request({
Expand Down Expand Up @@ -100,11 +116,9 @@ Cypress.Commands.add('uploadFile', (fileName, mimeType, target) => {
})

Cypress.Commands.add('createFolder', dirName => {
cy.get('#controls .actions > .button.new').click()
cy.get('#controls .actions .newFileMenu a[data-action="folder"]').click()
cy.get('#controls .actions .newFileMenu a[data-action="folder"] input[type="text"]').type(dirName)
cy.get('#controls .actions .newFileMenu a[data-action="folder"] input.icon-confirm').click()
cy.log('Created folder', dirName)
cy.window().then( win => {
win.OC.Files.getClient().createDirectory(dirName)
})
})

Cypress.Commands.add('openFile', fileName => {
Expand Down
4 changes: 2 additions & 2 deletions js/editor-rich.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion js/editor-rich.js.map

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions js/editor.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion js/editor.js.map

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions js/files-modal.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion js/files-modal.js.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions js/text-files.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion js/text-files.js.map

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions js/text-public.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion js/text-public.js.map

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions js/text-text.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion js/text-text.js.map

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions js/text-viewer.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion js/text-viewer.js.map

Large diffs are not rendered by default.

Loading