I'm trying to write a test where I need to check if a list of blogs is rendered in the descending order of likes for each blog. For this, I've created 3 mock blogs in Cypress and want to give them a specific number of likes (3 - 1 - 2) before I test whether they're arranged in descending orders of likes. However, the below code gives 4 - 2 - 2 likes instead of the intended 3 - 1 - 2:
it('the blogs are ordered in descending order of likes', function() {
cy.createBlog({
title: 'The Perks of Being a Wallflower',
author: 'Emma Watson',
url: 'www.blank.org',
})
cy.createBlog({
title: 'The Life of Pi',
author: 'Yann Martel',
url: 'www.pi.com',
})
cy.createBlog({
title: 'Deep Dive into the World of Containers',
author: 'GDG',
url: 'www.gdg.com',
})
cy.wait(750)
cy.contains('The Perks of Being a Wallflower')
.contains('view').click({ multiple: true })
.get('.blog-like-button').click({ multiple: true })
cy.wait(750)
cy.contains('The Perks of Being a Wallflower')
.get('.blog-like-button').click({ multiple: true })
cy.wait(750)
cy.contains('The Perks of Being a Wallflower')
.get('.blog-like-button').click({ multiple: true })
cy.wait(750)
cy.contains('The Life of Pi')
.contains('view').click({ multiple: true })
.get('.blog-like-button').click({ multiple: true })
cy.wait(750)
cy.contains('Deep Dive into the World of Containers')
.contains('view').click({ multiple: true })
.get('.blog-like-button').click({multiple: true})
cy.wait(750)
cy.contains('Deep Dive into the World of Containers')
.get('.blog-like-button').click({ multiple: true })
cy.wait(750)
cy.reload()
})
The incorrect output in Cypress looks like this: image of output of above code in Cypress