From 268ecc3b9923d5b7ac9f10439f9c306a640cfc0d Mon Sep 17 00:00:00 2001 From: Matti Tahvonen Date: Fri, 23 Feb 2024 10:59:18 +0200 Subject: [PATCH] nope, locale issues between workstation & CI --- src/test/java/firitin/pw/DatePickerIT.java | 15 ++++++++------- src/test/java/firitin/ui/DateView.java | 4 ++-- 2 files changed, 10 insertions(+), 9 deletions(-) diff --git a/src/test/java/firitin/pw/DatePickerIT.java b/src/test/java/firitin/pw/DatePickerIT.java index 535651c..ef9f4c5 100644 --- a/src/test/java/firitin/pw/DatePickerIT.java +++ b/src/test/java/firitin/pw/DatePickerIT.java @@ -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; @@ -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()); @@ -93,8 +95,8 @@ 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!!"); @@ -102,10 +104,9 @@ public void doStuffWithDatePickerPw() { @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"); diff --git a/src/test/java/firitin/ui/DateView.java b/src/test/java/firitin/ui/DateView.java index d75f9ab..b293872 100644 --- a/src/test/java/firitin/ui/DateView.java +++ b/src/test/java/firitin/ui/DateView.java @@ -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"); @@ -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();