File tree Expand file tree Collapse file tree 1 file changed +25
-0
lines changed
packages/template-retail-react-app/app/components/product-view Expand file tree Collapse file tree 1 file changed +25
-0
lines changed Original file line number Diff line number Diff line change @@ -128,6 +128,31 @@ test('Product View can update quantity', async () => {
128128 } )
129129} )
130130
131+ test ( 'Product View handles invalid quantity inputs' , async ( ) => {
132+ const user = userEvent . setup ( )
133+
134+ // Any invalid input should be reset to minOrderQuantity
135+ await renderWithProviders ( < MockComponent product = { mockProductDetail } /> )
136+
137+ const quantityInput = screen . getByRole ( 'spinbutton' , { name : / q u a n t i t y / i} )
138+ const minQuantity = mockProductDetail . minOrderQuantity . toString ( )
139+
140+ // Quantity is empty
141+ await user . clear ( quantityInput )
142+ await user . tab ( )
143+ await waitFor ( ( ) => {
144+ expect ( quantityInput ) . toHaveValue ( minQuantity )
145+ } )
146+
147+ // Quantity is zero
148+ await user . clear ( quantityInput )
149+ await user . type ( quantityInput , '0' )
150+ await user . tab ( )
151+ await waitFor ( ( ) => {
152+ expect ( quantityInput ) . toHaveValue ( minQuantity )
153+ } )
154+ } )
155+
131156describe ( 'ProductView Component' , ( ) => {
132157 test ( 'increases quantity when increment button is clicked' , async ( ) => {
133158 const user = userEvent . setup ( )
You can’t perform that action at this time.
0 commit comments