Skip to content
Snippets Groups Projects
Commit 46f9feda authored by jvfpw18's avatar jvfpw18
Browse files

Add tests for simcaq front using cypress

parent 8d94ed79
Branches
No related tags found
1 merge request!1Development
node_modules/
cypress/videos/
cypress/screenshots/
package-lock.json
\ No newline at end of file
{
"baseUrl": "http://simcaq.c3sl.ufpr.br/",
"integrationFolder": "./tests"
}
{
"name": "Using fixtures to represent data",
"email": "hello@cypress.io",
"body": "Fixtures are a great way to mock data for responses to routes"
}
\ No newline at end of file
// ***********************************************************
// This example plugins/index.js can be used to load plugins
//
// You can change the location of this file or turn off loading
// the plugins file with the 'pluginsFile' configuration option.
//
// You can read more here:
// https://on.cypress.io/plugins-guide
// ***********************************************************
// This function is called when a project is opened or re-opened (e.g. due to
// the project's config changing)
module.exports = (on, config) => {
// `on` is used to hook into various events Cypress emits
// `config` is the resolved Cypress config
}
// ***********************************************
// This example commands.js shows you how to
// create various custom commands and overwrite
// existing commands.
//
// For more comprehensive examples of custom
// commands please read more here:
// https://on.cypress.io/custom-commands
// ***********************************************
//
//
// -- This is a parent command --
// Cypress.Commands.add("login", (email, password) => { ... })
//
//
// -- This is a child command --
// Cypress.Commands.add("drag", { prevSubject: 'element'}, (subject, options) => { ... })
//
//
// -- This is a dual command --
// Cypress.Commands.add("dismiss", { prevSubject: 'optional'}, (subject, options) => { ... })
//
//
// -- This is will overwrite an existing command --
// Cypress.Commands.overwrite("visit", (originalFn, url, options) => { ... })
// ***********************************************************
// This example support/index.js is processed and
// loaded automatically before your test files.
//
// This is a great place to put global configuration and
// behavior that modifies Cypress.
//
// You can change the location of this file or turn off
// automatically serving support files with the
// 'supportFile' configuration option.
//
// You can read more here:
// https://on.cypress.io/configuration
// ***********************************************************
// Import commands.js using ES2015 syntax:
import './commands'
// Alternatively you can use CommonJS syntax:
// require('./commands')
{
"scripts": {
"cypress": "cypress open",
"cy:run": "cypress run"
},
"devDependencies": {
"cypress": "^3.3.2"
}
}
const TIMEOUT = {timeout: 130000};
describe('1 - CAQ', function() {
it('successfully loads', function() {
cy.clearLocalStorage()
cy.clearCookies()
cy.server()
cy.route({url: 'api/v1/enrollment**', method: 'GET'}).as('getEnrollment')
cy.route({url: 'api/v1/classroom_count**', method: 'POST'}).as('postApi')
cy.visit('http://simcaq.c3sl.ufpr.br/', {
auth: {
username: 'simcaq',
password: 'simcaqeducacao'
}
})
cy.wait(1000)
cy.get('.caq').contains('Acessar').click()
cy.get('.block-ui-main').should('visible')
cy.wait('@postApi', TIMEOUT)
cy.wait(Array(5).fill('@getEnrollment'), TIMEOUT)
cy.wait(300)
cy.route({url: 'api/v1/**', method: 'GET'}).as('getApi')
cy.get('.edit-mode').click()
let apiGetCalls = [1, 1, 0, 1, 0, 3, 1, 1, 0, 4, 1, 0, 4, 0, 1, 0, 0, 7, 3, 0, 0, 0, 0, 0] // Quantidade de get's da api por tela
for (let i = 0; i < 24; i++) {
cy.wait(300)
if (i == 9 || i == 18) // Telas que contêm um post.
cy.wait('@postApi', TIMEOUT)
if (apiGetCalls[i] > 0)
cy.wait(Array(apiGetCalls[i]).fill('@getApi'), TIMEOUT)
cy.contains('Próximo').click()
}
cy.wait(Array(3).fill('@getApi'), TIMEOUT)
cy.get('.block-ui-main', TIMEOUT).should('not.visible').then(() => {return cy.contains('Finalizar').click()} )
})
})
describe('2 - Orçamento educacional', function() {
it('successfully loads without selecting a state', function() {
cy.clearLocalStorage()
cy.clearCookies()
cy.server()
cy.route({url: 'api/v1/enrollment**', method: 'GET'}).as('getEnrollment')
cy.route({url: 'api/v1/classroom_count**', method: 'POST'}).as('postApi')
cy.visit('http://simcaq.c3sl.ufpr.br/', {
auth: {
username: 'simcaq',
password: 'simcaqeducacao'
}
})
cy.wait(1000)
cy.get('.planning').contains('Simular').click()
cy.wait('@getEnrollment', TIMEOUT)
cy.wait(300)
cy.contains('Simular').click()
cy.wait(['@postApi', '@postApi'], TIMEOUT) // Classroom count chamada duas vezes seguidas
cy.wait(Array(5).fill('@getEnrollment'), TIMEOUT)
cy.wait(300)
cy.get('.edit-mode').click()
cy.route({url: 'api/v1/**', method: 'GET'}).as('getApi')
cy.wait(300)
cy.contains('4').click()
let apiGetCalls = [0, 1, 2, 0, 1, 0, 3, 1, 1, 0, 4, 1, 0, 4, 0, 1, 0, 0, 0, 3, 0, 0, 0, 0, 0] // Quantidade de get's da api por tela
for (let i = 0; i < 25; i++) {
cy.wait(300)
if (i == 10 || i == 19) // Telas que contêm um post.
cy.wait('@postApi', TIMEOUT)
if (apiGetCalls[i] > 0)
cy.wait(Array(apiGetCalls[i]).fill('@getApi'), TIMEOUT)
cy.contains('Próximo').click()
}
cy.wait(Array(3).fill('@getApi'), TIMEOUT)
cy.get('.block-ui-main', TIMEOUT).should('not.visible').then(() => {return cy.contains('Finalizar').click()} )
})
it('successfully loads with RS selected', function() {
cy.clearLocalStorage()
cy.clearCookies()
cy.server()
cy.route({url: 'api/v1/enrollment**', method: 'GET'}).as('getEnrollment')
cy.route({url: 'api/v1/classroom_count**', method: 'POST'}).as('postApi')
cy.visit('http://simcaq.c3sl.ufpr.br/', {
auth: {
username: 'simcaq',
password: 'simcaqeducacao'
}
})
cy.wait(1000)
cy.get('.planning').contains('Simular').click()
cy.wait('@getEnrollment', TIMEOUT)
cy.wait(300)
cy.get('.state-rs').click({force: true})
cy.wait('@getEnrollment', TIMEOUT)
cy.wait(300)
cy.contains('Simular').click()
cy.wait(['@postApi', '@postApi'], TIMEOUT) // Classroom count chamada duas vezes seguidas
cy.wait(Array(5).fill('@getEnrollment'), TIMEOUT)
cy.wait(300)
cy.get('.edit-mode').click()
cy.route({url: 'api/v1/**', method: 'GET'}).as('getApi')
cy.wait(300)
cy.contains('4').click()
let apiGetCalls = [0, 1, 2, 0, 1, 0, 3, 1, 1, 0, 4, 1, 0, 4, 0, 1, 0, 0, 0, 3, 0, 0, 0, 0, 0] // Quantidade de get's da api por tela
for (let i = 0; i < 25; i++) {
cy.wait(300)
if (i == 10 || i == 19) // Telas que contêm um post.
cy.wait('@postApi', TIMEOUT)
if (apiGetCalls[i] > 0)
cy.wait(Array(apiGetCalls[i]).fill('@getApi'), TIMEOUT)
cy.contains('Próximo').click()
}
cy.wait(Array(3).fill('@getApi'), TIMEOUT)
cy.get('.block-ui-main', TIMEOUT).should('not.visible').then(() => {return cy.contains('Finalizar').click()} )
})
})
describe('3 - Fundo de manutenção', function() {
it('successfully loads', function() {
cy.clearLocalStorage()
cy.clearCookies()
cy.server()
cy.route({url: 'api/v1/enrollment**', method: 'GET'}).as('getEnrollment')
cy.route({url: 'api/v1/classroom_count**', method: 'POST'}).as('postApi')
cy.visit('http://simcaq.c3sl.ufpr.br/', {
auth: {
username: 'simcaq',
password: 'simcaqeducacao'
}
})
cy.wait(1000)
cy.get('.financing').contains('Consultar').click()
cy.wait('@postApi', TIMEOUT)
cy.wait(Array(5).fill('@getEnrollment'), TIMEOUT)
cy.wait(10000)
cy.route({url: 'api/v1/**', method: 'GET'}).as('getApi')
cy.get('.edit-mode').click()
let apiGetCalls = [1, 1, 0, 1, 0, 3, 1, 1, 0, 4, 1, 0, 4, 0, 1, 0, 0, 7, 3, 0, 0, 0, 0, 0] // Quantidade de get's da api por tela
for (let i = 0; i < 24; i++) {
cy.wait(300)
if (i == 9 || i == 18) // Telas que contêm um post.
cy.wait('@postApi', TIMEOUT)
if (apiGetCalls[i] > 0)
cy.wait(Array(apiGetCalls[i]).fill('@getApi'), TIMEOUT)
cy.contains('Próximo').click()
}
cy.wait(Array(3).fill('@getApi'), TIMEOUT)
cy.get('.block-ui-main', TIMEOUT).should('not.visible').then(() => {return cy.contains('Finalizar').click()} )
})
})
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment