Skip to content

Commit eb14544

Browse files
committed
enh(cy): fixed text attachment from toolbar text
Signed-off-by: Peter Birrer <peter.birrer@optonic.com>
1 parent db7a46a commit eb14544

1 file changed

Lines changed: 11 additions & 3 deletions

File tree

cypress/e2e/attachments.spec.js

100644100755
Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -116,16 +116,17 @@ const checkAttachment = (documentId, fileName, fileId, index, isImage = true) =>
116116
* @param {string} requestAlias Alias of the request we are waiting for
117117
* @param {number|undefined} index of the attachment
118118
* @param {boolean} isImage is the attachment an image or a media file?
119+
* @param {Function} check function used to check document for attachment
119120
*/
120-
const waitForRequestAndCheckAttachment = (requestAlias, index, isImage = true) => {
121+
const waitForRequestAndCheckAttachment = (requestAlias, index, isImage = true, check = checkAttachment) => {
121122
return cy.wait('@' + requestAlias)
122123
.then((req) => {
123124
// the name of the created file on NC side is returned in the response
124125
const fileId = req.response.body.id
125126
const fileName = req.response.body.name
126127
const documentId = req.response.body.documentId
127128

128-
return checkAttachment(documentId, fileName, fileId, index, isImage)
129+
return check(documentId, fileName, fileId, index, isImage)
129130
})
130131
}
131132

@@ -281,6 +282,13 @@ describe('Test all attachment insertion methods', () => {
281282
})
282283

283284
it('Create a new text file as an attachment', () => {
285+
const check = (documentId, fileName) => {
286+
cy.log('Check the attachment is visible and well formed', documentId, fileName)
287+
return cy.get(`.text-editor [basename="${fileName}"]`)
288+
.find('.text-editor__wrapper')
289+
.should('be.visible')
290+
}
291+
284292
cy.visit('/apps/files')
285293
cy.openFile('test.md')
286294

@@ -289,7 +297,7 @@ describe('Test all attachment insertion methods', () => {
289297
cy.intercept({ method: 'POST', url: '**/text/attachment/create' }).as(requestAlias)
290298
clickOnAttachmentAction(ACTION_CREATE_NEW_TEXT_FILE)
291299
.then(() => {
292-
return waitForRequestAndCheckAttachment(requestAlias, undefined, false)
300+
return waitForRequestAndCheckAttachment(requestAlias, undefined, false, check)
293301
})
294302
})
295303

0 commit comments

Comments
 (0)