Skip to content

Commit 951f5b2

Browse files
committed
fixing test configuration
1 parent 70bd74a commit 951f5b2

File tree

2 files changed

+22
-18
lines changed

2 files changed

+22
-18
lines changed

test/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ npm install
2424

2525
```bash
2626
# Open Cypress GUI for development
27-
npm run test:local
27+
npm run test:gui
2828

2929
# Run tests headlessly
3030
npm test

test/cypress/e2e/books_flow.cy.js

Lines changed: 21 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -4,21 +4,26 @@ describe("Books Flow", () => {
44
cy.resetTestData();
55
});
66

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+
714
it("allows proposing and approving books", () => {
815
// Visit React1 app (root path)
916
cy.visit("/");
1017
cy.contains("Book List");
1118

1219
// Propose a new book
1320
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+
});
2227
cy.contains("button", "Submit").click();
2328

2429
// Visit React2 app (/backend path)
@@ -45,21 +50,20 @@ describe("Books Flow", () => {
4550

4651
it("allows denying provisional books", () => {
4752
// Visit React1 app
48-
cy.visit("/backend");
49-
53+
cy.visit("/");
5054
// Propose a new book
5155
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+
});
5962
cy.contains("button", "Submit").click();
6063

6164
// Visit React2 app and deny the book
6265
cy.visit("/backend/");
66+
cy.contains("Provisional Books");
6367
cy.contains(".book-item", "Book To Deny")
6468
.contains("button", "Deny")
6569
.click();

0 commit comments

Comments
 (0)