@@ -4,21 +4,26 @@ describe("Books Flow", () => {
4
4
cy . resetTestData ( ) ;
5
5
} ) ;
6
6
7
+ function fillInBookForm ( { title, publisher, author, isbn} ) {
8
+ cy . get ( 'input[placeholder="Enter book title"]' ) . type ( title ) ;
9
+ cy . get ( 'input[placeholder="Enter book publisher"]' ) . type ( publisher ) ;
10
+ cy . get ( 'input[placeholder="Enter book author"]' ) . type ( author ) ;
11
+ cy . get ( 'input[placeholder="Enter book ISBN"]' ) . type ( isbn ) ;
12
+ }
13
+
7
14
it ( "allows proposing and approving books" , ( ) => {
8
15
// Visit React1 app (root path)
9
16
cy . visit ( "/" ) ;
10
17
cy . contains ( "Book List" ) ;
11
18
12
19
// Propose a new book
13
20
cy . contains ( "button" , "Propose New Book" ) . click ( ) ;
14
- cy . get ( 'input[placeholder="Enter book title"]' ) . type ( "Test Book Title" ) ;
15
- cy . get ( 'input[placeholder="Enter book publisher"]' ) . type (
16
- "Test Author Name"
17
- ) ;
18
- cy . get ( 'input[placeholder="Enter book author"]' ) . type (
19
- "Test Publisher Name"
20
- ) ;
21
- cy . get ( 'input[placeholder="Enter book ISBN"]' ) . type ( "1234567890" ) ;
21
+ fillInBookForm ( {
22
+ title : "Test Book Title" ,
23
+ publisher : "Test Author Name" ,
24
+ author : "Test Publisher Name" ,
25
+ isbn : "1234567890" ,
26
+ } ) ;
22
27
cy . contains ( "button" , "Submit" ) . click ( ) ;
23
28
24
29
// Visit React2 app (/backend path)
@@ -45,21 +50,20 @@ describe("Books Flow", () => {
45
50
46
51
it ( "allows denying provisional books" , ( ) => {
47
52
// Visit React1 app
48
- cy . visit ( "/backend" ) ;
49
-
53
+ cy . visit ( "/" ) ;
50
54
// Propose a new book
51
55
cy . contains ( "button" , "Propose New Book" ) . click ( ) ;
52
- cy . get ( 'input[placeholder="Enter book title"]' ) . type ( "Book To Deny" ) ;
53
- cy . get ( 'input[placeholder="Enter book publisher"]' ) . type (
54
- "Test Author Name"
55
- ) ;
56
- cy . get ( 'input[placeholder="Enter book author"]' ) . type (
57
- "Test Publisher Name"
58
- ) ;
56
+ fillInBookForm ( {
57
+ title : "Book To Deny" ,
58
+ publisher : "Test Author Name" ,
59
+ author : "Test Publisher Name" ,
60
+ isbn : "1234567890" ,
61
+ } ) ;
59
62
cy . contains ( "button" , "Submit" ) . click ( ) ;
60
63
61
64
// Visit React2 app and deny the book
62
65
cy . visit ( "/backend/" ) ;
66
+ cy . contains ( "Provisional Books" ) ;
63
67
cy . contains ( ".book-item" , "Book To Deny" )
64
68
. contains ( "button" , "Deny" )
65
69
. click ( ) ;
0 commit comments