Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix: 전체 기능 테스트 보완 #143

Merged
merged 34 commits into from
Oct 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
dc12dec
feat: 상세정보조회 이미지만 loop 가능
CLOUDoort Oct 16, 2024
3789a6e
style: 기타 코드 수정
CLOUDoort Oct 16, 2024
0f8af9e
fix: 기타 수정
CLOUDoort Oct 16, 2024
f631d07
fix: 사전 경매 좋아요 문구 변경 및 스타일 변경
CLOUDoort Oct 16, 2024
28713de
fix: mutation error message 변경
CLOUDoort Oct 16, 2024
b1b4287
fix: 실시간 알림 읽음 처리 하지 않음
CLOUDoort Oct 16, 2024
089257b
fix: 입찰할 때는 입찰 취소 못하게 하기
CLOUDoort Oct 17, 2024
eb0fdc9
refactor: 필요없는 부분 수정 및 스타일 수정
CLOUDoort Oct 17, 2024
9fbbe4d
fix: 경매 전환과 입찰 취소에 toast 알림 및 Pending 추가
CLOUDoort Oct 17, 2024
11444c4
fix: 좋아요 취소 시 사전경매 상세정보 데이터 무효화
CLOUDoort Oct 17, 2024
d9a10e5
fix: 경매 등록 이미지 간격 수정
CLOUDoort Oct 17, 2024
a33182a
style: 기존 하트 아이콘으로 변경
CLOUDoort Oct 17, 2024
86e4b6b
fix: 사전 경매 삭제
CLOUDoort Oct 17, 2024
2bda021
fix: 모든 알림 클릭시 알림 읽기 가능하게 하기.
CLOUDoort Oct 17, 2024
1e619c3
fix: 입찰 페이지 사진에 맞춰서 컴포넌트 크기 조정하기.
CLOUDoort Oct 17, 2024
ce092bf
style: 알림 cursor pointer 수정
CLOUDoort Oct 17, 2024
6c9eacf
fix: 입찰 내역 조회에서 확인 완료 버튼 클릭하면 이전 페이지로 이동
CLOUDoort Oct 18, 2024
831a6b3
style: 하트 아이콘 수정
CLOUDoort Oct 18, 2024
f167d4a
style: 상세조회 이미지 수정
CLOUDoort Oct 18, 2024
e26cb60
feat: 카테고리 및 프로필 이미지 추가
CLOUDoort Oct 18, 2024
c3b749c
style: 기타 스타일 수정
CLOUDoort Oct 18, 2024
5163112
style: 참여금액 아이콘 추가
CLOUDoort Oct 18, 2024
134a86f
style: modal 아이콘 추가
CLOUDoort Oct 18, 2024
b2825d7
fix: 기타 수정
CLOUDoort Oct 18, 2024
5b92d39
feat: 이미지 업로드 시 확장자 및 용량 체크 확인
CLOUDoort Oct 18, 2024
acc0444
feat: 경매 종료 시 상세정보 refetch
CLOUDoort Oct 18, 2024
2882c04
feat: 경매 timelabel을 1시간 미만이면 ~분 남음으로 수정하고 초단위는 1분 미만으로 수정.
CLOUDoort Oct 18, 2024
ef7611e
fix: 경매 등록과 사전 등록의 주의사항 체크 여부가 중복되는 버그 수정.
CLOUDoort Oct 18, 2024
8c80d32
fix: 회원가입, 로그인, 로그아웃 시 toast 알림 겹치는 버그 수정.
CLOUDoort Oct 18, 2024
e06bdb9
fix: 회원가입, 로그인, 로그아웃 시 toast 알림 겹치는 버그 수정.
CLOUDoort Oct 18, 2024
17cfc57
feat: 정식 경매 상세조회 이미지 변수명 변경 및 참여 취소 명시.
CLOUDoort Oct 18, 2024
84a1b16
feat: 정식 경매 및 사전 경매 상세조회 리팩토링, 입찰 취소 시 확인 modal 설정
CLOUDoort Oct 19, 2024
e6ce744
style; modal 스타일 설정
CLOUDoort Oct 19, 2024
5e5b5b1
Merge branch 'dev' into fix/functional-test
CLOUDoort Oct 19, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 6 additions & 5 deletions src/@types/AuctionDetails.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,11 @@ declare module 'AuctionDetails' {
minPrice: number;
isSeller: boolean;
category: string;
sellerProfileImageUrl: string;
images: {
imageId: number;
imageUrl: string;
}[];
}

export interface IAuctionDetails extends IAuctionDetailsBase {
Expand All @@ -17,16 +22,12 @@ declare module 'AuctionDetails' {
bidId: number | null;
bidAmount: number;
remainingBidCount: number;
imageUrls: string[];
isCancelled: boolean;
}

export interface IPreAuctionDetails extends IAuctionDetailsBase {
updatedAt: string;
likeCount: number;
isLiked: boolean;
images: {
imageId: number;
imageUrl: string;
}[];
}
}
5 changes: 5 additions & 0 deletions src/assets/icons/in_box_edit_time.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions src/assets/icons/in_box_like.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
5 changes: 5 additions & 0 deletions src/assets/icons/like_heart.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
7 changes: 7 additions & 0 deletions src/assets/icons/modal_cancel.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions src/assets/icons/modal_edit.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
5 changes: 5 additions & 0 deletions src/assets/icons/modal_share.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 4 additions & 0 deletions src/assets/icons/my_participation_amount.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
23 changes: 20 additions & 3 deletions src/components/bid/Bid.test.tsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import { RouterProvider, createMemoryRouter } from 'react-router-dom';
import { act, render, screen, waitFor } from '@testing-library/react';
import { RouterProvider, createMemoryRouter } from 'react-router-dom';
import { describe, expect, test, vi } from 'vitest';

import Bid from '@/pages/Bid';
import { mockedUseNavigate } from '@/setupTests';
import { useGetAuctionDetails } from '../details/queries';
import userEvent from '@testing-library/user-event';
import { useGetAuctionDetails } from '../details/queries';

vi.mock('@/components/details/queries');
vi.mocked(useGetAuctionDetails).mockReturnValue({
Expand All @@ -14,7 +14,8 @@ vi.mocked(useGetAuctionDetails).mockReturnValue({
bidId: null,
description:
"서로 다른 출신과 개성을 가진 이들이 모여 밴드 결성까지의 과정을 보여준 ‘Harmony from Discord’부터 멤버들 간의 만남을 동경과 벅차오르는 감성으로 담아낸 ‘MANITO’까지. 성장 서사를 써내려가는 밴드 QWER이 두 번째 EP인 ‘Algorithm’s Blossom’을 선보인다. 이번 앨범에서는 QWER이라는 하나의 팀으로서 새롭게 운명을 개척해나가는 이야기를 ‘알고리즘이 피워낸 꽃’이라는 키워드를 통해 풀어내고자 한다.\n\n\"사랑과 상처, 그 모든 것을 끌어안고 피어나”\n\n무수히 파편적이고 혼란하지만 보여지는 것은 단편적인 곳, 다양한 혼잡함이 가지런히 질서를 이루는 곳. 그런 '알고리즘' 속에서 우리의 이야기를 피워낸다. ‘Algorithm’s Blossom'에서 QWER은 보편적이지 않은 공간에 심겨진 씨앗으로, 동시에 사랑과 상처를 양분삼아 돋아난 싹으로, 세상에 보인 적 없던 새로운 꽃의 모습으로 자신들의 성장과 여정을 그린다.",
imageUrls: ['/jgbI75.jpg'],
images: [{ imageId: 1, imageUrl: '/jgbI75.jpg' }],
isCancelled: false,
isParticipated: false,
isSeller: false,
minPrice: 23000,
Expand All @@ -26,7 +27,23 @@ vi.mocked(useGetAuctionDetails).mockReturnValue({
status: 'PROCEEDING',
timeRemaining: 25816,
category: 'ELECTRONICS',
sellerProfileImageUrl: ''
},
refetch: vi.fn().mockResolvedValue({ // refetch 추가
data: {
bidAmount: 1000,
bidId: null,
description: 'Test auction',
imageUrls: ['test-image.jpg'],
isParticipated: false,
isSeller: false,
minPrice: 500,
productName: 'Test product',
participantCount: 5,
sellerProfileImageUrl: 'seller-image.jpg',
},
error: null,
}),
});

/**
Expand Down
48 changes: 14 additions & 34 deletions src/components/bid/BidFooter.tsx
Original file line number Diff line number Diff line change
@@ -1,46 +1,26 @@
import Button from '../common/Button';
import { MAX_BID_COUNT } from '@/constants/bid';
import Button from '../common/Button';

interface BidFooterProps {
remain: number;
check: boolean;
isSubmitting: boolean;
handlePost: (e?: React.BaseSyntheticEvent<object, any, any> | undefined) => Promise<void>;
handlePatch: () => void;
handlePost: (e: React.BaseSyntheticEvent<object, any, any> | undefined) => Promise<void>;
}

const BidFooter = ({ remain, check, isSubmitting, handlePost, handlePatch }: BidFooterProps) => {
if (remain === MAX_BID_COUNT) {
return (
<Button
type='button'
color='cheeseYellow'
className='w-full h-full transition-colors rounded text-button active:bg-black'
aria-label='제안하기 버튼'
onClick={handlePost}
disabled={!check || isSubmitting}
>
제안하기
</Button>
);
}

const BidFooter = ({ remain, check, isSubmitting, handlePost }: BidFooterProps) => {
const flag = remain === MAX_BID_COUNT
return (
<>
<Button type='button' color='white' className='flex-1 h-full transition-colors rounded text-button active:bg-black' onClick={handlePatch}>
참여 취소
</Button>
<Button
type='button'
color='cheeseYellow'
className='flex-[2] h-full rounded text-button active:bg-black transition-colors'
disabled={!check || isSubmitting || remain === 0}
onClick={handlePost}
>
금액 수정
{remain !== 0 ? `(${remain}회 가능)` : '(소진)'}
</Button>
</>
<Button
type='button'
color='cheeseYellow'
className='w-full h-full transition-colors rounded text-button active:bg-black'
aria-label={flag ? '제안하기' : '수정하기'}
onClick={handlePost}
disabled={flag ? (!check || isSubmitting) : remain === 0}
>
{flag ? '제안하기' : `금액 수정 ${remain !== 0 ? `(${remain}회 가능)` : '(소진)'}`}
</Button>
);
};

Expand Down
13 changes: 4 additions & 9 deletions src/components/bid/BidMain.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,16 +13,15 @@ import Layout from "../layout/Layout";
import { Input } from "../ui/input";
import BidCaution from "./BidCaution";
import BidFooter from "./BidFooter";
import { usePatchBid, usePostBid } from "./queries";
import { usePostBid } from "./queries";

const BidMain = ({ auctionId }: { auctionId: number }) => {
const { auctionDetails } = useGetAuctionDetails(auctionId);
const { mutate: postBid } = usePostBid(auctionId);
const { mutate: patchBid } = usePatchBid(auctionId);
const [check, setCheck] = useState<boolean>(false);
const toggleCheckBox = () => setCheck((state) => !state);

const { imageUrls, productName, minPrice, participantCount, remainingBidCount, bidAmount, timeRemaining, isParticipated, bidId } = auctionDetails;
const { images, productName, minPrice, participantCount, remainingBidCount, bidAmount, timeRemaining, isParticipated } = auctionDetails;
const BidSchema = getBidSchema(minPrice);
type FormFields = z.infer<typeof BidSchema>;

Expand Down Expand Up @@ -51,16 +50,12 @@ const BidMain = ({ auctionId }: { auctionId: number }) => {

postBid(bidData);
};
const onPatchSubmit = () => {
if (bidId) patchBid(bidId);
};

return (
<>
<Layout.Main>
<div className='flex flex-col gap-8'>
<AuctionItem axis='row' label='입찰 상품'>
<AuctionItem.Image src={imageUrls[0]} time={timeRemaining} />
<AuctionItem.Image src={images[0].imageUrl} time={timeRemaining} />
<AuctionItem.Main kind='register' name={productName} count={participantCount} price={minPrice} />
</AuctionItem>
{isParticipated && (
Expand Down Expand Up @@ -92,7 +87,7 @@ const BidMain = ({ auctionId }: { auctionId: number }) => {
</div>
</Layout.Main>
<Layout.Footer type={isParticipated ? 'double' : 'single'}>
<BidFooter remain={remainingBidCount} check={check} isSubmitting={isSubmitting} handlePatch={onPatchSubmit} handlePost={handleSubmit(onPostSubmit)} />
<BidFooter remain={remainingBidCount} check={check} isSubmitting={isSubmitting} handlePost={handleSubmit(onPostSubmit)} />
</Layout.Footer>
</>
);
Expand Down
23 changes: 20 additions & 3 deletions src/components/bid/EditBid.test.tsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import { RouterProvider, createMemoryRouter } from 'react-router-dom';
import { act, render, screen, waitFor } from '@testing-library/react';
import { RouterProvider, createMemoryRouter } from 'react-router-dom';
import { describe, expect, test, vi } from 'vitest';

import Bid from '@/pages/Bid';
import { mockedUseNavigate } from '@/setupTests';
import { useGetAuctionDetails } from '../details/queries';
import userEvent from '@testing-library/user-event';
import { useGetAuctionDetails } from '../details/queries';

vi.mock('@/components/details/queries');
vi.mocked(useGetAuctionDetails).mockReturnValue({
Expand All @@ -14,7 +14,8 @@ vi.mocked(useGetAuctionDetails).mockReturnValue({
bidId: null,
description:
"서로 다른 출신과 개성을 가진 이들이 모여 밴드 결성까지의 과정을 보여준 ‘Harmony from Discord’부터 멤버들 간의 만남을 동경과 벅차오르는 감성으로 담아낸 ‘MANITO’까지. 성장 서사를 써내려가는 밴드 QWER이 두 번째 EP인 ‘Algorithm’s Blossom’을 선보인다. 이번 앨범에서는 QWER이라는 하나의 팀으로서 새롭게 운명을 개척해나가는 이야기를 ‘알고리즘이 피워낸 꽃’이라는 키워드를 통해 풀어내고자 한다.\n\n\"사랑과 상처, 그 모든 것을 끌어안고 피어나”\n\n무수히 파편적이고 혼란하지만 보여지는 것은 단편적인 곳, 다양한 혼잡함이 가지런히 질서를 이루는 곳. 그런 '알고리즘' 속에서 우리의 이야기를 피워낸다. ‘Algorithm’s Blossom'에서 QWER은 보편적이지 않은 공간에 심겨진 씨앗으로, 동시에 사랑과 상처를 양분삼아 돋아난 싹으로, 세상에 보인 적 없던 새로운 꽃의 모습으로 자신들의 성장과 여정을 그린다.",
imageUrls: ['/jgbI75.jpg'],
images: [{ imageId: 1, imageUrl: '/jgbI75.jpg' }],
isCancelled: false,
isParticipated: false,
isSeller: false,
minPrice: 23000,
Expand All @@ -26,7 +27,23 @@ vi.mocked(useGetAuctionDetails).mockReturnValue({
status: 'PROCEEDING',
timeRemaining: 25816,
category: 'ELECTRONICS',
sellerProfileImageUrl: ''
},
refetch: vi.fn().mockResolvedValue({ // refetch 추가
data: {
bidAmount: 1000,
bidId: null,
description: 'Test auction',
imageUrls: ['test-image.jpg'],
isParticipated: false,
isSeller: false,
minPrice: 500,
productName: 'Test product',
participantCount: 5,
sellerProfileImageUrl: 'seller-image.jpg',
},
error: null,
}),
});
const router = createMemoryRouter(
[
Expand Down
27 changes: 3 additions & 24 deletions src/components/bid/queries.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { UseMutateFunction, useMutation } from '@tanstack/react-query';

import { API_END_POINT } from '@/constants/api';
import { httpClient } from '@/api/axios';
import { toast } from 'sonner';
import { useNavigate } from 'react-router-dom';
import { API_END_POINT } from '@/constants/api';
import { IBidPostData } from 'Bid';
import { useNavigate } from 'react-router-dom';
import { toast } from 'sonner';

export const usePostBid = (
auctionId: number
Expand All @@ -26,24 +26,3 @@ export const usePostBid = (

return { mutate };
};

export const usePatchBid = (
auctionId: number
): {
mutate: UseMutateFunction<void, Error, number, unknown>;
} => {
const patchBid = async (bidId: number) => {
await httpClient.patch(`${API_END_POINT.BID}/${bidId}/cancel`);
};

const navigate = useNavigate();
const { mutate } = useMutation({
mutationFn: patchBid,
onSuccess: () => {
toast.success('입찰 수정!');
navigate(`/auctions/auction/${auctionId}`);
},
});

return { mutate };
};
Loading