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

Delete Function and Test #198

Closed

Conversation

josieecook
Copy link
Contributor

Pull Request Description

A functional deleteLog function and functional but messy cypress tests for that function.


Licensing Certification

FarmData2 is a Free Cultural Work and all accepted contributions are licensed as described in the LICENSE.md file. This requires that the contributor holds the rights to do so. By submitting this pull request I certify that I satisfy the terms of the Developer Certificate of Origin for its contents.

@braughtg
Copy link
Member

Here is a structure that seems to be effective for the delete test and should generalize to the other tests as well.

        it('deletes a log based on log ID', () => {
            getSessionToken()
            .then(function(token) {
                console.log('making log')

                req = {
                    url: '/log.json?type=farm_observation',
                    method: 'POST',
                    headers: {
                        'X-Requested-With': 'XMLHttpRequest',
                        'X-CSRF-TOKEN' : token,
                    },
                    body: {
                        "name": "pleasegoaway",
                        "type": "farm_observation",
                        "timestamp": "1526584271",
                    }
                }

                logID = -1
                cy.request(req).as('created')
                cy.get('@created').should((response) => {
                    expect(response.status).to.equal(201)
                    logID = response.body.id
                })

                cy.wrap(deleteLog('/log.json?type=farm_observation', logID, token)).as('delete')
                cy.get('@delete').should((response) => {
                    expect(response.status).to.equal(200)
                })

                url = '/log.json?type=farm_observation&id=' + logID
                cy.request(url).as('check')
                cy.get('@check').should((response) => {
                    expect(response.body.list.length).to.equal(0)
                })
            })
        })

@braughtg
Copy link
Member

Note that the tests for getAllPages can also be updated to use this. It may also remove the need for the hacky wait(1) that is in there. So it would be worth checking to see if that can be taken out.

@braughtg braughtg marked this pull request as ready for review June 24, 2021 20:04
@braughtg
Copy link
Member

Superseded by #201.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants