@@ -124,11 +124,12 @@ describe.sequential("2. 장바구니 수량 조절", () => {
124124
125125 // 상품을 장바구니에 추가하고 수량을 2개로 증가
126126 await addProductToCart ( "pvc 투명 젤리 쇼핑백" ) ;
127- expect ( document . querySelector ( ".quantity-input" ) . value ) . toBe ( "1" ) ;
128127
129128 const cartIcon = document . querySelector ( "#cart-icon-btn" ) ;
130129 await userEvent . click ( cartIcon ) ;
131130
131+ expect ( document . querySelector ( ".quantity-input" ) . value ) . toBe ( "1" ) ;
132+
132133 // 수량을 먼저 2개로 증가
133134 const increaseButton = document . querySelector ( ".quantity-increase-btn" ) ;
134135 await userEvent . click ( increaseButton ) ;
@@ -138,7 +139,7 @@ describe.sequential("2. 장바구니 수량 조절", () => {
138139 expect ( decreaseButton ) . toBeInTheDocument ( ) ;
139140
140141 const quantityInput = document . querySelector ( ".quantity-input" ) ;
141- expect ( quantityInput . value ) . toBe ( "3 " ) ;
142+ expect ( quantityInput . value ) . toBe ( "2 " ) ;
142143
143144 await userEvent . click ( decreaseButton ) ;
144145
@@ -158,15 +159,15 @@ describe.sequential("2. 장바구니 수량 조절", () => {
158159 // 초기 총 금액 확인
159160 const getTotalAmountElement = ( ) => screen . getByText ( "총 금액" ) . parentNode . querySelector ( "span:last-child" ) ;
160161 const initialAmount = getTotalAmountElement ( ) . textContent ;
161- expect ( initialAmount ) . toBe ( "880원 " ) ;
162+ expect ( initialAmount ) . toBe ( "220원 " ) ;
162163
163164 // 수량 증가
164165 const increaseButton = document . querySelector ( ".quantity-increase-btn" ) ;
165166 await userEvent . click ( increaseButton ) ;
166167
167168 // 총 금액이 업데이트되었는지 확인
168169 const updatedAmount = getTotalAmountElement ( ) . textContent ;
169- expect ( updatedAmount ) . toBe ( "1,100원 " ) ;
170+ expect ( updatedAmount ) . toBe ( "440원 " ) ;
170171 } ) ;
171172} ) ;
172173
@@ -286,17 +287,12 @@ describe.sequential("5. 장바구니 전체 선택", () => {
286287 const cartIcon = document . querySelector ( "#cart-icon-btn" ) ;
287288 await userEvent . click ( cartIcon ) ;
288289
289- const selectAllCheckbox = document . querySelector ( "#cart-modal-select-all-checkbox" ) ;
290-
291290 // 전체 선택 후 전체 해제
292- await userEvent . click ( selectAllCheckbox ) ;
293- await userEvent . click ( selectAllCheckbox ) ;
291+ await userEvent . click ( document . querySelector ( "#cart-modal-select-all-checkbox" ) ) ;
292+ expect ( [ ... document . querySelectorAll ( ".cart-item-checkbox" ) ] . map ( ( v ) => v . checked ) ) . toEqual ( [ true , true ] ) ;
294293
295- // 모든 상품의 체크박스가 해제되었는지 확인
296- const itemCheckboxes = document . querySelectorAll ( ".cart-item-checkbox" ) ;
297- itemCheckboxes . forEach ( ( checkbox ) => {
298- expect ( checkbox . checked ) . toBe ( false ) ;
299- } ) ;
294+ await userEvent . click ( document . querySelector ( "#cart-modal-select-all-checkbox" ) ) ;
295+ expect ( [ ...document . querySelectorAll ( ".cart-item-checkbox" ) ] . map ( ( v ) => v . checked ) ) . toEqual ( [ false , false ] ) ;
300296 } ) ;
301297} ) ;
302298
0 commit comments