Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cache.spec.js Cypress test flaws #508

Closed
JingyuMarcelLee opened this issue Jun 28, 2022 · 0 comments · Fixed by #604
Closed

Cache.spec.js Cypress test flaws #508

JingyuMarcelLee opened this issue Jun 28, 2022 · 0 comments · Fixed by #604
Assignees
Labels
bug Something isn't working testing Issues related to tests.

Comments

@JingyuMarcelLee
Copy link
Collaborator

JingyuMarcelLee commented Jun 28, 2022

The cypress test for the cache.html page in fd2_examples needs to be revised.

The third test, which tests for the clearing of the cache seems to have an error with its logic or the comment.

    it('test clearing the cache', () => {

        // Crops should not be cached to start.
        let crops = localStorage.getItem('crops')
        expect(crops).to.not.equal(null)

        // Wait here for the response to come, be cached and fill in the list.
        cy.get('[data-cy=1crop]').should('have.text','ARUGULA')
        .then(() => {
            // Now crops should be in the cache.
            crops = localStorage.getItem('crops')
            expect(crops).to.not.equal(null)
        })
        
        // click the "Clear the Cache" button.
        cy.get('[data-cy=clear-cache]').click()

        // Now reload the page 
        cy.reload(true)

        // Now crops should not be in the cache
        crops = localStorage.getItem('crops')
        expect(crops).to.not.equal(null)

        // But once the response returns the crops should be cached again.
        cy.get('[data-cy=1crop]').should('have.text','ARUGULA')
        .then(() => {
            crops = localStorage.getItem('crops')
            expect(crops).to.not.equal(null)
        })
    })

The test checks if the clearCache button successfully clears the localStorage when it is clicked. When the page reloads after line 70, the localStorage should not contain any caches. However, line 74 checks if the crops are not equal to null (asserting that there should be cache inside localStorage), which is the opposite of what it should be testing. The cypress tests passed, meaning that the clearCache method in cache.html might be erroneous.

@JingyuMarcelLee JingyuMarcelLee changed the title Cache.spec.js Cypress test needs to be fixed Cache.spec.js Cypress test flaws Jun 28, 2022
@braughtg braughtg added bug Something isn't working testing Issues related to tests. labels Jun 29, 2022
@braughtg braughtg self-assigned this Jun 29, 2022
braughtg added a commit that referenced this issue Dec 23, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working testing Issues related to tests.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants