Skip to content

Commit 9978ad8

Browse files
authored
Merge branch 'stable29' into automated/noid/stable29-fix-npm-audit
2 parents 37e2f21 + 78daf1c commit 9978ad8

File tree

8 files changed

+63
-22
lines changed

8 files changed

+63
-22
lines changed

cypress/e2e/open.spec.js

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -56,10 +56,8 @@ describe('Open existing office files', function() {
5656
// Share action
5757
cy.wait(2000)
5858
cy.get('@loleafletframe').within(() => {
59-
cy.get('#main-menu #menu-file > a').click()
60-
cy.get('#main-menu #menu-shareas > a').should('be.visible').click()
59+
cy.verifyOpen(filename)
6160
})
62-
cy.verifyOpen(filename)
6361

6462
// FIXME: wait for sidebar tab content
6563
// FIXME: validate sharing tab
@@ -84,9 +82,8 @@ describe('Open existing office files', function() {
8482

8583
cy.screenshot('open-file_' + filename)
8684
cy.get('@loleafletframe').within(() => {
87-
cy.get('button.icon-nextcloud-sidebar').click()
85+
cy.verifyOpen(filename)
8886
})
89-
cy.verifyOpen(filename)
9087
// FIXME: wait for sidebar tab content
9188
// FIXME: validate sharing tab
9289
cy.screenshot('share-sidebar_' + filename)
@@ -148,9 +145,8 @@ describe('Open PDF with richdocuments', () => {
148145

149146
// Verify that the correct file is open
150147
cy.get('@loleafletframe').within(() => {
151-
cy.get('button.icon-nextcloud-sidebar').click()
148+
cy.verifyOpen('document.pdf')
152149
})
153-
cy.verifyOpen('document.pdf')
154150

155151
// Make sure we can close the document
156152
cy.closeDocument()

cypress/support/commands.js

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -307,11 +307,9 @@ Cypress.Commands.add('closeDocument', () => {
307307
})
308308

309309
Cypress.Commands.add('verifyOpen', (filename) => {
310-
cy.get('#app-sidebar-vue')
311-
.should('be.visible')
312-
cy.get('.app-sidebar-header__mainname')
313-
.should('be.visible')
314-
.should('contain.text', filename)
310+
cy.get('input#document-name-input').should(($docName) => {
311+
expect($docName.val()).to.equal(filename)
312+
})
315313
})
316314

317315
Cypress.Commands.add('uploadSystemTemplate', () => {

lib/Controller/WopiController.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -606,8 +606,7 @@ public function postFile(string $fileId, string $access_token): JSONResponse {
606606
$suggested = $this->request->getHeader('X-WOPI-RequestedName');
607607
$suggested = mb_convert_encoding($suggested, 'utf-8', 'utf-7') . '.' . $file->getExtension();
608608

609-
$parent = $isPublic ? dirname($file->getPath()) : $userFolder->getPath();
610-
$path = $this->normalizePath($suggested, $parent);
609+
$path = $this->normalizePath($suggested, dirname($file->getPath()));
611610

612611
if ($path === '') {
613612
return new JSONResponse([

package-lock.json

Lines changed: 7 additions & 7 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@
5151
"@cypress/webpack-preprocessor": "^6.0.2",
5252
"@nextcloud/babel-config": "^1.0.0",
5353
"@nextcloud/browserslist-config": "^3.0.1",
54-
"@nextcloud/cypress": "^1.0.0-beta.13",
54+
"@nextcloud/cypress": "^1.0.0-beta.14",
5555
"@nextcloud/eslint-config": "^8.3.0",
5656
"@nextcloud/stylelint-config": "^2.4.0",
5757
"@nextcloud/webpack-vue-config": "^6.1.1",

tests/features/bootstrap/RichDocumentsContext.php

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -232,4 +232,17 @@ public function updateTheGuestDisplayName($displayName) {
232232
'guestName' => $displayName,
233233
], [ 'auth' => null ]);
234234
}
235+
236+
/**
237+
* @Given /^as "([^"]*)" rename "([^"]*)" to "([^"]*)"$/
238+
*/
239+
public function renameFileTo($user, $file, $newName) {
240+
$this->serverContext->usingWebAsUser($user);
241+
$davClient = $this->filesContext->getSabreClient($user);
242+
$path = $this->filesContext->makeSabrePath($user, $file);
243+
$result = $davClient->propFind($path, ['{http://owncloud.org/ns}fileid']);
244+
$fileId = $result['{http://owncloud.org/ns}fileid'];
245+
246+
$this->wopiContext->collaboraRenamesTo($fileId, $newName);
247+
}
235248
}

tests/features/bootstrap/WopiContext.php

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -316,4 +316,21 @@ public function collaboraSavesTheFileAs($source, $newName) {
316316
$this->response = $e->getResponse();
317317
}
318318
}
319+
320+
public function collaboraRenamesTo($fileId, $newName) {
321+
$client = new Client();
322+
$options = [
323+
'headers' => [
324+
'X-LOOL-WOPI-Timestamp' => $this->checkFileInfoResult['LastModifiedTime'],
325+
'X-WOPI-RequestedName' => $newName,
326+
'X-WOPI-Override' => 'RENAME_FILE',
327+
],
328+
];
329+
330+
try {
331+
$this->response = $client->post($this->getWopiEndpointBaseUrl() . 'index.php/apps/richdocuments/wopi/files/' . $fileId . '?access_token=' . $this->wopiToken, $options);
332+
} catch (\GuzzleHttp\Exception\ClientException $e) {
333+
$this->response = $e->getResponse();
334+
}
335+
}
319336
}

tests/features/wopi.feature

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -358,3 +358,21 @@ Feature: WOPI
358358
And Collabora saves the content of "./../emptyTemplates/template.ods" as "/saved-as-guest-document.odt"
359359
And as "user1" the file "/SharedFolder/saved-as-guest-document.odt" exists
360360
And as "user1" the file "/saved-as-guest-document.odt" does not exist
361+
362+
Scenario: Rename file on share link
363+
Given as user "user1"
364+
365+
And User "user1" creates a folder "/SharedFolder"
366+
And User "user1" uploads file "./../emptyTemplates/template.odt" to "/SharedFolder/file.odt"
367+
And as "user1" create a share with
368+
| path | /SharedFolder |
369+
| shareType | 3 |
370+
And Updating last share with
371+
| permissions | 31 |
372+
And User "user1" opens the file "file.odt" of the shared link
373+
And Collabora fetches checkFileInfo
374+
375+
And as "user1" rename "/SharedFolder/file.odt" to "renamed_file"
376+
And as "user1" the file "/SharedFolder/renamed_file.odt" exists
377+
And as "user1" the file "/SharedFolder/file.odt" does not exist
378+
And as "user1" the file "/renamed_file.odt" does not exist

0 commit comments

Comments
 (0)