From adc7ed430d85a3633e2bfc595fcc3d881411e717 Mon Sep 17 00:00:00 2001 From: Benevanio Santos Date: Sun, 7 Jun 2026 18:54:49 -0300 Subject: [PATCH] =?UTF-8?q?feat(tests):=20corre=C3=A7=C3=A3o=20de=20contri?= =?UTF-8?q?buidores?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/components/landing/TeamSection.tsx | 101 +++++++++++++----- .../components/landing/TeamSection.test.tsx | 12 ++- 2 files changed, 81 insertions(+), 32 deletions(-) diff --git a/frontend/src/components/landing/TeamSection.tsx b/frontend/src/components/landing/TeamSection.tsx index 90e80e33..8ee366e2 100644 --- a/frontend/src/components/landing/TeamSection.tsx +++ b/frontend/src/components/landing/TeamSection.tsx @@ -1,10 +1,10 @@ import { useEffect, useState } from 'react'; +import { Autoplay, Pagination } from 'swiper/modules'; import { Swiper, SwiperSlide } from 'swiper/react'; -import { Pagination, Autoplay } from 'swiper/modules'; +import { Github } from 'lucide-react'; import 'swiper/css'; import 'swiper/css/pagination'; -import { Github } from 'lucide-react'; interface Contributor { id: number; @@ -31,6 +31,14 @@ const INITIAL_TEAM: Contributor[] = [ html_url: "https://github.com/PedroLucas1337", contributions: 0, type: "User" + }, + { + id: 110640572, + login: "thalitat", + avatar_url: "https://avatars.githubusercontent.com/u/110640572?v=4", + html_url: "https://github.com/thalitat", + contributions: 0, + type: "User" } ]; @@ -51,31 +59,59 @@ export default function TeamSection() { return res.json(); }) .then((data: unknown) => { - if (Array.isArray(data)) { - let realUsers = (data as Contributor[]) - .filter(user => user.type === 'User') - .map(user => { - if (user.login.toLowerCase() === "pedrolucas1337") { - return { ...user, avatar_url: "https://github.com/PedroLucas1337.png" }; - } - return user; - }); - - const hasPedro = realUsers.some(user => user.login.toLowerCase() === "pedrolucas1337"); - - if (!hasPedro) { - const pedroObj: Contributor = { - id: 104951475, - login: "PedroLucas1337", - avatar_url: "https://github.com/PedroLucas1337.png", - html_url: "https://github.com/PedroLucas1337", - contributions: 0, - type: "User" - }; - realUsers = [...realUsers, pedroObj]; + if (!Array.isArray(data)) return; + + const realUsers = (data as Contributor[]) + .filter(user => user.type === 'User') + .map(user => { + if (user.login.toLowerCase() === "pedrolucas1337") { + return { + ...user, + avatar_url: "https://github.com/PedroLucas1337.png" + }; + } + + if (user.login.toLowerCase() === "thalitat") { + return { + ...user, + avatar_url: "https://avatars.githubusercontent.com/u/110640572?v=4" + }; + } + + return user; + }); + + const fixedMembers: Contributor[] = [ + { + id: 104951475, + login: "PedroLucas1337", + avatar_url: "https://github.com/PedroLucas1337.png", + html_url: "https://github.com/PedroLucas1337", + contributions: 0, + type: "User" + }, + { + id: 110640572, + login: "thalitat", + avatar_url: "https://avatars.githubusercontent.com/u/110640572?v=4", + html_url: "https://github.com/thalitat", + contributions: 0, + type: "User" + } + ]; + + fixedMembers.forEach(member => { + const exists = realUsers.some( + user => user.login.toLowerCase() === member.login.toLowerCase() + ); + + if (!exists) { + realUsers.push(member); } + }); - if (realUsers.length > 0) setContributors(realUsers); + if (realUsers.length > 0) { + setContributors(realUsers); } }) .catch((err) => { @@ -92,7 +128,7 @@ export default function TeamSection() {
Conheça as mentes brilhantes por trás do{" "} - + < Cand!Date! > @@ -122,22 +158,29 @@ export default function TeamSection() { {contributors.map((user) => (
+
{user.login} +

{user.login}

- {user.login.toLowerCase() === "pedrolucas1337" + {user.login.toLowerCase() === "benevanio" + ? "Founder & Backend Dev" + : user.login.toLowerCase() === "pedrolucas1337" ? "QA" + : user.login.toLowerCase() === "thalitat" + ? "UX/UI Designer" : `${user.contributions} ${user.contributions === 1 ? 'commit' : 'commits'}`}

+ Ver Perfil - +
@@ -164,4 +207,4 @@ export default function TeamSection() { `} ); -} +} \ No newline at end of file diff --git a/frontend/tests/unit/components/landing/TeamSection.test.tsx b/frontend/tests/unit/components/landing/TeamSection.test.tsx index e4cfd3d1..a9cd7e64 100644 --- a/frontend/tests/unit/components/landing/TeamSection.test.tsx +++ b/frontend/tests/unit/components/landing/TeamSection.test.tsx @@ -19,7 +19,7 @@ describe("TeamSection", () => { vi.restoreAllMocks(); }); - it("renderiza lista da API, filtra bots e garante presença do Pedro", async () => { + it("renderiza lista da API, filtra bots e garante presença de membros fixos", async () => { vi.spyOn(globalThis, "fetch").mockResolvedValue({ ok: true, json: async () => [ @@ -49,9 +49,13 @@ describe("TeamSection", () => { }); expect(screen.queryByText("bot-user")).not.toBeInTheDocument(); + + // membros fixos expect(screen.getByText("PedroLucas1337")).toBeInTheDocument(); + expect(screen.getByText("thalitat")).toBeInTheDocument(); + expect(screen.getByText("QA")).toBeInTheDocument(); - expect(screen.getByText("1 commit")).toBeInTheDocument(); + expect(screen.getByText("UX/UI Designer")).toBeInTheDocument(); }); it("mantém fallback local quando API retorna resposta inválida", async () => { @@ -117,6 +121,7 @@ describe("TeamSection", () => { await waitFor(() => { expect(screen.getByText("Benevanio")).toBeInTheDocument(); expect(screen.getByText("PedroLucas1337")).toBeInTheDocument(); + expect(screen.getByText("thalitat")).toBeInTheDocument(); }); }); @@ -175,6 +180,7 @@ describe("TeamSection", () => { await waitFor(() => { expect(screen.getByText("Benevanio")).toBeInTheDocument(); expect(screen.getByText("PedroLucas1337")).toBeInTheDocument(); + expect(screen.getByText("thalitat")).toBeInTheDocument(); }); }); -}); +}); \ No newline at end of file