Skip to content

Commit 3a3a430

Browse files
Merge pull request #9 from boostcampwm-2024/refactor/playwright_선택자_설정_및_시나리오_작성
Refactor/#3 playwright 선택자 설정 및 시나리오 작성
2 parents ae7c7b8 + f16add7 commit 3a3a430

File tree

24 files changed

+910
-79
lines changed

24 files changed

+910
-79
lines changed

.gitignore

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,4 +9,9 @@
99
tsconfig.tsbuildinfo
1010

1111
# Jest globalConfig file
12-
../globalConfig.json
12+
../globalConfig.json
13+
node_modules/
14+
/test-results/
15+
/playwright-report/
16+
/blob-report/
17+
/playwright/.cache/

client/src/components/bottomNavigator/BottomNavigator.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ export const BottomNavigator = ({
1717
}: BottomNavigatorProps) => {
1818
return (
1919
<div className={bottomNavigatorContainer} {...BottomNavigatorOnBoardingProps}>
20-
{pages.map((page) => (
20+
{pages.map((page, idx) => (
2121
<motion.div
2222
key={page.id}
2323
initial={animation.initial}
@@ -29,6 +29,7 @@ export const BottomNavigator = ({
2929
key={page.id}
3030
icon={page.icon}
3131
size="md"
32+
testKey={`BottomNavigator-iconButton-${idx}`}
3233
onClick={() => {
3334
handlePageSelect({
3435
pageId: page.id,

client/src/components/button/IconButton.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,16 @@ import { iconButtonContainer } from "./IconButton.style";
55
interface IconButtonProps {
66
icon: PageIconType | "plus";
77
size: "sm" | "md";
8+
testKey: string;
89
onClick?: () => void;
910
}
1011

11-
export const IconButton = ({ icon, size, onClick }: IconButtonProps) => {
12+
export const IconButton = ({ icon, size, testKey, onClick }: IconButtonProps) => {
1213
const { icon: IconComponent, color: defaultColor }: IconConfig = iconComponents[icon];
1314

1415
return (
1516
<button
17+
data-testid={testKey}
1618
className={iconButtonContainer({ size })}
1719
data-onboarding="page-add-button"
1820
onClick={onClick}

client/src/components/button/textButton.tsx

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,19 @@ import { textButtonContainer } from "./textButton.style";
33
interface TextButtonProps {
44
variant?: "primary" | "secondary";
55
children: React.ReactNode;
6+
testKey: string;
67
onClick?: () => void;
78
}
89

9-
export const TextButton = ({ variant = "primary", children, onClick }: TextButtonProps) => {
10+
export const TextButton = ({
11+
variant = "primary",
12+
children,
13+
testKey,
14+
onClick,
15+
}: TextButtonProps) => {
1016
return (
1117
<button
18+
data-testid={testKey}
1219
className={textButtonContainer({ variant })}
1320
onClick={onClick}
1421
data-onboarding="login-button"

client/src/components/modal/modal.tsx

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -79,11 +79,17 @@ export const Modal = ({
7979
<div className={modalContent}>{children}</div>
8080
<div className={buttonContainer}>
8181
{secondaryButtonLabel && (
82-
<TextButton onClick={secondaryButtonOnClick} variant="secondary">
82+
<TextButton
83+
testKey="modalSecondaryButton"
84+
onClick={secondaryButtonOnClick}
85+
variant="secondary"
86+
>
8387
{secondaryButtonLabel}
8488
</TextButton>
8589
)}
86-
<TextButton onClick={primaryButtonOnClick}>{primaryButtonLabel}</TextButton>
90+
<TextButton testKey="modalPrimaryButton" onClick={primaryButtonOnClick}>
91+
{primaryButtonLabel}
92+
</TextButton>
8793
</div>
8894
</motion.div>
8995
</div>

client/src/components/sidebar/Sidebar.tsx

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -84,13 +84,14 @@ export const Sidebar = ({
8484

8585
return (
8686
<motion.aside
87+
data-testid="sidebar"
8788
className={sidebarContainer}
8889
initial="open"
8990
animate={isSidebarOpen ? "open" : "closed"}
9091
variants={sidebarVariants}
9192
{...sidebarOnBoardingProps}
9293
>
93-
<div className={sidebarToggleButton} onClick={toggleSidebar}>
94+
<div data-testid="sidebarToggle" className={sidebarToggleButton} onClick={toggleSidebar}>
9495
{isSidebarOpen ? "«" : "»"}
9596
</div>
9697
<motion.div variants={contentVariants}>
@@ -100,7 +101,7 @@ export const Sidebar = ({
100101
{pages.length === 0 ? (
101102
<div className={placeholderMessage}>+ 버튼을 눌러 페이지를 추가하세요</div>
102103
) : (
103-
pages?.map((item) => (
104+
pages?.map((item, idx) => (
104105
<motion.div
105106
key={item.id}
106107
initial={animation.initial}
@@ -109,6 +110,7 @@ export const Sidebar = ({
109110
>
110111
<PageItem
111112
{...item}
113+
testKey={`pageItem-${idx}`}
112114
onClick={() => handlePageItemClick(item.id)}
113115
onDelete={() => confirmPageDelete(item)}
114116
handleIconUpdate={handlePageUpdate}
@@ -118,7 +120,12 @@ export const Sidebar = ({
118120
)}
119121
</motion.nav>
120122
<motion.div className={plusIconBox} variants={contentVariants}>
121-
<IconButton icon="plus" onClick={handleAddPageButtonClick} size="sm" />
123+
<IconButton
124+
testKey="addPageButton"
125+
icon="plus"
126+
onClick={handleAddPageButtonClick}
127+
size="sm"
128+
/>
122129
<AuthButton />
123130
</motion.div>
124131

client/src/components/sidebar/components/pageIconButton/PageIconButton.tsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,15 @@ import { IconBox } from "./PageIconButton.style";
44

55
interface PageIconButtonProps {
66
type: PageIconType;
7+
testKey: string;
78
onClick: (e: React.MouseEvent) => void;
89
}
910

10-
export const PageIconButton = ({ type, onClick }: PageIconButtonProps) => {
11+
export const PageIconButton = ({ type, testKey, onClick }: PageIconButtonProps) => {
1112
const { icon: IconComponent, color: defaultColor }: IconConfig = iconComponents[type];
1213

1314
return (
14-
<div style={{ position: "relative" }}>
15+
<div data-testid={testKey} style={{ position: "relative" }}>
1516
<div className={IconBox} onClick={(e) => onClick(e)}>
1617
<IconComponent color={defaultColor} size="24px" />
1718
</div>

client/src/components/sidebar/components/pageIconButton/PageIconModal.tsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,9 @@ export interface PageIconModalProps {
1313

1414
export const PageIconModal = ({ onClose, onSelect, currentType }: PageIconModalProps) => {
1515
return (
16-
<div className={IconModal} onClick={onClose}>
16+
<div data-testid="iconModal" className={IconModal} onClick={onClose}>
1717
<div className={IconModalContainer} onClick={onClose}>
18-
<button onClick={onClose} className={IconModalClose}>
18+
<button data-testid="iconModalCloseButton" onClick={onClose} className={IconModalClose}>
1919
<RiCloseLine width={16} height={16} />
2020
</button>
2121
<div>
@@ -39,6 +39,7 @@ export const PageIconModal = ({ onClose, onSelect, currentType }: PageIconModalP
3939

4040
return (
4141
<button
42+
data-testid={`iconModalButton-${iconType}`}
4243
key={iconType}
4344
onClick={(e) => onSelect(e, iconType)}
4445
className={IconButton(isSelected)}

client/src/components/sidebar/components/pageItem/PageItem.tsx

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ interface PageItemProps {
1010
id: string;
1111
title: string;
1212
icon: PageIconType;
13+
testKey: string;
1314
onClick: () => void;
1415
onDelete?: (id: string) => void; // 추가: 삭제 핸들러
1516
handleIconUpdate: (
@@ -23,6 +24,7 @@ export const PageItem = ({
2324
id,
2425
icon,
2526
title,
27+
testKey,
2628
onClick,
2729
onDelete,
2830
handleIconUpdate,
@@ -61,10 +63,20 @@ export const PageItem = ({
6163
};
6264

6365
return (
64-
<div className={pageItemContainer} onClick={onClick}>
65-
<PageIconButton type={pageIcon ?? "Docs"} onClick={handleToggleModal} />
66-
<span className={textBox}>{title || "새로운 페이지"}</span>
67-
<span className={`delete_box ${deleteBox}`} onClick={handleDelete}>
66+
<div data-testid={testKey} className={pageItemContainer} onClick={onClick}>
67+
<PageIconButton
68+
testKey={`pageIconButton-${testKey.split("-")[1]}-${pageIcon}`}
69+
type={pageIcon ?? "Docs"}
70+
onClick={handleToggleModal}
71+
/>
72+
<span data-testid={`sidebarTitle-${testKey.split("-")[1]}`} className={textBox}>
73+
{title || "새로운 페이지"}
74+
</span>
75+
<span
76+
data-testid={`pageDeleteButton-${testKey.split("-")[1]}`}
77+
className={`delete_box ${deleteBox}`}
78+
onClick={handleDelete}
79+
>
6880
<CloseIcon width={16} height={16} />
6981
</span>
7082
{isOpen && (

client/src/features/auth/AuthButton.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,11 +26,11 @@ export const AuthButton = () => {
2626
return (
2727
<div className={container}>
2828
{isLogin ? (
29-
<TextButton onClick={openLogoutModal} variant="secondary">
29+
<TextButton testKey="sidebarLogoutButton" onClick={openLogoutModal} variant="secondary">
3030
로그아웃
3131
</TextButton>
3232
) : (
33-
<TextButton onClick={openAuthModal} variant="secondary">
33+
<TextButton testKey="sidebarLoginButton" onClick={openAuthModal} variant="secondary">
3434
로그인
3535
</TextButton>
3636
)}

0 commit comments

Comments
 (0)