Skip to content

Commit 6d9137d

Browse files
committed
Starting point
1 parent 32580ba commit 6d9137d

File tree

6 files changed

+85
-225
lines changed

6 files changed

+85
-225
lines changed

run-tests.sh

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
#!/bin/bash
2+
3+
# Build Docker images
4+
docker-compose build
5+
6+
# Start services and stop all when tests are complete
7+
docker-compose up --abort-on-container-exit
8+
9+
# Capture the exit code of the tests service
10+
EXIT_CODE=$(docker-compose ps -q tests | xargs docker inspect -f '{{ .State.ExitCode }}')
11+
12+
# Shutdown services
13+
docker-compose down
14+
15+
# Exit with the tests service's exit code
16+
exit $EXIT_CODE

todomvc-acceptance-tests/src/main/java/com/serenitydojo/playwright/todomvc/pageobjects/TodoMvcAppPage.java

Lines changed: 1 addition & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -9,74 +9,16 @@
99
public class TodoMvcAppPage {
1010

1111
private final Page page;
12-
13-
private final Locator todoItems;
14-
private final Locator todoField;
15-
1612
private final String baseUrl;
1713

1814
public TodoMvcAppPage(Page page) {
1915
this.page = page;
2016
baseUrl = (StringUtils.isEmpty(System.getenv("APP_HOST_URL"))) ? "http://localhost:7002" : System.getenv("APP_HOST_URL");
21-
this.todoItems = page.getByTestId("todo-item");
22-
this.todoField = page.getByTestId("text-input");
2317
}
2418

2519
public void open() {
2620
page.navigate(baseUrl);
2721
}
2822

29-
public List<String> todoItemsDisplayed() {
30-
return todoItems.allTextContents();
31-
}
32-
33-
public Locator todoField() {
34-
return todoField;
35-
}
36-
37-
public void addTodoItem(String todoItem) {
38-
todoField.fill(todoItem);
39-
todoField.press("Enter");
40-
}
41-
42-
public void addTodoItems(String... items) {
43-
for (String item : items) {
44-
addTodoItem(item);
45-
}
46-
}
47-
48-
public void deleteItem(String itemName) {
49-
Locator itemRow = itemRow(itemName);
50-
Locator deleteButton = itemRow.getByTestId("todo-item-button");
51-
52-
itemRow.hover();
53-
deleteButton.click();
54-
}
55-
56-
public Locator itemRow(String itemName) {
57-
return page.getByTestId("todo-item").filter(new Locator.FilterOptions().setHasText(itemName));
58-
}
59-
60-
public void completeItem(String itemName) {
61-
Locator itemRow = itemRow(itemName);
62-
Locator completeButton = itemRow.getByTestId("todo-item-toggle");
63-
completeButton.click();
64-
65-
}
66-
67-
public String todoCount() {
68-
return page.locator(".todo-count").textContent();
69-
}
70-
71-
public String activeFilter() {
72-
return page.locator(".filters .selected").textContent();
73-
}
74-
75-
public void filterItemsBy(String filter) {
76-
page.locator(".filters").getByText(filter).click();
77-
}
78-
79-
public void clearCompleted() {
80-
page.getByTestId("footer").getByText("Clear completed").click();
81-
}
23+
// TODO: Add page object methods here
8224
}

todomvc-acceptance-tests/src/test/java/com/serenitydojo/playwright/todomvc/AddingAndDeletingTodoItemsTest.java

Lines changed: 36 additions & 67 deletions
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,10 @@
66
import com.serenitydojo.playwright.todomvc.pageobjects.TodoMvcAppPage;
77
import io.qameta.allure.Feature;
88
import io.qameta.allure.Story;
9-
import org.assertj.core.api.Assertions;
109
import org.junit.jupiter.api.BeforeEach;
1110
import org.junit.jupiter.api.DisplayName;
1211
import org.junit.jupiter.api.Nested;
1312
import org.junit.jupiter.api.Test;
14-
import org.junit.jupiter.params.ParameterizedTest;
15-
import org.junit.jupiter.params.provider.CsvSource;
16-
17-
import static com.microsoft.playwright.assertions.PlaywrightAssertions.assertThat;
1813

1914
@DisplayName("Adding and deleting todo items to the list")
2015
@Feature("Adding and deleting todo items to the list")
@@ -26,7 +21,6 @@ class AddingAndDeletingTodoItemsTest {
2621
@BeforeEach
2722
void openApp(Page page) {
2823
todoMvcApp = new TodoMvcAppPage(page);
29-
3024
todoMvcApp.open();
3125
}
3226

@@ -37,16 +31,17 @@ class WhenTheApplicationStarts {
3731
@DisplayName("The list should be empty")
3832
@Test
3933
void the_list_should_initially_be_empty() {
40-
Assertions.assertThat(todoMvcApp.todoItemsDisplayed()).isEmpty();
34+
// TODO: Implement me
35+
// 1) Verify that no items are displayed in the todo list
4136
}
4237

4338
@DisplayName("The user should be prompted to enter a todo item")
4439
@Test
4540
void the_user_should_be_prompted_to_enter_a_value() {
46-
assertThat(todoMvcApp.todoField()).isVisible();
47-
assertThat(todoMvcApp.todoField()).hasAttribute("placeholder", "What needs to be done?");
41+
// TODO: Implement me
42+
// 1) Verify that the input field is visible
43+
// 2) Verify that the placeholder text is "What needs to be done?"
4844
}
49-
5045
}
5146

5247
@Story("When we want to add item to the list")
@@ -57,57 +52,42 @@ class WhenAddingItems {
5752
@DisplayName("We can add a single item")
5853
@Test
5954
void addingASingleItem() {
60-
todoMvcApp.addTodoItem("Feed the cat");
61-
62-
Assertions.assertThat(todoMvcApp.todoItemsDisplayed()).containsExactly("Feed the cat");
63-
55+
// TODO: Implement me
56+
// 1) Add a single todo item "Feed the cat"
57+
// 2) Verify that the list contains exactly "Feed the cat"
6458
}
6559

6660
@DisplayName("We can add multiple items")
6761
@Test
6862
void addingSeveralItem() {
69-
todoMvcApp.addTodoItem("Feed the cat");
70-
todoMvcApp.addTodoItem("Walk the dog");
71-
72-
Assertions.assertThat(todoMvcApp.todoItemsDisplayed()).containsExactly("Feed the cat", "Walk the dog");
63+
// TODO: Implement me
64+
// 1) Add multiple items "Feed the cat" and "Walk the dog"
65+
// 2) Verify that the list contains exactly "Feed the cat" and "Walk the dog"
7366
}
7467

75-
@DisplayName("We can't add add an empty item")
68+
@DisplayName("We can't add an empty item")
7669
@Test
7770
void addingAnEmptyItem() {
78-
todoMvcApp.addTodoItem("Feed the cat");
79-
todoMvcApp.addTodoItem("");
80-
81-
Assertions.assertThat(todoMvcApp.todoItemsDisplayed()).containsExactly("Feed the cat");
82-
71+
// TODO: Implement me
72+
// 1) Add a valid item "Feed the cat"
73+
// 2) Attempt to add an empty item
74+
// 3) Verify that the list contains only "Feed the cat"
8375
}
8476

8577
@DisplayName("We can add duplicate items")
8678
@Test
8779
void addingDuplicateItem() {
88-
todoMvcApp.addTodoItem("Feed the cat");
89-
todoMvcApp.addTodoItem("Walk the dog");
90-
todoMvcApp.addTodoItem("Feed the cat");
91-
92-
Assertions.assertThat(todoMvcApp.todoItemsDisplayed()).containsExactly("Feed the cat", "Walk the dog","Feed the cat");
80+
// TODO: Implement me
81+
// 1) Add items "Feed the cat", "Walk the dog", and "Feed the cat" again
82+
// 2) Verify that the list contains duplicates in the order they were added
9383
}
9484

9585
@DisplayName("We can add items with non-English characters")
96-
@ParameterizedTest
97-
@CsvSource({
98-
"Feed the cat", // English
99-
"Alimentar al gato", // Spanish
100-
"להאכיל את החתול", // Hebrew
101-
"ให้อาหารแมว", // Thai
102-
"喂猫", // Chinese
103-
"إطعام القط", // Arabic
104-
"кормить кошку", // Russian
105-
"猫に餌をやる", // Japanese
106-
"고양이 먹이기" // Korean
107-
})
108-
void addingNonEnglishItems(String item) {
109-
todoMvcApp.addTodoItem(item);
110-
Assertions.assertThat(todoMvcApp.todoItemsDisplayed()).containsExactly(item);
86+
@Test
87+
void addingNonEnglishItems() {
88+
// TODO: Implement me
89+
// 1) Add items in various languages (e.g., "Feed the cat", "喂猫", "إطعام القط")
90+
// 2) Verify that each item appears in the list as added
11191
}
11292
}
11393

@@ -119,39 +99,28 @@ class WhenDeletingItems {
11999
@DisplayName("We can delete an item in the middle of the list")
120100
@Test
121101
void deletingAnItemInTheMiddleOfTheList() {
122-
todoMvcApp.addTodoItems("Feed the cat", "Walk the dog", "Buy some milk");
123-
124-
todoMvcApp.deleteItem("Walk the dog");
125-
126-
Assertions.assertThat(todoMvcApp.todoItemsDisplayed()).containsExactly("Feed the cat", "Buy some milk");
127-
102+
// TODO: Implement me
103+
// 1) Add items "Feed the cat", "Walk the dog", "Buy some milk"
104+
// 2) Delete "Walk the dog"
105+
// 3) Verify that the list contains "Feed the cat" and "Buy some milk"
128106
}
129107

130-
131108
@DisplayName("We can delete an item at the end of the list")
132109
@Test
133110
void deletingAnItemAtTheEndOfTheList() {
134-
todoMvcApp.addTodoItems("Feed the cat", "Walk the dog", "Buy some milk");
135-
136-
todoMvcApp.deleteItem("Buy some milk");
137-
138-
Assertions.assertThat(todoMvcApp.todoItemsDisplayed()).containsExactly("Feed the cat", "Walk the dog");
139-
111+
// TODO: Implement me
112+
// 1) Add items "Feed the cat", "Walk the dog", "Buy some milk"
113+
// 2) Delete "Buy some milk"
114+
// 3) Verify that the list contains "Feed the cat" and "Walk the dog"
140115
}
141116

142-
143-
144117
@DisplayName("We can delete an item at the start of the list")
145118
@Test
146119
void deletingAnItemAtTheStartOfTheList() {
147-
todoMvcApp.addTodoItems("Feed the cat", "Walk the dog", "Buy some milk");
148-
149-
todoMvcApp.deleteItem("Feed the cat");
150-
151-
Assertions.assertThat(todoMvcApp.todoItemsDisplayed()).containsExactly("Walk the dog", "Buy some milk");
152-
120+
// TODO: Implement me
121+
// 1) Add items "Feed the cat", "Walk the dog", "Buy some milk"
122+
// 2) Delete "Feed the cat"
123+
// 3) Verify that the list contains "Walk the dog" and "Buy some milk"
153124
}
154-
155125
}
156-
157126
}

todomvc-acceptance-tests/src/test/java/com/serenitydojo/playwright/todomvc/CompletingTodoItemsTest.java

Lines changed: 13 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,9 @@
55
import com.serenitydojo.playwright.fixtures.ChromeHeadlessOptions;
66
import com.serenitydojo.playwright.todomvc.pageobjects.TodoMvcAppPage;
77
import io.qameta.allure.Feature;
8-
import org.assertj.core.api.Assertions;
98
import org.junit.jupiter.api.BeforeEach;
109
import org.junit.jupiter.api.DisplayName;
11-
import org.junit.jupiter.api.Nested;
1210
import org.junit.jupiter.api.Test;
13-
import org.junit.jupiter.params.ParameterizedTest;
14-
import org.junit.jupiter.params.provider.CsvSource;
15-
16-
import static com.microsoft.playwright.assertions.PlaywrightAssertions.assertThat;
1711

1812
@DisplayName("Completing todo items to the list")
1913
@UsePlaywright(ChromeHeadlessOptions.class)
@@ -32,31 +26,28 @@ void openApp(Page page) {
3226
@DisplayName("Completed items should be marked as completed")
3327
@Test
3428
void completedItemsShouldBeMarkedAsCompleted() {
35-
todoMvcApp.addTodoItems("Feed the cat","Walk the dog","Buy some milk");
36-
37-
todoMvcApp.completeItem("Feed the cat");
38-
39-
assertThat(todoMvcApp.itemRow("Feed the cat")).hasClass("completed");
29+
// TODO: Implement me
30+
// 1) Add "Feed the cat", "Walk the dog", "Buy some milk"
31+
// 2) Complete "Feed the cat"
32+
// 3) Check that "Feed the cat" is shown as completed
4033
}
4134

4235
@DisplayName("Completing an item should update the number of items left count")
4336
@Test
4437
void shouldUpdateNumberOfItemsLeftCount() {
45-
todoMvcApp.addTodoItems("Feed the cat","Walk the dog","Buy some milk");
46-
47-
todoMvcApp.completeItem("Feed the cat");
48-
49-
Assertions.assertThat(todoMvcApp.todoCount()).isEqualTo("2 items left!");
38+
// TODO: Implement me
39+
// 1) Add "Feed the cat", "Walk the dog", "Buy some milk"
40+
// 2) Complete "Feed the cat"
41+
// 3) Verify the todo count shows "2 items left!"
5042
}
5143

5244
@DisplayName("Should be able to clear completed items")
5345
@Test
5446
void shouldBeAbleToClearCompletedItems() {
55-
todoMvcApp.addTodoItems("Feed the cat", "Walk the dog", "Buy some milk");
56-
57-
todoMvcApp.completeItem("Walk the dog");
58-
todoMvcApp.clearCompleted();
59-
60-
Assertions.assertThat(todoMvcApp.todoItemsDisplayed()).containsExactly("Feed the cat", "Buy some milk");
47+
// TODO: Implement me
48+
// 1) Add "Feed the cat", "Walk the dog", "Buy some milk"
49+
// 2) Complete "Walk the dog"
50+
// 3) Clear the completed items
51+
// 4) Verify that the remaining items are "Feed the cat" and "Buy some milk"
6152
}
6253
}

0 commit comments

Comments
 (0)