Skip to content

Commit

Permalink
Make set-<xyz>-timeout more resilient to non-integer timeout values (
Browse files Browse the repository at this point in the history
…clj-commons#658)

* Make set-<xzy>-timeout routines more robust to non-integer values

* Add tests for non-integer timeouts to set-<xzy>-timeout

* Update CHANGELOG for issue 657
  • Loading branch information
dgr authored Sep 5, 2024
1 parent 0ad57e0 commit 7c9c5cb
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 14 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ A release with an intentional breaking changes is marked with:
** {issue}644[#644]: Deprecate `when-predicate` and `when-not-predicate` macros. See docstrings for guidance on alternatives. These will may be removed from the API at the next release that contains breaking changes. ({person}dgr[@dgr])
** {issue}647[#647]: Fix logic bug in `intersects?`. Added tests to test suite. ({person}dgr[@dgr])
** {issue}649[#649]: When supplied a vector argument for `q-text`, `fill-multi` and `fill-human-multi` now fill fields in the order that fields appear in the vector. Previously, the order was not guaranteed. ({person}dgr[@dgr])
** {issue}657[#657]: Make `set-<xyz>-timeout` functions resilient to reasonable non-integer timeouts (e.g., rationals, doubles, etc.). ({person}dgr[@dgr])

== v1.1.41 [minor breaking] - 2024-08-14 [[v1.1.41]]

Expand Down
2 changes: 1 addition & 1 deletion src/etaoin/impl/util.clj
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
(defmethod ~multifn dispatch-val# ~@fn-tail)))

(defn sec->ms [sec]
(* sec 1000))
(long (* sec 1000)))

(defn ms->sec [ms]
(/ ms 1000))
Expand Down
34 changes: 21 additions & 13 deletions test/etaoin/api_test.clj
Original file line number Diff line number Diff line change
Expand Up @@ -1094,19 +1094,27 @@
{:class :inside} {:tag :span}])))))

(deftest test-timeouts
(let [timeouts {:implicit 32134
:script 78921
:pageLoad 98765}]
(e/set-timeouts *driver* timeouts)
(is (= timeouts (e/get-timeouts *driver*)))
(e/set-page-load-timeout *driver* 987)
(e/set-implicit-timeout *driver* 876)
(e/set-script-timeout *driver* 765)
(is (= 987 (e/get-page-load-timeout *driver*)))
(is (= 876 (e/get-implicit-timeout *driver*)))
(is (= 765 (e/get-script-timeout *driver*)))
(is (= {:pageLoad 987000 :implicit 876000 :script 765000}
(e/get-timeouts *driver*)))))
(testing "basic timeout tests"
(let [timeouts {:implicit 32134
:script 78921
:pageLoad 98765}]
(e/set-timeouts *driver* timeouts)
(is (= timeouts (e/get-timeouts *driver*)))
(e/set-page-load-timeout *driver* 987)
(e/set-implicit-timeout *driver* 876)
(e/set-script-timeout *driver* 765)
(is (= 987 (e/get-page-load-timeout *driver*)))
(is (= 876 (e/get-implicit-timeout *driver*)))
(is (= 765 (e/get-script-timeout *driver*)))
(is (= {:pageLoad 987000 :implicit 876000 :script 765000}
(e/get-timeouts *driver*)))))
(testing "non-integer timeout values"
;; These should not throw. If they do, the test runner will record
;; a test failure.
(is (do (e/set-page-load-timeout *driver* 1.33333)
true))
(is (do (e/set-page-load-timeout *driver* 100/3)
true))))

(comment
;; start test server
Expand Down

0 comments on commit 7c9c5cb

Please sign in to comment.