From 87789f53487589c705c6b32cfacabd629dc8bd30 Mon Sep 17 00:00:00 2001 From: SamTheKorean Date: Fri, 22 Nov 2024 20:29:28 -0500 Subject: [PATCH 1/8] feat : convert profileurl to pass as prop --- src/components/Aside/Aside.stories.tsx | 47 ++++++++++++ src/components/Aside/Aside.test.tsx | 63 ++++++++++++++++ src/components/Aside/Aside.tsx | 92 +++++++++++++++++++++++ src/components/Progress/Progress.test.tsx | 38 ++++++++-- src/components/Progress/Progress.tsx | 46 ++++-------- src/components/Sidebar/Sidebar.module.css | 8 ++ 6 files changed, 255 insertions(+), 39 deletions(-) create mode 100644 src/components/Aside/Aside.stories.tsx create mode 100644 src/components/Aside/Aside.test.tsx create mode 100644 src/components/Aside/Aside.tsx diff --git a/src/components/Aside/Aside.stories.tsx b/src/components/Aside/Aside.stories.tsx new file mode 100644 index 00000000..3820d94c --- /dev/null +++ b/src/components/Aside/Aside.stories.tsx @@ -0,0 +1,47 @@ +import type { Meta, StoryObj } from "@storybook/react"; +import Aside from "./Aside"; +import { Grade } from "../../api/services/common/types.ts"; + +const meta = { + component: Aside, +} satisfies Meta; + +export default meta; + +export const Default: StoryObj = { + args: { + githubUsername: "testuser", + easyTasks: "5/10", + mediumTasks: "8/10", + hardTasks: "3/5", + solvedTasks: 16, + totalTasks: 25, + profile_url: "https://example.com/profile.jpg", // Provide a valid URL or mock + cohort: 3, + grade: Grade.SMALL_TREE, // Assign an appropriate grade here + }, +}; + +export const HighProgress: StoryObj = { + args: { + ...Default.args, + solvedTasks: 28, + totalTasks: 30, + easyTasks: "10/10", + mediumTasks: "10/10", + hardTasks: "8/10", + grade: Grade.BIG_TREE, // Higher grade for more progress + }, +}; + +export const NoTasks: StoryObj = { + args: { + ...Default.args, + easyTasks: "0/0", + mediumTasks: "0/0", + hardTasks: "0/0", + solvedTasks: 0, + totalTasks: 0, + grade: Grade.SEED, // Minimal grade due to no tasks solved + }, +}; diff --git a/src/components/Aside/Aside.test.tsx b/src/components/Aside/Aside.test.tsx new file mode 100644 index 00000000..0e347a08 --- /dev/null +++ b/src/components/Aside/Aside.test.tsx @@ -0,0 +1,63 @@ +import { test, expect } from "vitest"; +import { render, screen } from "@testing-library/react"; +import Aside from "./Aside"; +import { Grade } from "../../api/services/common/types.ts"; + +test("renders the Aside component", () => { + render( +