Skip to content

Commit 37b7c3e

Browse files
committed
Merge branch 'dev' into test/list-view-for-submissions
2 parents 6b0db3b + 26fda2b commit 37b7c3e

File tree

109 files changed

+513
-293
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

109 files changed

+513
-293
lines changed

CONTRIBUTING.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,7 @@ They can also be given class names as shown in the above image.
144144

145145
```javascript
146146
<div
147-
className={classNames("w-1/3", "bg-primary", {
147+
className={classNames("w-1/3", "bg-brand", {
148148
"text-white": type === "default",
149149
underline: hasLink,
150150
})}

__mocks__/fixtures/challenge.ts

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
import { mockFormat, mockCertificateData, mockCourse, mockLearningModule, mockRatingCriteria } from "./course";
22
import { mockCommunity, mockMetadata } from "./community";
33
import { reward } from "./reward";
4-
import { Submission } from "@/types/bounty";
4+
import { Evaluation, Submission } from "@/types/bounty";
55
import { AdditionalInfo, Challenge } from "@/types/course";
6-
import { TEAM_FORMATION } from "@/constants/challengeInfo";
6+
import { GRADING_CRITERIA, TEAM_FORMATION } from "@/constants/challengeInfo";
77
import { Team, TeamMember } from "@/types/challenge";
88
import { Feedback } from "@/types/feedback";
99
import { mockUser } from "./user";
@@ -51,6 +51,22 @@ export const challenge: Challenge = {
5151
type: "teamFormation",
5252
text: "Form your team details here",
5353
},
54+
[GRADING_CRITERIA]: { type: "teamFormation", text: "Sample grading criteria text" },
55+
},
56+
};
57+
export const evaluation: Evaluation = {
58+
evaluator: mockUser,
59+
created_at: new Date("2022-05-01T12:00:00Z"),
60+
comment: "comment",
61+
criteria: [],
62+
metadata: {
63+
language: "language",
64+
},
65+
points: 10,
66+
totalPoints: 1,
67+
reward: {
68+
amount: 10,
69+
token: "token",
5470
},
5571
};
5672

@@ -89,6 +105,7 @@ export const submission: Submission = {
89105
totalPoints: 10,
90106
},
91107
},
108+
evaluation: evaluation,
92109
timestamp: 0,
93110
user: mockUser,
94111
reviewable: false,
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
import "@testing-library/jest-dom";
2+
import { screen } from "@testing-library/react";
3+
import { challenge, submission } from "@__mocks__/fixtures/challenge";
4+
import { renderWithRedux } from "../../../../__mocks__/renderWithRedux";
5+
import BestSubmissions from "@/components/sections/submissions/BestSubmissions";
6+
7+
jest.mock("next/router", () => ({
8+
useRouter: () => ({
9+
asPath: "next",
10+
query: { challenge_id: "test-challenge-id", slug: "test-community-slug" },
11+
pathname: "/communities/test-community-slug/challenges/test-challenge-id",
12+
}),
13+
}));
14+
15+
const mockBestSubmissions = {
16+
challenges: {
17+
current: {
18+
...challenge,
19+
bestSubmissions: [submission],
20+
},
21+
list: [challenge],
22+
submission: submission,
23+
loading: true,
24+
},
25+
};
26+
27+
describe("BestSubmissions Component", () => {
28+
it("Should render best submissions when they exist", () => {
29+
renderWithRedux(<BestSubmissions testId="bestSubmissionId" />, mockBestSubmissions);
30+
const bestSubmission = screen.getByTestId("bestSubmissionId");
31+
expect(bestSubmission).toBeInTheDocument();
32+
mockBestSubmissions.challenges.current.bestSubmissions.forEach((submission) => {
33+
expect(screen.getByText(submission.text)).toBeInTheDocument();
34+
});
35+
});
36+
37+
it("Should render the link to submissions path", () => {
38+
renderWithRedux(<BestSubmissions testId="bestSubmissionId" />, mockBestSubmissions);
39+
const link = screen.getByRole("link", { name: /challenge.best-submissions.button/i });
40+
expect(link).toHaveAttribute("href", "/communities/test-community-slug/challenges/test-challenge-id/submissions");
41+
});
42+
});
Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
import Evaluations from "@/components/sections/submissions/Evaluation";
2+
import { challenge, submission } from "@__mocks__/fixtures/challenge";
3+
import { colors } from "@__mocks__/fixtures/colors";
4+
import { renderWithRedux } from "@__mocks__/renderWithRedux";
5+
import "@testing-library/jest-dom";
6+
import { screen } from "@testing-library/react";
7+
8+
jest.mock("next/router", () => ({
9+
useRouter: () => ({
10+
asPath: "next",
11+
}),
12+
}));
13+
14+
const mockEvaluationState = {
15+
ui: { colors: colors, locked: false, showReferralPopup: false, showJobOffersPopup: false },
16+
submissions: {
17+
current: {
18+
...submission,
19+
},
20+
list: [submission],
21+
text: "",
22+
},
23+
challenges: { current: challenge, list: [challenge], submission: submission, loading: false },
24+
};
25+
26+
describe("Evaluations", () => {
27+
it("Should render evaluations", () => {
28+
renderWithRedux(<Evaluations />, mockEvaluationState);
29+
const evaluations = screen.getByTestId("evaluationsId");
30+
expect(evaluations).toBeInTheDocument();
31+
});
32+
33+
it("Should render RatingRubric when the challenge is present", () => {
34+
renderWithRedux(<Evaluations />, mockEvaluationState);
35+
const ratingCriteriaName = challenge.ratingCriteria[0].name;
36+
const ratingRubric = screen.getByText(ratingCriteriaName);
37+
expect(ratingRubric).toBeInTheDocument();
38+
});
39+
40+
it("Should conditionally render reward information when evaluation reward is present and the challenge is not a hackathon", () => {
41+
const nonHackathonState = {
42+
...mockEvaluationState,
43+
challenges: {
44+
...mockEvaluationState.challenges,
45+
current: { ...challenge, isHackathon: false },
46+
},
47+
};
48+
49+
renderWithRedux(<Evaluations />, nonHackathonState);
50+
const token = submission.evaluation?.reward?.token;
51+
if (token) {
52+
expect(screen.getByText(token)).toBeInTheDocument();
53+
}
54+
});
55+
56+
it("Should conditionally render reward information when evaluation.reward is present and challenge is a hackathon", () => {
57+
const hackathonState = {
58+
...mockEvaluationState,
59+
challenges: {
60+
...mockEvaluationState.challenges,
61+
current: { ...challenge, isHackathon: true },
62+
},
63+
};
64+
65+
renderWithRedux(<Evaluations />, hackathonState);
66+
expect(screen.getByText("USD")).toBeInTheDocument();
67+
expect(screen.getByText("communities.challenge.evaluation.message.nominated")).toBeInTheDocument();
68+
});
69+
});

public/locales/bg/common.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
"page.index.communities.title": "Communities of Practice",
3232
"page.index.communities.subtitle": "In our communities, you will work with your peers to learn and build amazing projects using blockchain technology.",
3333
"page.index.communities.partnering.title": "Your community here",
34-
"page.index.communities.partnering.subtitle": "We know that developer community growth is a top priority for software projects in this highly competitive space; that's why we created dacade.",
34+
"page.index.communities.partnering.subtitle": "We know that developer community growth is a top priority for software projects in this highly competitive space, that's why we created dacade.",
3535
"page.index.communities.partnering.button-text": "Become a partner",
3636
"page.protocols.title.1": "Developer Adoption",
3737
"page.protocols.title.2": " through Peer-to-Peer education",

public/locales/en/common.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
"page.index.communities.title": "Communities of Practice",
3232
"page.index.communities.subtitle": "In our communities, you will work with your peers to learn and build amazing projects using blockchain technology.",
3333
"page.index.communities.partnering.title": "Your community here",
34-
"page.index.communities.partnering.subtitle": "We know that developer community growth is a top priority for software projects in this highly competitive space; that's why we created dacade.",
34+
"page.index.communities.partnering.subtitle": "We know that developer community growth is a top priority for software projects in this highly competitive space, that's why we created dacade.",
3535
"page.index.communities.partnering.button-text": "Become a partner",
3636
"page.protocols.title.1": "Developer Adoption",
3737
"page.protocols.title.2": " through Peer-to-Peer education",

public/locales/hr/common.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
"page.index.communities.title": "Communities of Practice",
3232
"page.index.communities.subtitle": "In our communities, you will work with your peers to learn and build amazing projects using blockchain technology.",
3333
"page.index.communities.partnering.title": "Your community here",
34-
"page.index.communities.partnering.subtitle": "We know that developer community growth is a top priority for software projects in this highly competitive space; that's why we created dacade.",
34+
"page.index.communities.partnering.subtitle": "We know that developer community growth is a top priority for software projects in this highly competitive space, that's why we created dacade.",
3535
"page.index.communities.partnering.button-text": "Become a partner",
3636
"page.protocols.title.1": "Developer Adoption",
3737
"page.protocols.title.2": " through Peer-to-Peer education",

src/components/banner/PrivacyPolicy.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ export default function PrivacyPolicyBanner(): ReactElement {
3333

3434
if (showBanner)
3535
return (
36-
<div className="fixed bottom-0 left-0 right-0 z-999 flex flex-row justify-center md:justify-between bg-primary">
36+
<div className="fixed bottom-0 left-0 right-0 z-999 flex flex-row justify-center md:justify-between bg-brand">
3737
<div className="text-white py-8 text-center mx-auto lg:text-base text-sm md:text-lg justify-center md:max-w-none px-6">
3838
{t("signup-page.privacy.text")}{" "}
3939
<Link href="/privacy-policy" className="underline">

src/components/cards/Address.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ interface AddressProps {
2727
export default function Address({ hasAddress }: AddressProps): ReactElement {
2828
const { t } = useTranslation();
2929
return (
30-
<div className="lg:pt-5 sm:pt-5 md:pt-5 pt-14 absolute text-sm lg:text-gray-700 md:text-gray-700 sm:text-gray-700 cursor-pointer text-primary font-medium lg:font-normal md:font-normal sm:font-normal">
30+
<div className="lg:pt-5 sm:pt-5 md:pt-5 pt-14 absolute text-sm lg:text-gray-700 md:text-gray-700 sm:text-gray-700 cursor-pointer text-brand font-medium lg:font-normal md:font-normal sm:font-normal">
3131
{hasAddress ? (
3232
<div>
3333
<Link href="#">{t("profile.wallets.address-set")}</Link>

src/components/cards/Balance.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ export default function Balance({ details }: BalanceProps): ReactElement {
3131

3232
return (
3333
<Link href="/profile/wallets">
34-
<div className="flex px-5 py-3 -mx-5 space-x-3 text-left hover:bg-gray-50">
34+
<div className="flex px-5 py-3 -mx-5 space-x-3 text-left hover:bg-secondary">
3535
<Coin token={details.token} size="medium" />
3636
<div className="w-3/4 pt-1">
3737
<div className="flex justify-between">

0 commit comments

Comments
 (0)