Skip to content

Commit

Permalink
Update cypress dependencies, create v2 documentation test folder and …
Browse files Browse the repository at this point in the history
…some configurations in cypress folders. (#300)
  • Loading branch information
Akellymourab authored and PaG0Dezaum2005 committed Aug 29, 2024
1 parent ac8038a commit 420b713
Show file tree
Hide file tree
Showing 29 changed files with 5,103 additions and 0 deletions.
11 changes: 11 additions & 0 deletions cypress.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
const { defineConfig } = require('cypress')

module.exports = defineConfig({
e2e: {
// We've imported your old cypress plugins here.
// You may want to clean this up later by importing these.
setupNodeEvents(on, config) {
return require('./cypress/plugins/index.js')(on, config)
},
},
})
10 changes: 10 additions & 0 deletions cypress/cypress.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
const { defineConfig } = require("cypress");

module.exports = defineConfig({
e2e: {
baseUrl: 'http://localhost',
chromeWebSecurity: false,
setupNodeEvents(on, config) {
},
},
});
23 changes: 23 additions & 0 deletions cypress/e2e/agentesPage/compact.cy.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
describe("Homepage compactada", () => {
beforeEach(() => {
cy.viewport(1000, 768);
cy.visit("/");
});
it("acessa \"Agentes\" no navbar", () => {
cy.get(".mc-header-menu__btn-mobile").click();
cy.contains(".mc-header-menu__itens a", "Agentes").click();
cy.url().should("include", "agentes");
});
});
describe("Pagina de Agentes", () => {
beforeEach(() => {
cy.viewport(1000, 768);
cy.visit("/agentes");
});

it("clica em \"Acessar\" e entra na pagina no agente selecionado", () => {
cy.get(":nth-child(2) > .entity-card__footer > .entity-card__footer--action > .button").click();
cy.url().should("include", "/agente/118/#info");
cy.contains("Junin Oliveira");
});
});
23 changes: 23 additions & 0 deletions cypress/e2e/agentesPage/full.cy.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
describe("HomePage", () => {
beforeEach(() => {
cy.viewport(1920, 1080);
cy.visit("/");
});

it("acessa \"Agentes\" no navbar", () => {
cy.contains("a", "Agentes").click();
cy.url().should("include", "/agentes");
});
});
describe("Pagina de Agentes", () => {
beforeEach(() => {
cy.viewport(1920, 1080);
cy.visit("/agentes");
});

it("clica em \"Acessar\" e entra na pagina no agente selecionado", () => {
cy.get(":nth-child(2) > .entity-card__footer > .entity-card__footer--action > .button").click();
cy.url().should("include", "/agente/118/#info");
cy.contains("Junin Oliveira");
});
});
91 changes: 91 additions & 0 deletions cypress/e2e/agentesPage/index.cy.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
const { clearAllFilters } = require("../../commands/clearAllFilters");

describe("Agents Page", () => {
beforeEach(() => {
cy.viewport(1920, 1080);
cy.visit("/agentes");
});

it("Garante que a página de agentes funciona", () => {
cy.url().should("include", "agentes");

cy.get("h1").contains("Agentes");

cy.contains("Mais recentes primeiro");
cy.contains("Agentes encontrados");
cy.contains("Filtros de agente");
cy.contains("Status do agente");
cy.contains("Tipo");
cy.contains("Área de atuação");
cy.contains("Junin Oliveira");
});

it("Garante que os filtros de oportunidades funcionam quando não existem resultados pra busca textual", () => {
cy.get(".search-filter__actions--form-input").type("Agente ruim");

cy.wait(1000);

cy.contains("Nenhuma entidade encontrada");
});

it("Garante que os filtros de agentes funcionam quando existem resultados para a busca textual", () => {
cy.get(".search-filter__actions--form-input").type("Oliviana");

cy.wait(1000);

cy.contains("2 Agentes encontrados");
});

it("Garante que o filtro de agentes oficiais funciona", () => {
cy.wait(1000);

cy.contains("Status do agente");

cy.get(".verified > input").click();

cy.contains("4 Agentes encontrados");
});

it("Garante que os filtros por tipo de agente funcionam", () => {
cy.wait(1000);

cy.contains("Tipo");

cy.get(":nth-child(2) > select").select(2);
cy.contains("Agente Coletivo");
cy.wait(1000);
cy.contains("24 Agentes encontrados");

cy.get(":nth-child(2) > select").select(1);
cy.contains("Agente Individual");
cy.wait(1000);
cy.contains("69 Agentes encontrados");

cy.get(":nth-child(2) > select").select(0);
cy.contains("Todos");
cy.wait(1000);
cy.contains("93 Agentes encontrados");
});

it("Garante que os filtros por área de atuação funcionam", () => {
cy.wait(1000);

cy.contains("Área de atuação");

cy.get(":nth-child(3) > .mc-multiselect > :nth-child(1) > .v-popper > .mc-multiselect--input").click();
cy.get(":nth-child(3) > .item > .text").click();

cy.wait(1000);

cy.contains("9 Agentes encontrados");
});

it("Garante que o botão limpar filtros na página de agentes funciona", () => {
clearAllFilters([
".verified",
":nth-child(2) > select",
".mc-multiselect--input",
":nth-child(1) > .item > .text"
], "98 Agentes encontrados");
});
});
18 changes: 18 additions & 0 deletions cypress/e2e/documentationV2Page/index.cy.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
describe('Swagger Documentation Page Test', () => {
beforeEach(() => {
cy.visit("/mapas/docs/v2");
});

it('should load the documentation page without errors', () => {
cy.visit(url);

cy.get('.errors-wrapper').should('not.exist');

cy.contains('API Mapas Culturais V2 - OpenAPI 3.0').should('be.visible');
cy.contains('GET /agents').should('be.visible');
cy.contains('POST /agents').should('be.visible');
cy.contains('GET /agents/{id}').should('be.visible');
cy.contains('PATCH /agents/{id}').should('be.visible');
cy.contains('DELETE /agents/{id}').should('be.visible');
});
});
56 changes: 56 additions & 0 deletions cypress/e2e/eventsPage/index.cy.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
describe("Events Page", () => {
beforeEach(() => {
cy.viewport(1920, 1080);
cy.visit("/eventos");
});

it("Garantir que após clicar em \"Eventos\" consiga carregar a página com a seção dos eventos e a seção de filtros, cada filtro com o valor padrão", () => {
cy.contains("a", "Eventos").click();
cy.get(".search-filter__actions--form-input").should("exist");
cy.get(".search-filter__actions--form-input").should("be.empty");
cy.get(".search-list__cards > div").should("exist");
});

it("Garantir que é possível clicar em \"Eventos acontecendo\" na caixa de filtragem e que ao fazê-lo, um calendário é exibido, juntamente com opções rápidas de busca na lateral direita", () => {
cy.contains("a", "Eventos").click();
cy.contains("Eventos acontecendo").should("exist");
cy.get(".dp__pointer").click();
cy.get(".dp__menu_content_wrapper").should("exist");
cy.get(".dp__preset_ranges").should("exist");
cy.get(".dp__flex_display").should("exist");
["Hoje", "Amanhã", "Esta semana", "Este fim de semana", "Próximo fim de semana", "Próximos 7 dias", "Próximos 30 dias", "Março", "2024"].forEach(dateRange => {
cy.contains(dateRange).should("exist");
});
});

it("Garantir que nas opções rápidas, seja possível clicar na opção \"2024\"", () => {
cy.contains("a", "Eventos").click();
cy.contains("Eventos acontecendo").should("exist");
cy.get(".dp__pointer").click();
cy.contains("2024").click();
cy.wait(1000);
});

it("Garantir de que, após clicar na opção \"2024\", é possível clicar na seta de navegação esquerda, filtrando para o ano de \"2023\"", () => {
cy.get(".dp__pointer").click();
cy.contains("2024").click();
cy.wait(1000);
cy.get(".filter-btn > :first-child").click();
cy.contains("h2", "Evento 2");
});

it("Garantir que é possível acessar um evento e carregar as informações", () => {
cy.get(".dp__pointer").click();
cy.contains("2024").click();
cy.wait(1000);
cy.get(".filter-btn > :first-child").click();
cy.wait(1000);
cy.get(`[href="${Cypress.config().baseUrl}/evento/2/"]`).click();
cy.wait(1000);
cy.contains("h1", "Evento 2");
cy.contains("h4", "Lista de oportunidades vinculadas");
cy.get(".opportunity-list__container").should("not.be.empty");
cy.contains(".age-rating__title", " Classificação Etária ");
cy.contains(".age-rating__content", "16 anos");
});
});
33 changes: 33 additions & 0 deletions cypress/e2e/faqPage/index.cy.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
import { backFaqPage } from "../../commands/backFaqPage";

describe("faqPage", () => {
beforeEach(() => {
cy.visit("/");
cy.contains("a", "Dúvidas frequentes").click();
});

it("Garante que as opções do menu 'Dúvidas Frequentes' sejam clicáveis", () => {
const url = [
"/perguntas-frequentes/cadastro/",
"/perguntas-frequentes/IntroducaoMapa/",
"/perguntas-frequentes/inscricao/"
];

url.forEach(url => {
const fullUrl = Cypress.config().baseUrl + url;

cy.get(`.faq__frequent > [href="${fullUrl}"]`).click();
backFaqPage();
cy.wait(1000);
cy.get(`.faq__links > [href="${fullUrl}"]`).click();
backFaqPage();
});
});

it("Garante que a barra de pesquisa funciona e carrega os resultados", () => {
cy.get(".faq-search__input").should("be.enabled").type("cadastro");

cy.get(".faq__main--results").should("be.visible");
cy.get(".faq-accordion__items").should("be.visible");
});
});
11 changes: 11 additions & 0 deletions cypress/e2e/footer/index.cy.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import { footer } from "../../commands/footer";

describe("Homepage", () => {
beforeEach(() => {
cy.visit("/");
});

it("testa a funcão footer", () => {
footer();
});
});
86 changes: 86 additions & 0 deletions cypress/e2e/homepage/compact.cy.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
import { backHomepageCompact } from "../../commands/backHomepageCompact";

describe("Homepage compactada", () => {
beforeEach(() => {
cy.viewport(1000, 768);
cy.visit("/");
});

it("Garante o funcionamento do home", () => {
backHomepageCompact();
});

it("Acessa \"Ver todos\" de Eventos", () => {
cy.get(":nth-child(2) > .card__right > .button").click();
cy.url().should("include", "/eventos/");
backHomepageCompact();
});
it("Acessa \"Ver todos\" de Espaços", () => {
cy.get(":nth-child(3) > .card__right > .button").click();
cy.url().should("include", "/espacos/");
backHomepageCompact();
});
it("Acessa \"Ver todos\" de Agentes", () => {
cy.get(":nth-child(4) > .card__right > .button").click();
cy.url().should("include", "/agentes/");
backHomepageCompact();
});
it("Acessa \"Ver todos\" de Projetos", () => {
cy.get(":nth-child(5) > .card__right > .button").click();
cy.url().should("include", "/projetos/");
backHomepageCompact();
});

it("Navegação entre os cards da seção \"Em desteaque\"", () => {
cy.get(".carousel__next").click();
cy.wait(1000);
cy.get(".carousel__prev").click();
});

it("Acessa o navbar e o botão \"Acessar\" dos cards da seção \"Em desteaque\"", () => {
cy.get(".agents > a > span").click();
cy.wait(1000);
cy.get(".carousel__slide--active > .entity-card > .entity-card__footer > .entity-card__footer--action > .button").click();
cy.url().should("include", "/agente/54/#info");
cy.contains("Bianca Vieira");
backHomepageCompact();

cy.get(".spaces > a > span").click();
cy.wait(1000);
cy.get("[style=\"width: 35.7143%; order: 0;\"] > .entity-card > .entity-card__footer > .entity-card__footer--action > .button").click();
cy.url().should("include", "/espaco/25/#info");
cy.contains("Quatro pixels");
backHomepageCompact();

cy.get(".projects > a > span").click();
cy.wait(1000);
cy.get(".entity-card__footer--action > .button").click();
cy.url().should("include", "/projeto/12/#info");
cy.contains("12");
backHomepageCompact();

cy.get(".carousel__slide--active > .entity-card > .entity-card__footer > .entity-card__footer--action > .button").click();
cy.url().should("include", "/agente/1/#info");
cy.contains("Administrador");
backHomepageCompact();
});

it("Acessa o botão \"Fazer Cadastro\" da quarta seção", () => {
cy.get(".home-register__content--button").click();
cy.url().should("include", "autenticacao/register/");
cy.contains("Novo cadastro");
backHomepageCompact();
});

it("Acessa o botões de zoom do mapa", () => {
cy.get(".leaflet-control-zoom-in").click();
cy.wait(2000);
cy.get(".leaflet-control-zoom-out").click();
});

it("Acessa o botão \"Conheça o repositório\" da seção \"Alô desenvolvedores\"", () => {
cy.get(".home-developers__content--link > .link").click();
cy.url().should("include", "https://github.com/mapasculturais");
cy.visit("/");
});
});
Loading

0 comments on commit 420b713

Please sign in to comment.