Skip to content

Commit 3f7a56d

Browse files
juliusknorrbackportbot[bot]
authored andcommitted
test: Add test case for creating a new file and opening it with direct editing
Signed-off-by: Julius Knorr <jus@bitgrid.net> [skip ci]
1 parent 05d1d7c commit 3f7a56d

File tree

1 file changed

+37
-0
lines changed

1 file changed

+37
-0
lines changed

cypress/e2e/direct.spec.js

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,28 @@ const createDirectEditingLink = (user, fileId) => {
3939
})
4040
}
4141

42+
const createNewFileDirectEditingLink = (user, path, template) => {
43+
cy.login(user)
44+
return cy.request({
45+
method: 'POST',
46+
url: `${Cypress.env('baseUrl')}/ocs/v2.php/apps/richdocuments/api/v1/templates/new?format=json`,
47+
form: true,
48+
body: {
49+
path, template,
50+
},
51+
// auth: { user: user.userId, pass: user.password },
52+
headers: {
53+
'OCS-ApiRequest': 'true',
54+
'Content-Type': 'application/x-www-form-urlencoded',
55+
},
56+
}).then(response => {
57+
cy.log(response)
58+
const token = response.body?.ocs?.data?.url
59+
cy.log(`Created direct editing token for ${user.userId}`, token)
60+
cy.wrap(token)
61+
})
62+
}
63+
4264
const createDirectEditingLinkForShareToken = (shareToken, host = undefined, path = '', password = undefined) => {
4365
cy.logout()
4466
return cy.request({
@@ -90,6 +112,21 @@ describe('Direct editing (legacy)', function() {
90112
})
91113
})
92114

115+
it('Open an new file', function() {
116+
getTemplates(randUser, 'document')
117+
.then((templates) => {
118+
const emptyTemplate = templates.find((template) => template.name === 'Empty')
119+
cy.nextcloudTestingAppConfigSet('richdocuments', 'uiDefaults-UIMode', 'classic')
120+
createNewFileDirectEditingLink(randUser, 'mynewfile.odt', emptyTemplate.id)
121+
.then((token) => {
122+
cy.logout()
123+
cy.visit(token)
124+
cy.waitForCollabora(false)
125+
cy.screenshot('direct-new')
126+
})
127+
})
128+
})
129+
93130
it('Open an existing file on a share link', function() {
94131
cy.shareLink(randUser, '/document.odt').then((token) => {
95132
createDirectEditingLinkForShareToken(token)

0 commit comments

Comments
 (0)