// rotas com mocks.
// Necessário por enquanto, dado que a aplicação demoautomation está instável
cy.server()
cy.route({
method: 'POST',
url: '**/api/1/databases/userdetails/collections/newtable?**',
status: 200,
response: {}
}).as('postNewtable');
cy.route({
method: 'POST',
url: '**/api/1/databases/userdetails/collections/usertable?**',
status: 200,
response: {}
}).as('postUsertable');
cy.route({
method: 'GET',
url: '**/api/1/databases/userdetails/collections/newtable?**',
status: 200,
response: {}
}).as('getNewtable');
// solução proposta por Jaque Nunes, Turma 5 do Agilizei Bootcamp
cy.intercept('POST', '**/api/1/databases/userdetails/collections/newtable?**', {
statusCode: 200,
body: {}
}).as('postNewtable');
cy.intercept('POST', '**/api/1/databases/userdetails/collections/usertable?**', {
statusCode: 200,
body: {}
}).as('postUsertable');
cy.intercept('GET', '**/api/1/databases/userdetails/collections/newtable?**', {
statusCode: 200,
body: {}
}).as('getNewtable');
Com o server / route
:
cy.wait('@postNewtable').then((resNewtable) => {
// com o serve / route
expect(resNewtable.status).to.eq(200)
})
cy.wait('@postUsertable').then((resUsertable) => {
// com o server / route
expect(resUsertable.status).to.eq(200)
})
cy.wait('@getNewtable').then((resNewtable) => {
// com o server / route
expect(resNewtable.status).to.eq(200)
})
Com o intercept
:
cy.wait('@postNewtable').then((resNewtable) => {
// com o intercept
expect(resNewtable.response.statusCode).to.eq(200)
})
cy.wait('@postUsertable').then((resUsertable) => {
// com o intercept
expect(resUsertable.response.statusCode).to.eq(200)
})
cy.wait('@getNewtable').then((resNewtable) => {
// com o intercept
expect(resNewtable.response.statusCode).to.eq(200)
})