Stats card: show started and answered discussions stats (#2849)

* Stats card: show started and answered discussions stats

* trans

* dev
This commit is contained in:
Alexandr Garbuzov
2023-06-19 05:51:58 +02:00
committed by GitHub
parent a5260cb38a
commit 92518e375f
9 changed files with 137 additions and 7 deletions
+8
View File
@@ -12,6 +12,9 @@ const stats = {
totalCommits: 200,
totalIssues: 300,
totalPRs: 400,
totalReviews: 50,
totalDiscussionsStarted: 10,
totalDiscussionsAnswered: 40,
contributedTo: 50,
rank: null,
};
@@ -33,11 +36,16 @@ const data_stats = {
repositoriesContributedTo: { totalCount: stats.contributedTo },
contributionsCollection: {
totalCommitContributions: stats.totalCommits,
totalPullRequestReviewContributions: stats.totalReviews,
},
pullRequests: { totalCount: stats.totalPRs },
openIssues: { totalCount: stats.totalIssues },
closedIssues: { totalCount: 0 },
followers: { totalCount: 0 },
repositoryDiscussions: { totalCount: stats.totalDiscussionsStarted },
repositoryDiscussionComments: {
totalCount: stats.totalDiscussionsAnswered,
},
repositories: {
totalCount: 1,
nodes: [{ stargazers: { totalCount: 100 } }],
+16
View File
@@ -18,6 +18,8 @@ const data_stats = {
openIssues: { totalCount: 100 },
closedIssues: { totalCount: 100 },
followers: { totalCount: 100 },
repositoryDiscussions: { totalCount: 10 },
repositoryDiscussionComments: { totalCount: 40 },
repositories: {
totalCount: 5,
nodes: [
@@ -119,6 +121,8 @@ describe("Test fetchStats", () => {
totalPRs: 300,
totalReviews: 50,
totalStars: 300,
totalDiscussionsStarted: 10,
totalDiscussionsAnswered: 40,
rank,
});
});
@@ -150,6 +154,8 @@ describe("Test fetchStats", () => {
totalPRs: 300,
totalReviews: 50,
totalStars: 300,
totalDiscussionsStarted: 10,
totalDiscussionsAnswered: 40,
rank,
});
});
@@ -187,6 +193,8 @@ describe("Test fetchStats", () => {
totalPRs: 300,
totalReviews: 50,
totalStars: 300,
totalDiscussionsStarted: 10,
totalDiscussionsAnswered: 40,
rank,
});
});
@@ -215,6 +223,8 @@ describe("Test fetchStats", () => {
totalPRs: 300,
totalReviews: 50,
totalStars: 200,
totalDiscussionsStarted: 10,
totalDiscussionsAnswered: 40,
rank,
});
});
@@ -241,6 +251,8 @@ describe("Test fetchStats", () => {
totalPRs: 300,
totalReviews: 50,
totalStars: 400,
totalDiscussionsStarted: 10,
totalDiscussionsAnswered: 40,
rank,
});
});
@@ -267,6 +279,8 @@ describe("Test fetchStats", () => {
totalPRs: 300,
totalReviews: 50,
totalStars: 300,
totalDiscussionsStarted: 10,
totalDiscussionsAnswered: 40,
rank,
});
});
@@ -293,6 +307,8 @@ describe("Test fetchStats", () => {
totalPRs: 300,
totalReviews: 50,
totalStars: 300,
totalDiscussionsStarted: 10,
totalDiscussionsAnswered: 40,
rank,
});
});
+15 -3
View File
@@ -17,6 +17,8 @@ const stats = {
totalIssues: 300,
totalPRs: 400,
totalReviews: 50,
totalDiscussionsStarted: 10,
totalDiscussionsAnswered: 50,
contributedTo: 500,
rank: { level: "A+", score: 40 },
};
@@ -42,6 +44,12 @@ describe("Test renderStatsCard", () => {
// Default hidden stats
expect(queryByTestId(document.body, "reviews")).not.toBeInTheDocument();
expect(
queryByTestId(document.body, "discussions_started"),
).not.toBeInTheDocument();
expect(
queryByTestId(document.body, "discussions_answered"),
).not.toBeInTheDocument();
});
it("should have proper name apostrophe", () => {
@@ -73,16 +81,18 @@ describe("Test renderStatsCard", () => {
expect(queryByTestId(document.body, "prs")).toBeNull();
expect(queryByTestId(document.body, "contribs")).toBeNull();
expect(queryByTestId(document.body, "reviews")).toBeNull();
expect(queryByTestId(document.body, "discussions_started")).toBeNull();
expect(queryByTestId(document.body, "discussions_answered")).toBeNull();
});
it("should show total reviews", () => {
it("should show additional stats", () => {
document.body.innerHTML = renderStatsCard(stats, {
show: ["reviews"],
show: ["reviews", "discussions_started", "discussions_answered"],
});
expect(
document.body.getElementsByTagName("svg")[0].getAttribute("height"),
).toBe("220");
).toBe("270");
expect(queryByTestId(document.body, "stars")).toBeDefined();
expect(queryByTestId(document.body, "commits")).toBeDefined();
@@ -90,6 +100,8 @@ describe("Test renderStatsCard", () => {
expect(queryByTestId(document.body, "prs")).toBeDefined();
expect(queryByTestId(document.body, "contribs")).toBeDefined();
expect(queryByTestId(document.body, "reviews")).toBeDefined();
expect(queryByTestId(document.body, "discussions_started")).toBeDefined();
expect(queryByTestId(document.body, "discussions_answered")).toBeDefined();
});
it("should hide_rank", () => {