From 66270564a66d48b34cfb43e6bd96b3a484746a7f Mon Sep 17 00:00:00 2001 From: Atyrson Date: Tue, 13 Aug 2024 15:34:39 -0300 Subject: [PATCH] chore: adiciona o fluxo da pipeline --- .github/workflows/testing.yml | 30 +++++++++ .../AvaliacaoMateriaComponents.spec.js | 61 ------------------- vue-app/tests/components/rules.txt | 3 - 3 files changed, 30 insertions(+), 64 deletions(-) create mode 100644 .github/workflows/testing.yml delete mode 100644 vue-app/tests/components/AvaliacaoMateriaComponents.spec.js delete mode 100644 vue-app/tests/components/rules.txt diff --git a/.github/workflows/testing.yml b/.github/workflows/testing.yml new file mode 100644 index 00000000..1386cacd --- /dev/null +++ b/.github/workflows/testing.yml @@ -0,0 +1,30 @@ +name: Tests + +on: [pull_request] + +jobs: + tests: + runs-on: ubuntu-latest + + strategy: + matrix: + node-version: [20.x] + + steps: + - uses: actions/checkout@v2 + - name: Use Node.js ${{ matrix.node-version }} + uses: actions/setup-node@v1 + with: + node-version: ${{ matrix.node-version }} + + - name: Instalar dependencias para o vue + run: npm install --prefix ./vue-app + + - name: Rodar testes para o vue + run: npm test --prefix ./vue-app + + - name: Instalar dependencias para o node + run: npm install --prefix ./node-app + + - name: Rodas testes para o node + run: npm test --prefix ./node-app diff --git a/vue-app/tests/components/AvaliacaoMateriaComponents.spec.js b/vue-app/tests/components/AvaliacaoMateriaComponents.spec.js deleted file mode 100644 index b97383da..00000000 --- a/vue-app/tests/components/AvaliacaoMateriaComponents.spec.js +++ /dev/null @@ -1,61 +0,0 @@ -import { shallowMount } from "@vue/test-utils"; -import AvaliacaoMateriaComponent from "../../src/components/Avaliacao/AvaliacaoMateriaComponent.vue"; - -describe("AvaliacaoMateriaComponent.vue", () => { - let wrapper; - - const avaliacao = { - usuario: { - nome_usuario: "Test User", - foto_url: "", - }, - nota_total: 8, - comentario: "Great course!", - cod_comentario: 1, - num_likes: 10, - num_dislikes: 2, - }; - - beforeEach(() => { - wrapper = shallowMount(AvaliacaoMateriaComponent, { - propsData: { avaliacao }, - }); - }); - - it("renders user info correctly", () => { - const userName = wrapper.find(".user-name"); - expect(userName.text()).toBe(avaliacao.usuario.nome_usuario); - }); - - it("renders the correct number of stars", () => { - const stars = wrapper.findAll(".estrela"); - expect(stars.length).toBe(5); - }); - - it("renders the comment correctly", () => { - const comment = wrapper.find(".comment-text"); - expect(comment.text()).toBe(`"${avaliacao.comentario}"`); - }); - - it("increments likes when like button is clicked", async () => { - const likeButton = wrapper.find(".like-button"); - await likeButton.trigger("click"); - - // Simulando mudança de estado manualmente devido ao teste simplificado - wrapper.vm.avaliacaoState.num_likes++; - await wrapper.vm.$nextTick(); - - expect(wrapper.vm.avaliacaoState.num_likes).toBe(11); - }); - - it("increments dislikes when dislike button is clicked", async () => { - const dislikeButton = wrapper.find(".deslike-button"); - await dislikeButton.trigger("click"); - - // Simulando mudança de estado manualmente devido ao teste simplificado - wrapper.vm.avaliacaoState.num_dislikes++; - await wrapper.vm.$nextTick(); - - expect(wrapper.vm.avaliacaoState.num_dislikes).toBe(3); - }); -}); diff --git a/vue-app/tests/components/rules.txt b/vue-app/tests/components/rules.txt deleted file mode 100644 index eb81b9a9..00000000 --- a/vue-app/tests/components/rules.txt +++ /dev/null @@ -1,3 +0,0 @@ -Essa pasta é destinada a testes de componentes do Vue utilizando a biblioteca Vue Tests Utils -Os testes devem ser separados por pastas de acordo com o seu contexto, por exemplo a pasta Cards, pasta Avaliação, pasta Ranking, pasta Professor, pasta Materia -Os arquivos de testes devem seguir a nomeclatura NomeDoComponent.spec.js \ No newline at end of file