Skip to content

Commit 8393ecc

Browse files
committed
text: fix cypress selector to find the right image
`get().filter()` might not take into account elements that did not exist in the dom yet when the `get` part was fired. `.filter()` would then wait for the elements that already existed during `.get()` to contain the newly created image. Signed-off-by: Max <max@nextcloud.com>
1 parent 0f961fc commit 8393ecc

File tree

2 files changed

+6
-7
lines changed

2 files changed

+6
-7
lines changed

cypress/e2e/files.spec.js

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,15 +21,14 @@
2121
*/
2222

2323
describe('Files default view', function() {
24+
2425
beforeEach(function() {
25-
cy.login('admin', 'admin')
26+
cy.log(this.currentTest.currentRetry())
2627
})
2728

2829
it('See the default files list', function() {
30+
cy.login('admin', 'admin')
2931
cy.get('#fileList tr').should('contain', 'welcome.txt')
3032
})
3133

32-
it('Take screenshot', function() {
33-
cy.screenshot()
34-
})
3534
})

cypress/e2e/images.spec.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -79,11 +79,11 @@ const clickOnImageAction = (actionName) => {
7979
*/
8080
const checkImage = (documentId, imageName, imageId, index) => {
8181
const encodedName = fixedEncodeURIComponent(imageName)
82+
const src = `.attachments.${documentId}/${encodedName}`
8283

83-
cy.log('Check the image is visible and well formed', { documentId, imageName, imageId, index, encodedName })
84+
cy.log('Check the image is visible and well formed', documentId, imageName, imageId, index, encodedName)
8485
return new Cypress.Promise((resolve, reject) => {
85-
cy.get('#editor [data-component="image-view"]')
86-
.filter('[data-src=".attachments.' + documentId + '/' + encodedName + '"]')
86+
cy.get(`#editor [data-component="image-view"][data-src="${src}"]`)
8787
.find('.image__view') // wait for load finish
8888
.within(($el) => {
8989
// keep track that we have created this image in the attachment dir

0 commit comments

Comments
 (0)