Skip to content

Commit cbc411e

Browse files
authored
feat(tests): correção de contribuidores (#112)
2 parents 26a5db8 + adc7ed4 commit cbc411e

2 files changed

Lines changed: 81 additions & 32 deletions

File tree

frontend/src/components/landing/TeamSection.tsx

Lines changed: 72 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
import { useEffect, useState } from 'react';
2+
import { Autoplay, Pagination } from 'swiper/modules';
23
import { Swiper, SwiperSlide } from 'swiper/react';
3-
import { Pagination, Autoplay } from 'swiper/modules';
44

5+
import { Github } from 'lucide-react';
56
import 'swiper/css';
67
import 'swiper/css/pagination';
7-
import { Github } from 'lucide-react';
88

99
interface Contributor {
1010
id: number;
@@ -31,6 +31,14 @@ const INITIAL_TEAM: Contributor[] = [
3131
html_url: "https://github.com/PedroLucas1337",
3232
contributions: 0,
3333
type: "User"
34+
},
35+
{
36+
id: 110640572,
37+
login: "thalitat",
38+
avatar_url: "https://avatars.githubusercontent.com/u/110640572?v=4",
39+
html_url: "https://github.com/thalitat",
40+
contributions: 0,
41+
type: "User"
3442
}
3543
];
3644

@@ -51,31 +59,59 @@ export default function TeamSection() {
5159
return res.json();
5260
})
5361
.then((data: unknown) => {
54-
if (Array.isArray(data)) {
55-
let realUsers = (data as Contributor[])
56-
.filter(user => user.type === 'User')
57-
.map(user => {
58-
if (user.login.toLowerCase() === "pedrolucas1337") {
59-
return { ...user, avatar_url: "https://github.com/PedroLucas1337.png" };
60-
}
61-
return user;
62-
});
63-
64-
const hasPedro = realUsers.some(user => user.login.toLowerCase() === "pedrolucas1337");
65-
66-
if (!hasPedro) {
67-
const pedroObj: Contributor = {
68-
id: 104951475,
69-
login: "PedroLucas1337",
70-
avatar_url: "https://github.com/PedroLucas1337.png",
71-
html_url: "https://github.com/PedroLucas1337",
72-
contributions: 0,
73-
type: "User"
74-
};
75-
realUsers = [...realUsers, pedroObj];
62+
if (!Array.isArray(data)) return;
63+
64+
const realUsers = (data as Contributor[])
65+
.filter(user => user.type === 'User')
66+
.map(user => {
67+
if (user.login.toLowerCase() === "pedrolucas1337") {
68+
return {
69+
...user,
70+
avatar_url: "https://github.com/PedroLucas1337.png"
71+
};
72+
}
73+
74+
if (user.login.toLowerCase() === "thalitat") {
75+
return {
76+
...user,
77+
avatar_url: "https://avatars.githubusercontent.com/u/110640572?v=4"
78+
};
79+
}
80+
81+
return user;
82+
});
83+
84+
const fixedMembers: Contributor[] = [
85+
{
86+
id: 104951475,
87+
login: "PedroLucas1337",
88+
avatar_url: "https://github.com/PedroLucas1337.png",
89+
html_url: "https://github.com/PedroLucas1337",
90+
contributions: 0,
91+
type: "User"
92+
},
93+
{
94+
id: 110640572,
95+
login: "thalitat",
96+
avatar_url: "https://avatars.githubusercontent.com/u/110640572?v=4",
97+
html_url: "https://github.com/thalitat",
98+
contributions: 0,
99+
type: "User"
100+
}
101+
];
102+
103+
fixedMembers.forEach(member => {
104+
const exists = realUsers.some(
105+
user => user.login.toLowerCase() === member.login.toLowerCase()
106+
);
107+
108+
if (!exists) {
109+
realUsers.push(member);
76110
}
111+
});
77112

78-
if (realUsers.length > 0) setContributors(realUsers);
113+
if (realUsers.length > 0) {
114+
setContributors(realUsers);
79115
}
80116
})
81117
.catch((err) => {
@@ -92,7 +128,7 @@ export default function TeamSection() {
92128

93129
<div className="text-gray-500 dark:text-gray-400 mb-10 text-sm sm:text-base">
94130
Conheça as mentes brilhantes por trás do{" "}
95-
<span className='font-bold text-gray-800 dark:text-white inline-block block sm:inline'>
131+
<span className='font-bold text-gray-800 dark:text-white inline-block sm:inline'>
96132
<span className="text-blue-500 font-bold">&lt;</span>
97133
Cand<span className="text-amber-500 font-bold">!</span>Date<span className="text-purple-500 font-bold">!</span>
98134
<span className="text-blue-500 font-bold">&gt;</span>
@@ -122,30 +158,37 @@ export default function TeamSection() {
122158
{contributors.map((user) => (
123159
<SwiperSlide key={user.id} className="h-full inline-block">
124160
<div className="flex flex-col items-center p-6 border border-gray-100 dark:border-zinc-800/80 rounded-2xl text-center bg-white dark:bg-zinc-900/40 backdrop-blur-sm shadow-sm hover:shadow-md transition-all duration-300 min-h-[260px] h-full justify-between">
161+
125162
<div className="flex flex-col items-center w-full">
126163
<img
127164
src={user.avatar_url}
128165
alt={user.login}
129166
className="w-24 h-24 rounded-full mb-4 border-2 border-violet-500/60 shadow-sm object-cover"
130167
/>
168+
131169
<h4 className="font-semibold text-lg text-gray-900 dark:text-zinc-100 mb-1 truncate w-full">
132170
{user.login}
133171
</h4>
134172

135173
<p className="text-xs font-medium text-gray-400 dark:text-zinc-500 mb-4">
136-
{user.login.toLowerCase() === "pedrolucas1337"
174+
{user.login.toLowerCase() === "benevanio"
175+
? "Founder & Backend Dev"
176+
: user.login.toLowerCase() === "pedrolucas1337"
137177
? "QA"
178+
: user.login.toLowerCase() === "thalitat"
179+
? "UX/UI Designer"
138180
: `${user.contributions} ${user.contributions === 1 ? 'commit' : 'commits'}`}
139181
</p>
140182
</div>
183+
141184
<a
142185
href={user.html_url}
143186
target="_blank"
144187
rel="noreferrer"
145188
className="w-full py-2 px-4 bg-gradient-to-r from-blue-600 via-indigo-600 to-violet-600 hover:opacity-90 text-white flex items-center justify-center text-sm font-medium rounded-lg transition-all duration-200 gap-2 shadow-sm"
146189
>
147190
Ver Perfil
148-
<Github className='h-4 w-4 flex justify-center items-center'/>
191+
<Github className='h-4 w-4' />
149192
</a>
150193
</div>
151194
</SwiperSlide>
@@ -164,4 +207,4 @@ export default function TeamSection() {
164207
`}</style>
165208
</section>
166209
);
167-
}
210+
}

frontend/tests/unit/components/landing/TeamSection.test.tsx

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ describe("TeamSection", () => {
1919
vi.restoreAllMocks();
2020
});
2121

22-
it("renderiza lista da API, filtra bots e garante presença do Pedro", async () => {
22+
it("renderiza lista da API, filtra bots e garante presença de membros fixos", async () => {
2323
vi.spyOn(globalThis, "fetch").mockResolvedValue({
2424
ok: true,
2525
json: async () => [
@@ -49,9 +49,13 @@ describe("TeamSection", () => {
4949
});
5050

5151
expect(screen.queryByText("bot-user")).not.toBeInTheDocument();
52+
53+
// membros fixos
5254
expect(screen.getByText("PedroLucas1337")).toBeInTheDocument();
55+
expect(screen.getByText("thalitat")).toBeInTheDocument();
56+
5357
expect(screen.getByText("QA")).toBeInTheDocument();
54-
expect(screen.getByText("1 commit")).toBeInTheDocument();
58+
expect(screen.getByText("UX/UI Designer")).toBeInTheDocument();
5559
});
5660

5761
it("mantém fallback local quando API retorna resposta inválida", async () => {
@@ -117,6 +121,7 @@ describe("TeamSection", () => {
117121
await waitFor(() => {
118122
expect(screen.getByText("Benevanio")).toBeInTheDocument();
119123
expect(screen.getByText("PedroLucas1337")).toBeInTheDocument();
124+
expect(screen.getByText("thalitat")).toBeInTheDocument();
120125
});
121126
});
122127

@@ -175,6 +180,7 @@ describe("TeamSection", () => {
175180
await waitFor(() => {
176181
expect(screen.getByText("Benevanio")).toBeInTheDocument();
177182
expect(screen.getByText("PedroLucas1337")).toBeInTheDocument();
183+
expect(screen.getByText("thalitat")).toBeInTheDocument();
178184
});
179185
});
180-
});
186+
});

0 commit comments

Comments
 (0)