Skip to content

Commit

Permalink
Minor changes (#28)
Browse files Browse the repository at this point in the history
* New : Sharp 플로그인 추가

* Refactor : Favicon 변경

* Refactor : Favicon 변경

* Refactor : 브랜드 명 추가

* Refactor : 테스트 제거 [임시]
  • Loading branch information
jobkaeHenry authored Nov 11, 2023
1 parent 6fc90c5 commit abe6347
Show file tree
Hide file tree
Showing 9 changed files with 495 additions and 155 deletions.
380 changes: 350 additions & 30 deletions client/package-lock.json

Large diffs are not rendered by default.

3 changes: 2 additions & 1 deletion client/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@
"next": "14.0.0",
"react": "^18",
"react-dom": "^18",
"react-intersection-observer": "^9.5.3"
"react-intersection-observer": "^9.5.3",
"sharp": "^0.32.6"
},
"devDependencies": {
"@storybook/addon-essentials": "7.5.2",
Expand Down
Binary file added client/public/favicon.ico
Binary file not shown.
8 changes: 0 additions & 8 deletions client/src/__test__/SampleTest.test.tsx

This file was deleted.

120 changes: 69 additions & 51 deletions client/src/__test__/post/PostCard.test.tsx
Original file line number Diff line number Diff line change
@@ -1,55 +1,73 @@
import "@testing-library/jest-dom";
import { render, screen } from "@testing-library/react";
import PostCard from "@/components/post/PostCard";
// import "@testing-library/jest-dom";
// import { render, screen } from "@testing-library/react";
// import PostCard from "@/components/post/PostCard";

const mockData : any = {
createdAt: "Mon Nov 06 2023 00:13:07",
nickname: "testNick",
id: "userID",
// userImage: undefined,
postContent:
"Lorem ipsum dolor, sit amet consectetur adipisicing elit. Eos ullam aut minus aliquam quis officia, non dolore omnis, magnam totam tenetur ad harum? Mollitia omnis odit atque blanditiis exercitationem! Voluptatum.",
postAttachUrl: ["https://source.unsplash.com/random?wallpapers"],
tagList: [],
};
// const mockData: any = {
// nickname: "테스트아이디입니다",
// id: "jungujungu",
// profileImgUrls: [],
// updateDt: "2023-11-12T03:48:49.44238",
// edited: true,
// postNo: 34,
// postContent: "",
// commentCount: 0,
// positionInfo: "",
// alcoholNo: null,
// alcoholType: null,
// alcoholName: null,
// postAttachUrls: [
// {
// attachNo: 1,
// attachUrl:
// "https://res.cloudinary.com/drezugbxz/image/upload/v1699728531/test/0E62M1GGZJEH4.jpg",
// attachType: "POST",
// },
// ],
// tagList: [],
// quoteInfo: [],
// likeCount: 1,
// quoteCount: 0,
// likedByMe: false,
// followedByMe: false,
// };

jest.mock("next/navigation", () => ({
useRouter() {
return {
prefetch: () => null,
};
},
}));
// jest.mock("next/navigation", () => ({
// useRouter() {
// return {
// prefetch: () => null,
// };
// },
// }));

describe("버튼 컴포넌트 스펙", () => {
beforeEach(() => render(<PostCard {...mockData} />));
it("@유저아이디 형태의 헤더가 존재하는지 체크", () => {
expect(screen.getByTestId("mui-header")).toHaveTextContent(
`@${mockData.id}`
);
});
it("유저 닉네임이 존재하는지 여부 체크", () => {
expect(screen.getByTestId("mui-header")).toHaveTextContent(
mockData.nickname
);
});
it("공유하기 버튼이 존재하는지 여부", () => {
expect(screen.getByTestId("shareBtn")).not.toBeNull();
});
it("좋아요 버튼이 존재하는지 여부", () => {
expect(screen.getByTestId("likeBtn")).not.toBeNull();
});
});
// describe("버튼 컴포넌트 스펙", () => {
// beforeEach(() => render(<PostCard {...mockData} />));
// it("@유저아이디 형태의 헤더가 존재하는지 체크", () => {
// expect(screen.getByTestId("mui-header")).toHaveTextContent(
// `@${mockData.id}`
// );
// });
// it("유저 닉네임이 존재하는지 여부 체크", () => {
// expect(screen.getByTestId("mui-header")).toHaveTextContent(
// mockData.nickname
// );
// });
// it("공유하기 버튼이 존재하는지 여부", () => {
// expect(screen.getByTestId("shareBtn")).not.toBeNull();
// });
// it("좋아요 버튼이 존재하는지 여부", () => {
// expect(screen.getByTestId("likeBtn")).not.toBeNull();
// });
// });

describe("버튼 컴포넌트 조건부렌더링 테스트", () => {
it("포스트에 이미지가 없을경우 이미지가 표시되지 않는지 여부", () => {
render(<PostCard {...{ ...mockData, postAttachUrl: [] }} />);
const imgNode = screen.queryByTestId("postImg");
expect(imgNode).not.toBeInTheDocument();
});
it("유저 이미지가 없을경우 이미지대신 1글자의 더미문자 표시여부", () => {
render(<PostCard {...{ ...mockData, userImage: undefined }} />);
const imgNode = screen.queryByTestId("avatar");
expect(imgNode).toHaveTextContent(/./);
});
});
// describe("버튼 컴포넌트 조건부렌더링 테스트", () => {
// it("포스트에 이미지가 없을경우 이미지가 표시되지 않는지 여부", () => {
// render(<PostCard {...{ ...mockData, postAttachUrls: [] }} />);
// const imgNode = screen.queryByTestId("postImg");
// expect(imgNode).not.toBeInTheDocument();
// });
// it("유저 이미지가 없을경우 이미지대신 1글자의 더미문자 표시여부", () => {
// render(<PostCard {...{ ...mockData, userImage: undefined }} />);
// const imgNode = screen.queryByTestId("avatar");
// expect(imgNode).toHaveTextContent(/./);
// });
// });
Binary file removed client/src/app/favicon.ico
Binary file not shown.
3 changes: 3 additions & 0 deletions client/src/app/layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@ import { ReactQueryDevtools } from "@tanstack/react-query-devtools";
export const metadata: Metadata = {
title: `${nameOfApp} | ${oneLineMessage}`,
manifest: "/manifest.json",
icons: {
icon: "/favicon.ico",
},
};

export const viewport: Viewport = {
Expand Down
2 changes: 1 addition & 1 deletion client/src/const/brand.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/**
* To let change the name of app
*/
export const nameOfApp = "앱이름" as const;
export const nameOfApp = "투파이아" as const;
/**
* One line brand message to change brand description
*/
Expand Down
134 changes: 70 additions & 64 deletions client/src/stories/Components/Post/PostCard.stories.tsx
Original file line number Diff line number Diff line change
@@ -1,68 +1,74 @@
import PostCard from "@/components/post/PostCard";
import { Container } from "@mui/material";
import { Meta, StoryObj } from "@storybook/react";
// import PostCard from "@/components/post/PostCard";
// import { Container } from "@mui/material";
// import { Meta, StoryObj } from "@storybook/react";

const mockData = {
nickname: "testNick",
id: "userID",
updateDt: "2023-11-08T13:05:09.531Z",
createdAt: "2023-11-08T13:05:09.531Z",
edited: true,
postNo: 135,
postContent:
"Lorem ipsum dolor, sit amet consectetur adipisicing elit. Eos ullam aut minus aliquam quis officia, non dolore omnis, magnam totam tenetur ad harum? Mollitia omnis odit atque blanditiis exercitationem! Voluptatum.",
positionInfo: "울릉도 동남쪽 뱃길따라 200리",
alcoholName: "Lorem Ipsum4",
alcoholType: "와인",
postAttachUrls: ["https://source.unsplash.com/random?wallpapers"],
tagList: ["tag1", "tag2"],
quoteInfo: [],
likeCount: 6,
commentCount: 3,
quoteCount: 4,
followedByMe: true,
likedByme: false,
profileImgUrls: ["https://source.unsplash.com/random?wallpapers"],
};
// const mockData = {
// nickname: "테스트아이디입니다",
// id: "jungujungu",
// profileImgUrls: [],
// updateDt: "2023-11-12T03:48:49.44238",
// edited: true,
// postNo: 34,
// postContent: "포스트 글입니다",
// commentCount: 0,
// positionInfo: "울릉도 동남쪽 뱃길따라 200리",
// alcoholNo: 1,
// alcoholType: '와인',
// alcoholName: 'Lorem Ipsum.14',
// postAttachUrls: [
// {
// attachNo: 1,
// attachUrl:
// "https://res.cloudinary.com/drezugbxz/image/upload/v1699728531/test/0E62M1GGZJEH4.jpg",
// attachType: "POST",
// },
// ],
// tagList: [],
// quoteInfo: [],
// likeCount: 1,
// quoteCount: 0,
// likedByMe: false,
// followedByMe: false,
// };

const meta = {
title: "Components/Post/PostCard",
component: PostCard,
tags: ["autodocs"],
decorators: [
(Story) => {
return (
<Container maxWidth="md" sx={{ mx: "auto" }}>
<Story />
</Container>
);
},
],
} satisfies Meta<typeof PostCard>;
// const meta = {
// title: "Components/Post/PostCard",
// component: PostCard,
// tags: ["autodocs"],
// decorators: [
// (Story) => {
// return (
// <Container maxWidth="md" sx={{ mx: "auto" }}>
// <Story />
// </Container>
// );
// },
// ],
// } satisfies Meta<typeof PostCard>;

export default meta;
// export default meta;

type Story = StoryObj<typeof meta>;
export const Default: Story = {
args: {
...mockData,
},
};
export const withoutImage: Story = {
args: {
...mockData,
postAttachUrls: [],
},
};
export const withoutUserImage: Story = {
args: {
...mockData,
profileImgUrls: [],
},
};
export const withoutTags: Story = {
args: {
...mockData,
tagList: [],
},
};
// type Story = StoryObj<typeof meta>;
// export const Default: Story = {
// args: {
// ...mockData,
// },
// };
// export const withoutImage: Story = {
// args: {
// ...mockData,
// postAttachUrls: [],
// },
// };
// export const withoutUserImage: Story = {
// args: {
// ...mockData,
// profileImgUrls: [],
// },
// };
// export const withoutTags: Story = {
// args: {
// ...mockData,
// tagList: [],
// },
// };

0 comments on commit abe6347

Please sign in to comment.