fix: calendar component specs to avoid duplicate day entries (#21164)
This change attempts to fix the calendar component specs to avoid errors with finding multiple elements with the same text. Prior to this change it was possible for multiple elements to be found with the same number of the day, like "5", which caused the tests helpers to thrown an exception. Now the specs will use a different test helper to avoid the exceptions, and we've adjusted the test data to avoid duplicate day numbers too.
This commit is contained in:
parent
97d4edcf30
commit
5b75e1dca6
|
@ -4,7 +4,7 @@
|
|||
[quo.components.calendar.calendar.view :as calendar]
|
||||
[test-helpers.component :as h]))
|
||||
|
||||
(def start-date (time/date-time (time/year (time/now)) (time/month (time/now)) 5))
|
||||
(def start-date (time/date-time (time/year (time/now)) (time/month (time/now)) 8))
|
||||
(def end-date (time/date-time (time/plus start-date (time/days 2))))
|
||||
|
||||
(h/describe "calendar component"
|
||||
|
@ -23,7 +23,7 @@
|
|||
{:start-date nil
|
||||
:end-date nil
|
||||
:on-change on-change}])
|
||||
(h/fire-event :press (h/query-by-text (str (time/day start-date))))
|
||||
(h/fire-event :press (h/query-first-by-text (str (time/day start-date))))
|
||||
(h/was-called-with on-change {:start-date start-date :end-date nil})))
|
||||
|
||||
(h/test "should call on-change with start and end date on second click"
|
||||
|
@ -31,7 +31,7 @@
|
|||
(h/render
|
||||
[calendar/view
|
||||
{:start-date start-date :end-date nil :on-change on-change}])
|
||||
(h/fire-event :press (h/query-by-text (str (time/day end-date))))
|
||||
(h/fire-event :press (h/query-first-by-text (str (time/day end-date))))
|
||||
(h/was-called-with on-change {:start-date start-date :end-date end-date})))
|
||||
|
||||
(h/test "should reset the dates on third click"
|
||||
|
@ -41,7 +41,7 @@
|
|||
{:start-date start-date
|
||||
:end-date end-date
|
||||
:on-change on-change}])
|
||||
(h/fire-event :press (h/query-by-text (str (time/day start-date))))
|
||||
(h/fire-event :press (h/query-first-by-text (str (time/day start-date))))
|
||||
(h/was-called-with on-change {:start-date start-date :end-date nil})))
|
||||
|
||||
(h/test "should reset dates when start date is clicked again"
|
||||
|
@ -51,7 +51,7 @@
|
|||
{:start-date start-date
|
||||
:end-date nil
|
||||
:on-change on-change}])
|
||||
(h/fire-event :press (h/query-by-text (str (time/day start-date))))
|
||||
(h/fire-event :press (h/query-first-by-text (str (time/day start-date))))
|
||||
(h/was-called-with on-change {:start-date nil :end-date nil})))
|
||||
|
||||
(h/test "should assign start and end date correctly when upper range selected first"
|
||||
|
@ -61,5 +61,5 @@
|
|||
{:start-date end-date
|
||||
:end-date nil
|
||||
:on-change on-change}])
|
||||
(h/fire-event :press (h/query-by-text (str (time/day start-date))))
|
||||
(h/fire-event :press (h/query-first-by-text (str (time/day start-date))))
|
||||
(h/was-called-with on-change {:start-date start-date :end-date end-date}))))
|
||||
|
|
|
@ -101,6 +101,7 @@
|
|||
(def get-by-text (with-node-or-screen :get-by-text))
|
||||
(def query-all-by-text (with-node-or-screen :query-all-by-text))
|
||||
(def query-by-text (with-node-or-screen :query-by-text))
|
||||
(def query-first-by-text (comp first query-all-by-text))
|
||||
|
||||
(def get-all-by-label-text (with-node-or-screen :get-all-by-label-text))
|
||||
(def get-by-label-text (with-node-or-screen :get-by-label-text))
|
||||
|
|
Loading…
Reference in New Issue