diff --git a/tests/simcaq-front.js b/tests/simcaq-front.js index 254e162263c21e1245aeb8cda054f7e1299b4f0d..a02898a00269e051898a541d3abf78b2316eb58b 100644 --- a/tests/simcaq-front.js +++ b/tests/simcaq-front.js @@ -1,13 +1,13 @@ -const TIMEOUT = {timeout: 130000}; +const TIMEOUT = { timeout: 130000 }; -describe('1 - CAQ', function() { - it('successfully loads', function() { +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.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', @@ -19,35 +19,35 @@ describe('1 - CAQ', function() { 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('@postApi', TIMEOUT) cy.wait(300) - cy.route({url: 'api/v1/**', method: 'GET'}).as('getApi') + 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, 2, 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) + if (i == 9 || i == 18) // Telas que contêm um post. + cy.wait('@postApi', TIMEOUT) cy.get('.btn-primary.step.next').click() } cy.wait(Array(3).fill('@getApi'), TIMEOUT) - cy.get('.block-ui-main', TIMEOUT).should('not.visible').then(() => {return cy.get('.finalize').click()} ) + cy.get('.block-ui-main', TIMEOUT).should('not.visible').then(() => { return cy.get('.finalize').click() }) }) }) -describe('2 - Orçamento educacional', function() { - it('successfully loads without selecting a state', function() { +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.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', @@ -61,36 +61,36 @@ describe('2 - Orçamento educacional', function() { 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(['@postApi', '@postApi'], TIMEOUT) // Classroom count chamada duas vezes seguidas cy.wait(300) cy.get('.edit-mode').click() - cy.route({url: 'api/v1/**', method: 'GET'}).as('getApi') + 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, 2, 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) + if (i == 10 || i == 19) // Telas que contêm um post. + cy.wait('@postApi', TIMEOUT) - cy.get('.btn-primary.step.next').click() + cy.get('.btn-primary.step.next').click() } cy.wait(Array(3).fill('@getApi'), TIMEOUT) - cy.get('.block-ui-main', TIMEOUT).should('not.visible').then(() => {return cy.get('.finalize').click()} ) + cy.get('.block-ui-main', TIMEOUT).should('not.visible').then(() => { return cy.get('.finalize').click() }) }) - it('successfully loads with RS selected', function() { + 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.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', @@ -103,43 +103,43 @@ describe('2 - Orçamento educacional', function() { cy.wait('@getEnrollment', TIMEOUT) cy.wait(300) - cy.get('.state-rs').click({force: true}) + cy.get('.state-rs').click({ force: true }) cy.wait('@getEnrollment', TIMEOUT) cy.wait(300) cy.contains('Simular').click() + cy.wait(Array(5).fill('@getEnrollment'), TIMEOUT) 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.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, 2, 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) + if (i == 10 || i == 19) // Telas que contêm um post. + cy.wait('@postApi', TIMEOUT) - cy.get('.btn-primary.step.next').click() + cy.get('.btn-primary.step.next').click() } cy.wait(Array(3).fill('@getApi'), TIMEOUT) - cy.get('.block-ui-main', TIMEOUT).should('not.visible').then(() => {return cy.get('.finalize').click()} ) + cy.get('.block-ui-main', TIMEOUT).should('not.visible').then(() => { return cy.get('.finalize').click() }) }) }) -describe('3 - Fundo de manutenção', function() { - it('successfully loads', function() { +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.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', @@ -149,24 +149,24 @@ describe('3 - Fundo de manutenção', function() { cy.wait(1000) cy.get('.financing').contains('Consultar').click() - cy.wait('@postApi', TIMEOUT) cy.wait(Array(5).fill('@getEnrollment'), TIMEOUT) + cy.wait(15000) - cy.route({url: 'api/v1/**', method: 'GET'}).as('getApi') + 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, 2, 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) + if (i == 9 || i == 18) // Telas que contêm um post. + cy.wait('@postApi', TIMEOUT) - cy.get('.btn-primary.step.next').click() + cy.get('.btn-primary.step.next').click() } cy.wait(Array(3).fill('@getApi'), TIMEOUT) - cy.get('.block-ui-main', TIMEOUT).should('not.visible').then(() => {return cy.get('.finalize').click()} ) + cy.get('.block-ui-main', TIMEOUT).should('not.visible').then(() => { return cy.get('.finalize').click() }) }) }) \ No newline at end of file