mirror of
https://github.com/nextcloud/richdocuments.git
synced 2025-12-18 05:20:43 +01:00
test: Add test case for creating a new file and opening it with direct editing
Signed-off-by: Julius Knorr <jus@bitgrid.net>
This commit is contained in:
parent
a33d37fbeb
commit
cf83444010
1 changed files with 53 additions and 0 deletions
|
|
@ -2,6 +2,22 @@
|
|||
* SPDX-FileCopyrightText: 2023 Julius Härtl <jus@bitgrid.net>
|
||||
* SPDX-License-Identifier: AGPL-3.0-or-later
|
||||
*/
|
||||
const getTemplates = (user, type) => {
|
||||
return cy.request({
|
||||
method: 'GET',
|
||||
url: `${Cypress.env('baseUrl')}/ocs/v2.php/apps/richdocuments/api/v1/templates/${type}?format=json`,
|
||||
auth: { user: user.userId, pass: user.password },
|
||||
headers: {
|
||||
'OCS-ApiRequest': 'true',
|
||||
'Content-Type': 'application/x-www-form-urlencoded',
|
||||
},
|
||||
}).then(response => {
|
||||
cy.log(response)
|
||||
const templates = response.body?.ocs?.data
|
||||
cy.wrap(templates)
|
||||
})
|
||||
}
|
||||
|
||||
const createDirectEditingLink = (user, fileId) => {
|
||||
cy.login(user)
|
||||
return cy.request({
|
||||
|
|
@ -24,6 +40,28 @@ const createDirectEditingLink = (user, fileId) => {
|
|||
})
|
||||
}
|
||||
|
||||
const createNewFileDirectEditingLink = (user, path, template) => {
|
||||
cy.login(user)
|
||||
return cy.request({
|
||||
method: 'POST',
|
||||
url: `${Cypress.env('baseUrl')}/ocs/v2.php/apps/richdocuments/api/v1/templates/new?format=json`,
|
||||
form: true,
|
||||
body: {
|
||||
path, template,
|
||||
},
|
||||
// auth: { user: user.userId, pass: user.password },
|
||||
headers: {
|
||||
'OCS-ApiRequest': 'true',
|
||||
'Content-Type': 'application/x-www-form-urlencoded',
|
||||
},
|
||||
}).then(response => {
|
||||
cy.log(response)
|
||||
const token = response.body?.ocs?.data?.url
|
||||
cy.log(`Created direct editing token for ${user.userId}`, token)
|
||||
cy.wrap(token)
|
||||
})
|
||||
}
|
||||
|
||||
const createDirectEditingLinkForShareToken = (shareToken, host = undefined, path = '', password = undefined) => {
|
||||
cy.logout()
|
||||
return cy.request({
|
||||
|
|
@ -75,6 +113,21 @@ describe('Direct editing (legacy)', function() {
|
|||
})
|
||||
})
|
||||
|
||||
it('Open an new file', function() {
|
||||
getTemplates(randUser, 'document')
|
||||
.then((templates) => {
|
||||
const emptyTemplate = templates.find((template) => template.name === 'Empty')
|
||||
cy.nextcloudTestingAppConfigSet('richdocuments', 'uiDefaults-UIMode', 'classic')
|
||||
createNewFileDirectEditingLink(randUser, 'mynewfile.odt', emptyTemplate.id)
|
||||
.then((token) => {
|
||||
cy.logout()
|
||||
cy.visit(token)
|
||||
cy.waitForCollabora(false)
|
||||
cy.screenshot('direct-new')
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
it('Open an existing file on a share link', function() {
|
||||
cy.shareLink(randUser, '/document.odt').then((token) => {
|
||||
createDirectEditingLinkForShareToken(token)
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue