Skip to content

Commit b2fa1d3

Browse files
Merge pull request #1027 from dacadeorg/test/add-testing
test: add testing for ui components
2 parents 45d5cbb + 99bb32a commit b2fa1d3

File tree

105 files changed

+3941
-220
lines changed

Some content is hidden

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

105 files changed

+3941
-220
lines changed

.github/workflows/ci.yml

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
name: ci
2+
3+
on: ["push", "pull_request"]
4+
5+
jobs:
6+
build:
7+
runs-on: ubuntu-latest
8+
steps:
9+
- uses: actions/checkout@v4
10+
- uses: actions/setup-node@v4
11+
with:
12+
node-version: "21.0.0"
13+
cache: "yarn"
14+
15+
- name: Install dependencies
16+
run: yarn --frozen-lockfile
17+
18+
- name: Setup environment variables
19+
run: |
20+
echo "NEXT_PUBLIC_FIREBASE_API_KEY=${{ secrets.NEXT_PUBLIC_FIREBASE_API_KEY }}" >> $GITHUB_ENV
21+
echo "NEXT_PUBLIC_FIREBASE_AUTH_DOMAIN=${{ secrets.NEXT_PUBLIC_FIREBASE_AUTH_DOMAIN }}" >> $GITHUB_ENV
22+
echo "NEXT_PUBLIC_FIREBASE_PROJECT_ID=${{ secrets.NEXT_PUBLIC_FIREBASE_PROJECT_ID }}" >> $GITHUB_ENV
23+
echo "NEXT_PUBLIC_FIREBASE_APP_ID=${{ secrets.NEXT_PUBLIC_FIREBASE_APP_ID }}" >> $GITHUB_ENV
24+
echo "NEXT_PUBLIC_API_BASE_URL=${{ secrets.NEXT_PUBLIC_API_BASE_URL }}" >> $GITHUB_ENV
25+
echo "NEXT_PUBLIC_BUGSNAG_API_KEY=${{ secrets.NEXT_PUBLIC_BUGSNAG_API_KEY }}" >> $GITHUB_ENV
26+
echo "NEXT_PUBLIC_SHOW_LANGUAGE_SELECTOR=${{ secrets.NEXT_PUBLIC_SHOW_LANGUAGE_SELECTOR }}" >> $GITHUB_ENV
27+
echo "NEXT_PUBLIC_DISCORD_CLIENT_ID=${{ secrets.NEXT_PUBLIC_DISCORD_CLIENT_ID }}" >> $GITHUB_ENV
28+
echo "NEXT_PUBLIC_DISCORD_CALLBACK_URL=${{ secrets.NEXT_PUBLIC_DISCORD_CALLBACK_URL }}" >> $GITHUB_ENV
29+
echo "NEXT_PUBLIC_DISCORD_OAUTH_BASE_URL=${{ secrets.NEXT_PUBLIC_DISCORD_OAUTH_BASE_URL }}" >> $GITHUB_ENV
30+
echo "NEXT_PUBLIC_DISCORD_SCOPE=${{ secrets.NEXT_PUBLIC_DISCORD_SCOPE }}" >> $GITHUB_ENV
31+
echo "NEXT_PUBLIC_GOOGLE_TRANSLATE_API_KEY=${{ secrets.NEXT_PUBLIC_GOOGLE_TRANSLATE_API_KEY }}" >> $GITHUB_ENV
32+
echo "NEXT_PUBLIC_BLOCK_EXPLORER_URL=${{ secrets.NEXT_PUBLIC_BLOCK_EXPLORER_URL }}" >> $GITHUB_ENV
33+
echo "NEXT_PUBLIC_IPFS_URL=${{ secrets.NEXT_PUBLIC_IPFS_URL }}" >> $GITHUB_ENV
34+
35+
- name: Run tests
36+
run: yarn test

.nvmrc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
v18.14.0
1+
v21.0.0

__mocks__/colors.ts

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
export const colors = {
2+
textAccent: "--tm-text",
3+
text: "--tm-text",
4+
accent: "--tm-accent",
5+
primary: "--tm-primary",
6+
secondary: "--tm-secondary",
7+
highlight: "--tm-highlight",
8+
muted: "--tm-muted",
9+
cover: {
10+
text: "--tm-text",
11+
accent: "--tm-accent",
12+
primary: "--tm-primary",
13+
background: "--tm-background",
14+
},
15+
};

__mocks__/link.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
export const link = {
2+
url: "https://example.com",
3+
title: "Example Link",
4+
icon: "discord",
5+
};

__mocks__/plugin.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export default function remarkPlugin() {}

__mocks__/provider/handlers.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
import { http, HttpResponse, delay } from "msw";
2+
3+
export const handlers = [
4+
http.get("/api/communities", async () => {
5+
await delay(150);
6+
console.log("Called called called");
7+
return HttpResponse.json({ community: {} });
8+
}),
9+
];

__mocks__/react-markdown.tsx

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
2+
// @ts-ignore
3+
export default function Mardown({ children }) {
4+
return <>{children}</>;
5+
}

__mocks__/renderWithRedux.tsx

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
import { IRootState, middlewares, reducers } from "@/store";
2+
import { configureStore } from "@reduxjs/toolkit";
3+
import { ReactElement, ReactNode } from "react";
4+
import { Provider } from "react-redux";
5+
import { render } from "@testing-library/react";
6+
7+
const mockStore = (state: Partial<IRootState>) => {
8+
return configureStore({
9+
reducer: reducers,
10+
middleware: (getDefaultMiddleware) => {
11+
return getDefaultMiddleware().concat(...middlewares);
12+
},
13+
preloadedState: state,
14+
});
15+
};
16+
17+
export const renderWithRedux = (component: ReactElement, state: Partial<IRootState> = {}) => {
18+
const Wrapper = ({ children }: { children: ReactNode }) => {
19+
return <Provider store={mockStore(state)}>{children}</Provider>;
20+
};
21+
22+
return render(component, { wrapper: Wrapper });
23+
};

__mocks__/reward.ts

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
export const reward = {
2+
id: "id",
3+
ref: "ref",
4+
created_at: new Date("2024-01-29T08:00:00Z"),
5+
updated_at: new Date("2024-01-29T08:00:00Z"),
6+
challenge: "challenge",
7+
type: "challenge type",
8+
community: "community",
9+
token: "token",
10+
stable: false,
11+
amount: 10,
12+
timestamp: 10,
13+
};

__mocks__/svg.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
const ReactComponent = "div";
2+
export default ReactComponent;

0 commit comments

Comments
 (0)