1+ //Visit store
2+
3+ describe ( "visit store" , ( ) => {
4+ it ( "visit store" , function ( ) {
5+ cy . visit ( "http://localhost:3000" ) ;
6+ } ) ;
7+ } ) ;
8+
9+ //check out one pruduct
10+ describe ( "add ,remove ,increase ,decrease, product" , ( ) => {
11+ //we have 20 product
12+ it ( "get all products" , function ( ) {
13+ cy . get ( ".product_product__8NFYa" ) . should ( "have.length" , 20 ) ;
14+ } ) ;
15+
16+
17+ //increase 4 product
18+ it ( "increase 4 product" , function ( ) {
19+ for ( var i = 0 ; i < 4 ; i ++ ) {
20+ cy . get ( `[data-testid=product-button-${ product_count } ]` ) . click ( ) ;
21+ cy . wait ( 1000 ) ;
22+ }
23+
24+ } ) ;
25+
26+ //remove product
27+ it ( "remove product" , function ( ) {
28+ for ( var i = 0 ; i < 4 ; i ++ ) {
29+ cy . get ( `[data-testid=product-button-decrease-${ product_count } ]` ) . click ( ) ;
30+ cy . wait ( 1000 ) ;
31+ }
32+ cy . wait ( 3000 ) ;
33+ } ) ;
34+
35+ // add to card multi products
36+ it ( "add to card multi products" , function ( ) {
37+ let product_count = random_number ( 10 ) ;
38+ for ( var i = 0 ; i < product_count ; i ++ ) {
39+ cy . get ( `[data-testid=product-button-${ random_number ( 20 ) } ]` ) . click ( ) ;
40+ cy . wait ( 1000 ) ;
41+ }
42+ } ) ;
43+
44+
45+ } ) ;
46+
47+ describe ( "checkout" , ( ) => {
48+
49+ it ( "go to shop card" , function ( ) {
50+ cy . get ( ".navbar_container__kRWCp div a" ) . click ( ) ;
51+ cy . wait ( 1000 ) ;
52+ } ) ;
53+
54+ it ( "click checkout" , function ( ) {
55+ cy . get ( ".shopCard_check_out__XWR45" ) . click ( ) ;
56+ cy . wait ( 2000 ) ;
57+ } ) ;
58+
59+ //buy more
60+ it ( "buy more" , function ( ) {
61+ cy . get ( ".shopCard_clear_checkout_div__lKoz0 a" ) . click ( ) ;
62+
63+ } ) ;
64+
65+ } ) ;
66+
67+ //this function can create random number between 1 to max_random
68+ function random_number ( max_random ) {
69+ let rand = 0 ;
70+ rand = Math . floor ( Math . random ( ) * max_random ) + 1 ;
71+ return rand ;
72+ }
73+
74+ let product_count = random_number ( 20 ) ;
0 commit comments