Skip to content

Commit 4cbd45f

Browse files
authored
Merge pull request #5939 from nextcloud/backport/5934/stable32
[stable32] fix(ci): stabilize cypress tests
2 parents 752aa32 + 54c3316 commit 4cbd45f

3 files changed

Lines changed: 26 additions & 10 deletions

File tree

.github/workflows/cypress-e2e.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ jobs:
4343
aliasgroup1: 'http://172.17.0.1'
4444
ports:
4545
- "9980:9980"
46+
options: --cap-add SYS_ADMIN --cap-add SYS_CHROOT
4647

4748
steps:
4849
- name: Checkout server

cypress/e2e/direct.spec.js

Lines changed: 22 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -166,19 +166,29 @@ describe('Direct editing (legacy)', function() {
166166
it('Save as', function() {
167167
createDirectEditingLink(randUser, fileId)
168168
.then((token) => {
169-
cy.nextcloudTestingAppConfigSet('richdocuments', 'uiDefaults-UIMode', 'tabbed')
169+
cy.nextcloudTestingAppConfigSet('richdocuments', 'uiDefaults-UIMode', 'notebookbar')
170170
cy.logout()
171-
cy.visit(token)
171+
cy.visit(token, {
172+
onBeforeLoad(win) {
173+
cy.spy(win, 'postMessage').as('postMessage')
174+
},
175+
})
172176
cy.waitForCollabora(false)
177+
cy.waitForPostMessage('App_LoadingStatus', { Status: 'Document_Loaded' })
173178

174179
cy.get('@loleafletframe').within(() => {
175180
cy.get('.notebookbar-tabs-container', { timeout: 30_000 })
176181
.should('be.visible')
177182

178183
cy.get('button[aria-label="File"]').click()
179-
cy.get('button[aria-label="Save As"]').click()
184+
cy.get('button[aria-label="Save As"]')
185+
.should('be.visible', { timeout: 10_000 })
186+
.click()
180187

181-
cy.get('#saveas-entries #saveas-entry-1').click()
188+
cy.get('#saveas-entries > div', { timeout: 30_000 })
189+
.contains('Rich Text (.rtf)')
190+
.should('be.visible')
191+
.click()
182192
})
183193

184194
cy.get('.saveas-dialog')
@@ -225,13 +235,18 @@ describe('Direct editing (legacy)', function() {
225235
.then((token) => {
226236
cy.nextcloudTestingAppConfigSet('richdocuments', 'uiDefaults-UIMode', 'classic')
227237
cy.logout()
228-
cy.visit(token)
238+
cy.visit(token, {
239+
onBeforeLoad(win) {
240+
cy.spy(win, 'postMessage').as('postMessage')
241+
},
242+
})
229243
cy.waitForCollabora(false)
244+
cy.waitForPostMessage('App_LoadingStatus', { Status: 'Document_Loaded' })
230245
cy.get('[data-cy="coolframe"]').then($iframe => {
231246
const collaboraOrigin = $iframe[0].contentWindow.location.origin
232247
cy.spy($iframe[0].contentWindow, 'postMessage').as('postMessage')
233-
cy.dispatchMessageFromOrigin(collaboraOrigin, { MessageId: 'App_LoadingStatus', Values: { Status: 'Document_Loaded' } })
234-
cy.waitForPostMessage('Host_PostmessageReady', undefined, { targetOrigin: collaboraOrigin })
248+
cy.dispatchMessageFromOrigin(collaboraOrigin, { MessageId: 'Action_Paste', Values: {} })
249+
cy.waitForPostMessage('Action_Paste', undefined, { targetOrigin: collaboraOrigin })
235250
})
236251
})
237252
})

src/document.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -620,9 +620,9 @@ const documentsMain = {
620620

621621
$('footer,nav').show()
622622
documentsMain.UI.hideEditor()
623-
documentsMain.openLocally()
624-
625-
PostMessages.sendPostMessage('parent', 'close')
623+
if (!isDirectEditing()) {
624+
PostMessages.sendPostMessage('parent', 'close')
625+
}
626626
},
627627

628628
onCloseViewer() {

0 commit comments

Comments
 (0)