Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make vector arg to fill-multi/fill-human-multi fill in order #652

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions CHANGELOG.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,13 @@ A release with an intentional breaking changes is marked with:
* Changes
** {issue}559[#559]: Create `query-from` and `query-all-from` as replacements for `child` and `children`. Rewrite logic such that `q` parameter allows for vector syntax similar to `query` and `query-all`. Deprecate `child` and `children`. ({person}dgr[@dgr])
** {issue}559[#559]: Make `get-active-element` a public API. This was previously private. ({person}dgr[@dgr])
** {issue}629[#629]: Added `fill-human-active` as a convenience function that fills the currently active input using `fill-human-el`. ({person}dgr[@dgr])
** {issue}620[#620]: Get stricter when unwrapping elements. ({person}dgr[@dgr])
* Docs
** {issue}559[#559]: Deprecate use of `:active` with `query` and other APIs that use `query` under the hood. ({person}dgr[@dgr])
** {issue}620[#620]: Get stricter when unwrapping elements. ({person}dgr[@dgr])
** {issue}629[#629]: Added `fill-human-active` as a convenience function that fills the currently active input using `fill-human-el`. ({person}dgr[@dgr])
** {issue}642[#642]: Add `driver-type` to retrieve driver type keyword. ({person}dgr[@dgr])
** {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])
dgr marked this conversation as resolved.
Show resolved Hide resolved

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

Expand Down
26 changes: 20 additions & 6 deletions src/etaoin/api.clj
Original file line number Diff line number Diff line change
Expand Up @@ -2745,8 +2745,10 @@
"Have `driver` fill multiple inputs via `q-text`.

`q-text` can be:
- a map of `{q1 \"text1\" q2 \"text2\" ...}`
- a vector of `[q1 \"text1\" q2 \"text2\" ...]`
- a map of `{q1 \"text1\" q2 \"text2\" ...}`. There are no guarantees
about the order in which fields are filled.
- a vector of `[q1 \"text1\" q2 \"text2\" ...]`. The fields are filled
in the order the fields are listed in the vector.

See [[query]] for details on `q`s."
[driver q-text]
Expand All @@ -2756,7 +2758,12 @@
(fill driver q text))

(vector? q-text)
(recur driver (apply hash-map q-text))
(if (even? (count q-text))
(doseq [[q text] (partition 2 q-text)]
(fill driver q text))
(throw+ {:type :etaoin/argument
:message "Vector q-text must have even length"
:arg q-text}))

:else (throw+ {:type :etaoin/argument
:message "Wrong argument type"
Expand Down Expand Up @@ -2811,8 +2818,10 @@
"Have `driver` fill multiple elements as if it were a real human being via `q-text` using `opts`.

`q-text` can be:
- a map of `{q1 \"text1\" q2 \"text2\" ...}`
- a vector of `[q1 \"text1\" q2 \"text2\" ...]`
- a map of `{q1 \"text1\" q2 \"text2\" ...}`. There are no guarantees
about the order in which fields are filled.
- a vector of `[q1 \"text1\" q2 \"text2\" ...]`. The fields are filled
in the order the fields are listed in the vector.

See [[query]] for details on `q`s.

Expand All @@ -2825,7 +2834,12 @@
(fill-human driver q text opts))

(vector? q-text)
(recur driver (apply hash-map q-text) opts)
(if (even? (count q-text))
(doseq [[q text] (partition 2 q-text)]
(fill driver q text))
(throw+ {:type :etaoin/argument
:message "Vector q-text must have even length"
:arg q-text}))

:else (throw+ {:type :etaoin/argument
:message "Wrong argument type"
Expand Down
Loading