Skip to content

Commit c376b81

Browse files
committed
Assertj examples
1 parent 086ec86 commit c376b81

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed

src/test/java/com/serenitydojo/playwright/PlaywrightAssertionsTest.java

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
import org.junit.jupiter.api.parallel.ExecutionMode;
1313

1414
import java.util.Arrays;
15+
import java.util.Comparator;
1516
import java.util.List;
1617
import java.util.regex.Pattern;
1718

@@ -125,5 +126,27 @@ void allProductPricesShouldBeCorrectValues() {
125126
.isGreaterThan(0.0)
126127
.isLessThan(1000.0));
127128
}
129+
130+
131+
@Test
132+
void shouldSortInAlphabeticalOrder() {
133+
page.getByLabel("Sort").selectOption("Name (A - Z)");
134+
page.waitForLoadState(LoadState.NETWORKIDLE);
135+
136+
List<String> productNames = page.getByTestId("product-name").allTextContents();
137+
138+
Assertions.assertThat(productNames).isSortedAccordingTo(String.CASE_INSENSITIVE_ORDER);
139+
}
140+
141+
@Test
142+
void shouldSortInReverseAlphabeticalOrder() {
143+
page.getByLabel("Sort").selectOption("Name (Z - A)");
144+
page.waitForLoadState(LoadState.NETWORKIDLE);
145+
146+
List<String> productNames = page.getByTestId("product-name").allTextContents();
147+
148+
Assertions.assertThat(productNames).isSortedAccordingTo(Comparator.reverseOrder());
149+
}
150+
128151
}
129152
}

0 commit comments

Comments
 (0)