From 86d26723d38cadcd4bd275ba0e8a3db27b361d32 Mon Sep 17 00:00:00 2001 From: Karan Gathani Date: Thu, 19 Sep 2024 20:09:08 -0700 Subject: [PATCH 1/7] add tests for input_date and date_range --- shiny/api-examples/input_date/app-core.py | 8 +++++ .../api-examples/input_date_range/app-core.py | 4 +++ shiny/playwright/controller/_input_fields.py | 31 ++++++++++++++++--- .../shiny/inputs/test_input_date.py | 13 +++++++- .../shiny/inputs/test_input_date_range.py | 18 +++++++---- 5 files changed, 63 insertions(+), 11 deletions(-) diff --git a/shiny/api-examples/input_date/app-core.py b/shiny/api-examples/input_date/app-core.py index 8717487db..c92caa355 100644 --- a/shiny/api-examples/input_date/app-core.py +++ b/shiny/api-examples/input_date/app-core.py @@ -23,6 +23,14 @@ value="2016-02-29", datesdisabled=["2016-03-01", "2016-03-02"], ), + # Set min and max dates. + ui.input_date( + "date9", "Date:", value="2016-02-03", min="2016-02-01", max="2016-02-29" + ), + # Set width of the date field + ui.input_date("date10", "Date:", width="600px"), + # Set autoclose to false + ui.input_date("date11", "Date:", autoclose=False), ) diff --git a/shiny/api-examples/input_date_range/app-core.py b/shiny/api-examples/input_date_range/app-core.py index 07b4bcbac..3c4039c17 100644 --- a/shiny/api-examples/input_date_range/app-core.py +++ b/shiny/api-examples/input_date_range/app-core.py @@ -28,6 +28,10 @@ ui.input_date_range("daterange5", "Date range:", language="de", weekstart=1), # Start with decade view instead of default month view ui.input_date_range("daterange6", "Date range:", startview="decade"), + # Set width of the daterange field + ui.input_date_range("daterange7", "Date range:", width="600px"), + # Set autoclose to false + ui.input_date_range("daterange8", "Date range:", autoclose=False), ) diff --git a/shiny/playwright/controller/_input_fields.py b/shiny/playwright/controller/_input_fields.py index 1054e2207..7133a7095 100644 --- a/shiny/playwright/controller/_input_fields.py +++ b/shiny/playwright/controller/_input_fields.py @@ -17,6 +17,7 @@ from ._base import ( Resize, UiBaseP, + UiWithContainerP, UiWithLabel, WidthContainerM, WidthLocM, @@ -26,6 +27,30 @@ ) +class InputDateWidthM: + """ + A mixin class for input date width. + This mixin class provides methods to expect the width of input date elements. + """ + + def expect_width( + self: UiWithContainerP, + value: AttrValue, + *, + timeout: Timeout = None, + ) -> None: + """ + Expect the input select to have a specific width. + Parameters + ---------- + value + The expected width. + timeout + The maximum time to wait for the expectation to be fulfilled. Defaults to `None`. + """ + _expect_style_to_have_value(self.loc_container, "width", value, timeout=timeout) + + class _SetTextM: def set(self: UiBaseP, value: str, *, timeout: Timeout = None) -> None: """ @@ -425,8 +450,8 @@ def expect_autoresize( class _DateBase( + InputDateWidthM, _SetTextM, - WidthContainerM, UiWithLabel, ): @@ -669,7 +694,7 @@ def __init__(self, page: Page, id: str) -> None: ) -class InputDateRange(WidthContainerM, UiWithLabel): +class InputDateRange(InputDateWidthM, UiWithLabel): """Controller for :func:`shiny.ui.input_date_range`.""" loc_separator: Locator @@ -933,8 +958,6 @@ def expect_separator( """ playwright_expect(self.loc_separator).to_have_text(value, timeout=timeout) - # width: Optional[str] = None, - # autoclose: bool = True, def expect_autoclose( self, diff --git a/tests/playwright/shiny/inputs/test_input_date.py b/tests/playwright/shiny/inputs/test_input_date.py index 38e8f74f8..8a2889bc7 100644 --- a/tests/playwright/shiny/inputs/test_input_date.py +++ b/tests/playwright/shiny/inputs/test_input_date.py @@ -31,6 +31,7 @@ def expect_date( ) -> None: date.expect_value(str(datetime.date.today()) if value == "today" else value) autoclose_str = "true" if autoclose else "false" + date.expect_label(label) date.expect_autoclose(autoclose_str) date.expect_datesdisabled(datesdisabled) date.expect_daysofweekdisabled(daysofweekdisabled) @@ -48,7 +49,6 @@ def test_input_date_kitchen(page: Page, app: ShinyAppProc) -> None: date1 = controller.InputDate(page, "date1") - date1.expect_label("Date:") expect(date1.loc_label).to_have_text("Date:") expect_date(date1, "2016-02-29") @@ -75,3 +75,14 @@ def test_input_date_kitchen(page: Page, app: ShinyAppProc) -> None: "2016-02-29", datesdisabled=["2016-03-01", "2016-03-02"], ) + + expect_date( + controller.InputDate(page, "date9"), + "2016-02-03", + min_date="2016-02-01", + max_date="2016-02-29", + ) + + expect_date(controller.InputDate(page, "date10"), width="600px") + + expect_date(controller.InputDate(page, "date11"), autoclose=False) diff --git a/tests/playwright/shiny/inputs/test_input_date_range.py b/tests/playwright/shiny/inputs/test_input_date_range.py index e5f9c7a6e..42dbd90c4 100644 --- a/tests/playwright/shiny/inputs/test_input_date_range.py +++ b/tests/playwright/shiny/inputs/test_input_date_range.py @@ -18,10 +18,8 @@ def expect_date_range( start_value: str | Literal["today"] = "today", end_value: str | Literal["today"] = "today", *, - label: str = "Date:", + label: str = "Date range:", autoclose: bool = True, - datesdisabled: typing.Optional[list[str]] = None, - daysofweekdisabled: typing.Optional[list[int]] = None, format: str = "yyyy-mm-dd", language: str = "en", max_date: typing.Optional[str] = None, @@ -34,11 +32,9 @@ def expect_date_range( start_value = str(datetime.date.today()) if start_value == "today" else start_value end_value = str(datetime.date.today()) if end_value == "today" else end_value date.expect_value((start_value, end_value)) + date.expect_label(label) autoclose_str = "true" if autoclose else "false" date.expect_autoclose(autoclose_str) - # # Not supported in `input_date_range()` - # date.expect_datesdisabled(datesdisabled) - # date.expect_daysofweekdisabled(daysofweekdisabled) date.expect_format(format) date.expect_language(language) date.expect_max_date(max_date) @@ -88,3 +84,13 @@ def test_input_date_kitchen(page: Page, app: ShinyAppProc) -> None: controller.InputDateRange(page, "daterange6"), startview="decade", ) + + expect_date_range( + controller.InputDateRange(page, "daterange7"), + width="600px", + ) + + expect_date_range( + controller.InputDateRange(page, "daterange8"), + autoclose=False, + ) From 3fc21079f4f22fdf84257d154d41eae1137a1805 Mon Sep 17 00:00:00 2001 From: Karan Gathani Date: Thu, 19 Sep 2024 20:14:10 -0700 Subject: [PATCH 2/7] remove unused imports --- shiny/playwright/controller/_input_fields.py | 1 - 1 file changed, 1 deletion(-) diff --git a/shiny/playwright/controller/_input_fields.py b/shiny/playwright/controller/_input_fields.py index 7133a7095..9c76f75ef 100644 --- a/shiny/playwright/controller/_input_fields.py +++ b/shiny/playwright/controller/_input_fields.py @@ -19,7 +19,6 @@ UiBaseP, UiWithContainerP, UiWithLabel, - WidthContainerM, WidthLocM, all_missing, not_is_missing, From 2cd0bbb8ccc98c6333ef00e652bd72422f00396c Mon Sep 17 00:00:00 2001 From: Karan Gathani Date: Fri, 20 Sep 2024 08:44:54 -0700 Subject: [PATCH 3/7] Update CHANGELOG.md --- CHANGELOG.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index db516d0fa..62782cffe 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -37,6 +37,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 * Fixed the `InputSlider` controller's `.expect_width()` to check the `width` property within the `style` attribute. (#1691) +* Fixed the `InputDate` and `InputDateRange` controllers to check the `width` property within the `style` attribute. (#1696) + ## [1.1.0] - 2024-09-03 ### New features From 03bdc1610b035bb672a25e5f5644c790e4c10112 Mon Sep 17 00:00:00 2001 From: Barret Schloerke Date: Fri, 20 Sep 2024 12:42:35 -0400 Subject: [PATCH 4/7] Code review Co-Authored-By: Karan --- shiny/api-examples/input_date/app-core.py | 31 ++++++++++++------- shiny/api-examples/input_date/app-express.py | 4 ++- .../api-examples/input_date_range/app-core.py | 31 +++++++++++++------ .../input_date_range/app-express.py | 2 ++ shiny/playwright/controller/_accordion.py | 2 +- shiny/playwright/controller/_input_buttons.py | 2 +- .../playwright/controller/_input_controls.py | 2 +- shiny/playwright/controller/_input_fields.py | 1 + 8 files changed, 50 insertions(+), 25 deletions(-) diff --git a/shiny/api-examples/input_date/app-core.py b/shiny/api-examples/input_date/app-core.py index c92caa355..457ff304c 100644 --- a/shiny/api-examples/input_date/app-core.py +++ b/shiny/api-examples/input_date/app-core.py @@ -3,34 +3,43 @@ from shiny import App, Inputs, Outputs, Session, ui app_ui = ui.page_fluid( - ui.input_date("date1", "Date:", value="2016-02-29"), + ui.input_date("date1", "Has default date:", value="2016-02-29"), # Default value is the date in client's time zone - ui.input_date("date2", "Date:"), + ui.input_date("date2", "Client's timezone:"), # value is always yyyy-mm-dd, even if the display format is different - ui.input_date("date3", "Date:", value="2016-02-29", format="mm/dd/yy"), + ui.input_date("date3", "Format mm/dd/yy:", value="2016-02-29", format="mm/dd/yy"), # Pass in a Date object - ui.input_date("date4", "Date:", value=date(2016, 2, 29)), + ui.input_date("date4", "Default uses date object:", value=date(2016, 2, 29)), # Use different language and different first day of week - ui.input_date("date5", "Date:", language="ru", weekstart=1), + ui.input_date( + "date5", + "Language is German and the week starts on Monday:", + language="ru", + weekstart=1, + ), # Start with decade view instead of default month view - ui.input_date("date6", "Date:", startview="decade"), + ui.input_date("date6", "Start Date picker in Decade view:", startview="decade"), # Disable Mondays and Tuesdays. - ui.input_date("date7", "Date:", daysofweekdisabled=[1, 2]), + ui.input_date("date7", "Disable Monday and Tuesday:", daysofweekdisabled=[1, 2]), # Disable specific dates. ui.input_date( "date8", - "Date:", + "Disable specific dates:", value="2016-02-29", datesdisabled=["2016-03-01", "2016-03-02"], ), # Set min and max dates. ui.input_date( - "date9", "Date:", value="2016-02-03", min="2016-02-01", max="2016-02-29" + "date9", + "Set min and max dates:", + value="2016-02-03", + min="2016-02-01", + max="2016-02-29", ), # Set width of the date field - ui.input_date("date10", "Date:", width="600px"), + ui.input_date("date10", "Set width of text input:", width="600px"), # Set autoclose to false - ui.input_date("date11", "Date:", autoclose=False), + ui.input_date("date11", "Auto close is disabled:", autoclose=False), ) diff --git a/shiny/api-examples/input_date/app-express.py b/shiny/api-examples/input_date/app-express.py index bd696beb3..668b7017e 100644 --- a/shiny/api-examples/input_date/app-express.py +++ b/shiny/api-examples/input_date/app-express.py @@ -2,6 +2,8 @@ from shiny.express import ui +# TODO-karan. Duplicate changes from app-core.py + ui.input_date("date1", "Date:", value="2016-02-29") # Default value is the date in client's time zone ui.input_date("date2", "Date:") @@ -10,7 +12,7 @@ # Pass in a Date object ui.input_date("date4", "Date:", value=date(2016, 2, 29)) # Use different language and different first day of week -ui.input_date("date5", "Date:", language="ru", weekstart=1) +ui.input_date("date5", "Date:", language="de", weekstart=1) # Start with decade view instead of default month view ui.input_date("date6", "Date:", startview="decade") # Disable Mondays and Tuesdays. diff --git a/shiny/api-examples/input_date_range/app-core.py b/shiny/api-examples/input_date_range/app-core.py index 3c4039c17..77baf2c34 100644 --- a/shiny/api-examples/input_date_range/app-core.py +++ b/shiny/api-examples/input_date_range/app-core.py @@ -3,16 +3,17 @@ from shiny import App, Inputs, Outputs, Session, ui app_ui = ui.page_fluid( + # Default start and end is the current date in the client's time zone + ui.input_date_range("daterange1", "Date range:"), + # Set start and end dates ui.input_date_range( - "daterange1", "Date range:", start="2001-01-01", end="2010-12-31" + "daterange2", "Set start and end date:", start="2001-01-01", end="2010-12-31" ), - # Default start and end is the current date in the client's time zone - ui.input_date_range("daterange2", "Date range:"), - # start and end are always specified in yyyy-mm-dd, even if the display + # Start and end are always specified in yyyy-mm-dd, even if the display # format is different ui.input_date_range( "daterange3", - "Date range:", + "Min, max, start, and end dates are set with custom format and separator:", start="2001-01-01", end="2010-12-31", min="2001-01-01", @@ -22,16 +23,26 @@ ), # Pass in Date objects ui.input_date_range( - "daterange4", "Date range:", start=date(2001, 1, 1), end=date(2010, 12, 31) + "daterange4", + "Default start and end use date objects:", + start=date(2001, 1, 1), + end=date(2010, 12, 31), ), # Use different language and different first day of week - ui.input_date_range("daterange5", "Date range:", language="de", weekstart=1), + ui.input_date_range( + "daterange5", + "Language is German and we starts on Monday:", + language="de", + weekstart=1, + ), # Start with decade view instead of default month view - ui.input_date_range("daterange6", "Date range:", startview="decade"), + ui.input_date_range( + "daterange6", "Start Date picker in Decade view:", startview="decade" + ), # Set width of the daterange field - ui.input_date_range("daterange7", "Date range:", width="600px"), + ui.input_date_range("daterange7", "Set width of text input:", width="600px"), # Set autoclose to false - ui.input_date_range("daterange8", "Date range:", autoclose=False), + ui.input_date_range("daterange8", "Auto close is disabled:", autoclose=False), ) diff --git a/shiny/api-examples/input_date_range/app-express.py b/shiny/api-examples/input_date_range/app-express.py index 66f79c5c4..5d7e15aa3 100644 --- a/shiny/api-examples/input_date_range/app-express.py +++ b/shiny/api-examples/input_date_range/app-express.py @@ -2,6 +2,8 @@ from shiny.express import ui +# TODO-karan. Duplicate changes from app-core.py + ui.input_date_range("daterange1", "Date range:", start="2001-01-01", end="2010-12-31") # Default start and end is the current date in the client's time zone ui.input_date_range("daterange2", "Date range:") diff --git a/shiny/playwright/controller/_accordion.py b/shiny/playwright/controller/_accordion.py index d5981e156..890b03bde 100644 --- a/shiny/playwright/controller/_accordion.py +++ b/shiny/playwright/controller/_accordion.py @@ -229,7 +229,7 @@ def expect_width(self, value: StyleValue, *, timeout: Timeout = None) -> None: value The expected width. timeout - The maximum time to wait for the width to be visible and interactable. Defaults to `None`. + The maximum time to wait for the expectation to be fulfilled. Defaults to `None`. """ _expect_style_to_have_value(self.loc_container, "width", value, timeout=timeout) diff --git a/shiny/playwright/controller/_input_buttons.py b/shiny/playwright/controller/_input_buttons.py index e55e8cbfe..59326ee62 100644 --- a/shiny/playwright/controller/_input_buttons.py +++ b/shiny/playwright/controller/_input_buttons.py @@ -420,7 +420,7 @@ def expect_width(self, value: StyleValue, *, timeout: Timeout = None) -> None: value The expected value of the width. timeout - The timeout for the expectation. Defaults to `None`. + The maximum time to wait for the expectation to be fulfilled. Defaults to `None`. """ _expect_style_to_have_value(self.loc_container, "width", value, timeout=timeout) diff --git a/shiny/playwright/controller/_input_controls.py b/shiny/playwright/controller/_input_controls.py index 663cd039e..54fc5ac12 100644 --- a/shiny/playwright/controller/_input_controls.py +++ b/shiny/playwright/controller/_input_controls.py @@ -211,7 +211,7 @@ def expect_width(self, value: str, *, timeout: Timeout = None) -> None: value The expected width. timeout - The maximum time to wait for the width to be visible and interactable. Defaults to `None`. + The maximum time to wait for the expectation to be fulfilled. Defaults to `None`. """ _expect_style_to_have_value(self.loc_container, "width", value, timeout=timeout) diff --git a/shiny/playwright/controller/_input_fields.py b/shiny/playwright/controller/_input_fields.py index 9c76f75ef..affa9cee7 100644 --- a/shiny/playwright/controller/_input_fields.py +++ b/shiny/playwright/controller/_input_fields.py @@ -40,6 +40,7 @@ def expect_width( ) -> None: """ Expect the input select to have a specific width. + Parameters ---------- value From 4a904e548f73a4d64eebe67dd0c27c08e77051ed Mon Sep 17 00:00:00 2001 From: Karan Gathani Date: Mon, 23 Sep 2024 13:02:58 -0700 Subject: [PATCH 5/7] code review comments --- shiny/api-examples/input_date/app-express.py | 35 +++++++++++++------ .../input_date_range/app-express.py | 33 ++++++++++++----- .../shiny/inputs/test_input_date.py | 7 ++-- .../shiny/inputs/test_input_date_range.py | 21 +++++------ 4 files changed, 62 insertions(+), 34 deletions(-) diff --git a/shiny/api-examples/input_date/app-express.py b/shiny/api-examples/input_date/app-express.py index 668b7017e..7af693db7 100644 --- a/shiny/api-examples/input_date/app-express.py +++ b/shiny/api-examples/input_date/app-express.py @@ -2,25 +2,40 @@ from shiny.express import ui -# TODO-karan. Duplicate changes from app-core.py - -ui.input_date("date1", "Date:", value="2016-02-29") +ui.input_date("date1", "Has default date:", value="2016-02-29") # Default value is the date in client's time zone -ui.input_date("date2", "Date:") +ui.input_date("date2", "Client's timezone:") # value is always yyyy-mm-dd, even if the display format is different -ui.input_date("date3", "Date:", value="2016-02-29", format="mm/dd/yy") +ui.input_date("date3", "Format mm/dd/yy:", value="2016-02-29", format="mm/dd/yy") # Pass in a Date object -ui.input_date("date4", "Date:", value=date(2016, 2, 29)) +ui.input_date("date4", "Default uses date object:", value=date(2016, 2, 29)) # Use different language and different first day of week -ui.input_date("date5", "Date:", language="de", weekstart=1) +ui.input_date( + "date5", + "Language is German and the week starts on Monday:", + language="ru", + weekstart=1, +) # Start with decade view instead of default month view -ui.input_date("date6", "Date:", startview="decade") +ui.input_date("date6", "Start Date picker in Decade view:", startview="decade") # Disable Mondays and Tuesdays. -ui.input_date("date7", "Date:", daysofweekdisabled=[1, 2]) +ui.input_date("date7", "Disable Monday and Tuesday:", daysofweekdisabled=[1, 2]) # Disable specific dates. ui.input_date( "date8", - "Date:", + "Disable specific dates:", value="2016-02-29", datesdisabled=["2016-03-01", "2016-03-02"], ) +# Set min and max dates. +ui.input_date( + "date9", + "Set min and max dates:", + value="2016-02-03", + min="2016-02-01", + max="2016-02-29", +) +# Set width of the date field +ui.input_date("date10", "Set width of text input:", width="600px") +# Set autoclose to false +ui.input_date("date11", "Auto close is disabled:", autoclose=False) diff --git a/shiny/api-examples/input_date_range/app-express.py b/shiny/api-examples/input_date_range/app-express.py index 5d7e15aa3..7e7074560 100644 --- a/shiny/api-examples/input_date_range/app-express.py +++ b/shiny/api-examples/input_date_range/app-express.py @@ -2,16 +2,17 @@ from shiny.express import ui -# TODO-karan. Duplicate changes from app-core.py - -ui.input_date_range("daterange1", "Date range:", start="2001-01-01", end="2010-12-31") # Default start and end is the current date in the client's time zone -ui.input_date_range("daterange2", "Date range:") -# start and end are always specified in yyyy-mm-dd, even if the display +ui.input_date_range("daterange1", "Date range:") +# Set start and end dates +ui.input_date_range( + "daterange2", "Set start and end date:", start="2001-01-01", end="2010-12-31" +) +# Start and end are always specified in yyyy-mm-dd, even if the display # format is different ui.input_date_range( "daterange3", - "Date range:", + "Min, max, start, and end dates are set with custom format and separator:", start="2001-01-01", end="2010-12-31", min="2001-01-01", @@ -21,9 +22,23 @@ ) # Pass in Date objects ui.input_date_range( - "daterange4", "Date range:", start=date(2001, 1, 1), end=date(2010, 12, 31) + "daterange4", + "Default start and end use date objects:", + start=date(2001, 1, 1), + end=date(2010, 12, 31), ) # Use different language and different first day of week -ui.input_date_range("daterange5", "Date range:", language="de", weekstart=1) +ui.input_date_range( + "daterange5", + "Language is German and we starts on Monday:", + language="de", + weekstart=1, +) # Start with decade view instead of default month view -ui.input_date_range("daterange6", "Date range:", startview="decade") +ui.input_date_range( + "daterange6", "Start Date picker in Decade view:", startview="decade" +) +# Set width of the daterange field +ui.input_date_range("daterange7", "Set width of text input:", width="600px") +# Set autoclose to false +ui.input_date_range("daterange8", "Auto close is disabled:", autoclose=False) diff --git a/tests/playwright/shiny/inputs/test_input_date.py b/tests/playwright/shiny/inputs/test_input_date.py index 8a2889bc7..57786ce73 100644 --- a/tests/playwright/shiny/inputs/test_input_date.py +++ b/tests/playwright/shiny/inputs/test_input_date.py @@ -5,7 +5,7 @@ from typing import Literal from conftest import create_doc_example_core_fixture -from playwright.sync_api import Page, expect +from playwright.sync_api import Page from shiny.playwright import controller from shiny.run import ShinyAppProc @@ -17,7 +17,6 @@ def expect_date( date: controller.InputDate, value: str | Literal["today"] = "today", *, - label: str = "Date:", autoclose: bool = True, datesdisabled: typing.Optional[list[str]] = None, daysofweekdisabled: typing.Optional[list[int]] = None, @@ -31,7 +30,6 @@ def expect_date( ) -> None: date.expect_value(str(datetime.date.today()) if value == "today" else value) autoclose_str = "true" if autoclose else "false" - date.expect_label(label) date.expect_autoclose(autoclose_str) date.expect_datesdisabled(datesdisabled) date.expect_daysofweekdisabled(daysofweekdisabled) @@ -48,8 +46,7 @@ def test_input_date_kitchen(page: Page, app: ShinyAppProc) -> None: page.goto(app.url) date1 = controller.InputDate(page, "date1") - - expect(date1.loc_label).to_have_text("Date:") + date1.expect_label("Has default date:") expect_date(date1, "2016-02-29") diff --git a/tests/playwright/shiny/inputs/test_input_date_range.py b/tests/playwright/shiny/inputs/test_input_date_range.py index 42dbd90c4..ed9d5bac6 100644 --- a/tests/playwright/shiny/inputs/test_input_date_range.py +++ b/tests/playwright/shiny/inputs/test_input_date_range.py @@ -5,7 +5,7 @@ from typing import Literal from conftest import create_doc_example_core_fixture -from playwright.sync_api import Page, expect +from playwright.sync_api import Page from shiny.playwright import controller from shiny.run import ShinyAppProc @@ -18,7 +18,6 @@ def expect_date_range( start_value: str | Literal["today"] = "today", end_value: str | Literal["today"] = "today", *, - label: str = "Date range:", autoclose: bool = True, format: str = "yyyy-mm-dd", language: str = "en", @@ -32,7 +31,6 @@ def expect_date_range( start_value = str(datetime.date.today()) if start_value == "today" else start_value end_value = str(datetime.date.today()) if end_value == "today" else end_value date.expect_value((start_value, end_value)) - date.expect_label(label) autoclose_str = "true" if autoclose else "false" date.expect_autoclose(autoclose_str) date.expect_format(format) @@ -51,14 +49,17 @@ def test_input_date_kitchen(page: Page, app: ShinyAppProc) -> None: daterange1 = controller.InputDateRange(page, "daterange1") daterange1.expect_label("Date range:") - expect(daterange1.loc_label).to_have_text("Date range:") - - expect_date_range(daterange1, "2001-01-01", "2010-12-31") - - daterange1.set(("2012-02-02", "2012-11-15")) - expect_date_range(daterange1, "2012-02-02", "2012-11-15") + today = str(datetime.date.today().strftime("%Y-%m-%d")) + tommorow = str( + (datetime.date.today() + datetime.timedelta(days=1)).strftime("%Y-%m-%d") + ) + daterange1.set((today, today)) + expect_date_range(daterange1, today, today) + daterange1.set((today, tommorow)) - expect_date_range(controller.InputDateRange(page, "daterange2")) + expect_date_range( + controller.InputDateRange(page, "daterange2"), "2001-01-01", "2010-12-31" + ) expect_date_range( controller.InputDateRange(page, "daterange3"), From 9945a10dbcaf488f6dde3e280c9d5490296cae2e Mon Sep 17 00:00:00 2001 From: Barret Schloerke Date: Tue, 24 Sep 2024 14:08:19 -0400 Subject: [PATCH 6/7] Apply suggestions from code review --- shiny/api-examples/input_date/app-core.py | 2 +- shiny/api-examples/input_date/app-express.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/shiny/api-examples/input_date/app-core.py b/shiny/api-examples/input_date/app-core.py index 457ff304c..44b3189a0 100644 --- a/shiny/api-examples/input_date/app-core.py +++ b/shiny/api-examples/input_date/app-core.py @@ -5,7 +5,7 @@ app_ui = ui.page_fluid( ui.input_date("date1", "Has default date:", value="2016-02-29"), # Default value is the date in client's time zone - ui.input_date("date2", "Client's timezone:"), + ui.input_date("date2", "Client's current date:"), # value is always yyyy-mm-dd, even if the display format is different ui.input_date("date3", "Format mm/dd/yy:", value="2016-02-29", format="mm/dd/yy"), # Pass in a Date object diff --git a/shiny/api-examples/input_date/app-express.py b/shiny/api-examples/input_date/app-express.py index 7af693db7..23f2def73 100644 --- a/shiny/api-examples/input_date/app-express.py +++ b/shiny/api-examples/input_date/app-express.py @@ -4,7 +4,7 @@ ui.input_date("date1", "Has default date:", value="2016-02-29") # Default value is the date in client's time zone -ui.input_date("date2", "Client's timezone:") +ui.input_date("date2", "Client's current date:") # value is always yyyy-mm-dd, even if the display format is different ui.input_date("date3", "Format mm/dd/yy:", value="2016-02-29", format="mm/dd/yy") # Pass in a Date object From ff00c46d7eccf083aedf7f1d2511c78bbae57a2f Mon Sep 17 00:00:00 2001 From: Barret Schloerke Date: Tue, 24 Sep 2024 14:09:20 -0400 Subject: [PATCH 7/7] Update CHANGELOG.md --- CHANGELOG.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 62782cffe..6e29a5bd3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -35,9 +35,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 * `ui.Theme()` now works correctly on Windows when the theme requires Sass compilation. (thanks @yuuuxt, #1684) -* Fixed the `InputSlider` controller's `.expect_width()` to check the `width` property within the `style` attribute. (#1691) +* Fixed the `InputSlider` playwright controller's `.expect_width()` to check the `width` property within the `style` attribute. (#1691) -* Fixed the `InputDate` and `InputDateRange` controllers to check the `width` property within the `style` attribute. (#1696) +* Fixed the `InputDate` and `InputDateRange` playwright controllers to check the `width` property within the `style` attribute. (#1696) ## [1.1.0] - 2024-09-03