Skip to content

Commit

Permalink
nope, locale issues between workstation & CI
Browse files Browse the repository at this point in the history
  • Loading branch information
mstahv committed Feb 23, 2024
1 parent 0107ebc commit 268ecc3
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 9 deletions.
15 changes: 8 additions & 7 deletions src/test/java/firitin/pw/DatePickerIT.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import java.util.Locale;

import static com.microsoft.playwright.assertions.PlaywrightAssertions.assertThat;
import static org.junit.jupiter.api.Assertions.assertEquals;
Expand Down Expand Up @@ -78,7 +79,8 @@ public void doStuffWithDatePickerPw() {
value = datePickerPw.getValue();
String valueInField = datePickerPw.getInputString();

String formattedNow = DateTimeFormatter.ofPattern("dd.M.yyyy").format(now);

String formattedNow = DateTimeFormatter.ofPattern("M/d/yyyy", Locale.US).format(now);

assertEquals(formattedNow, valueInField);
assertThat(page.locator("#dpValue")).containsText(now.toString());
Expand All @@ -93,19 +95,18 @@ public void doStuffWithDatePickerPw() {

String dateInputValue = dateTimePickerPw.getDateInputString();
String timeInputValue = dateTimePickerPw.getTimeInputString();
assertEquals("24.12.2001", dateInputValue);
assertEquals("22.36.00", timeInputValue);
assertEquals("12/24/2001", dateInputValue);
assertEquals("10:36:00 PM", timeInputValue);

System.out.println("Success!!");

}

@Test
public void doStuffWithRawApi() {
// Finnish formatting set in the UI
DateTimeFormatter dateFormatter = DateTimeFormatter.ofPattern("dd.MM.yyyy");
DateTimeFormatter timeFormatter = DateTimeFormatter.ofPattern("HH.mm");
DateTimeFormatter dateTimeFormatter = DateTimeFormatter.ofPattern("dd.MM.yyyy HH.mm");
DateTimeFormatter dateFormatter = DateTimeFormatter.ofPattern("M/d/yyyy");
DateTimeFormatter timeFormatter = DateTimeFormatter.ofPattern("HH:mm");
DateTimeFormatter dateTimeFormatter = DateTimeFormatter.ofPattern("M/d/yyyy HH:mm");

page.navigate("http://localhost:" + port + "/date");

Expand Down
4 changes: 2 additions & 2 deletions src/test/java/firitin/ui/DateView.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,9 @@ public class DateView extends VerticalLayout {

public DateView() {

UI.getCurrent().setLocale(Locale.forLanguageTag("fi"));

DatePicker datePicker = new DatePicker();
datePicker.setId("dp");
datePicker.setLocale(Locale.US);

Paragraph dpValue = new Paragraph();
dpValue.setId("dpValue");
Expand All @@ -32,6 +31,7 @@ public DateView() {
add(datePicker, dpValue);

DateTimePicker dateTimePicker = new DateTimePicker();
dateTimePicker.setLocale(Locale.US);
dateTimePicker.setStep(Duration.of(1, ChronoUnit.SECONDS));
dateTimePicker.setId("dtp");
Paragraph dtpValue = new Paragraph();
Expand Down

0 comments on commit 268ecc3

Please sign in to comment.