2019-10-04 00:47:41 +00:00
|
|
|
/**
|
2020-02-24 18:44:50 +00:00
|
|
|
* Creates cy.seedAndVisit() function
|
|
|
|
|
* This function will go to some path and wait for some fake response from 'src/tests/fixtures/*.json'
|
|
|
|
|
* @param { String } seedData The name of json at 'src/tests/fixtures/
|
|
|
|
|
* @param { String } path The path or query parameters to go -ex. '/?path=/api/users'
|
|
|
|
|
* @param { String } method The fake request method
|
|
|
|
|
*/
|
2020-02-25 02:06:23 +00:00
|
|
|
Cypress.Commands.add("seedAndVisit", (seedData, path = "/", method = "GET") => {
|
2019-10-04 00:47:41 +00:00
|
|
|
cy.server()
|
2020-02-25 02:06:23 +00:00
|
|
|
.route(method, "https://api.thecatapi.com/", `fixture:${seedData}`)
|
|
|
|
|
.as("load")
|
2020-02-01 21:36:51 +00:00
|
|
|
|
2019-10-04 00:47:41 +00:00
|
|
|
cy.visit(path)
|
2020-02-25 02:06:23 +00:00
|
|
|
.get("#send")
|
2020-02-24 18:44:50 +00:00
|
|
|
.click()
|
2020-02-25 02:06:23 +00:00
|
|
|
.wait("@load")
|
2020-02-01 21:36:51 +00:00
|
|
|
})
|
|
|
|
|
|
|
|
|
|
/**
|
2020-02-24 18:44:50 +00:00
|
|
|
* Creates cy.enableProxy() function
|
|
|
|
|
* This function will enable the proxy and navigate back to a given path
|
|
|
|
|
* @param { String } goBackPath The page go back
|
|
|
|
|
*/
|
2020-02-25 02:06:23 +00:00
|
|
|
Cypress.Commands.add("enableProxy", goBackPath => {
|
|
|
|
|
cy.visit("/settings")
|
|
|
|
|
.get("#proxy")
|
|
|
|
|
.find(".toggle")
|
2020-02-24 18:44:50 +00:00
|
|
|
.click({ force: true })
|
2020-02-25 02:06:23 +00:00
|
|
|
.should("have.class", "on")
|
2020-02-01 21:36:51 +00:00
|
|
|
.visit(goBackPath)
|
2020-02-24 18:44:50 +00:00
|
|
|
})
|