Skip to content

Commit

Permalink
Enter time input correctly
Browse files Browse the repository at this point in the history
The default text doesn't enter time inputs correct for a few reasons:

* The text input doesn't expected you to type ":", spaces, or the "M" in
  "AM" or "PM". The space specifically seems to mess up inputs.
* You need to key press "Enter" after entering the time, otherwise moving
  focus will erase the current input.

This change filters the time value given to remove ":", " ", and "M",
and also adds an Enter keypress to make sure the value is entered correctly.
  • Loading branch information
BryceStevenWilley committed Jul 14, 2023
1 parent 12dc240 commit bc3f744
Show file tree
Hide file tree
Showing 3 changed files with 49 additions and 0 deletions.
34 changes: 34 additions & 0 deletions docassemble/ALKilnTests/data/questions/test_date_and_time.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
metadata:
title: Test testing library - date and time
short title: Test ALKiln
---
features:
css:
- styles.css
---
# Necessary to tell us what the sought var is on each page
# Every interview that wants testing will need to have an element like this
default screen parts:
post: |
<div data-variable="${ encode_name(str( user_info().variable )) }" id="trigger" aria-hidden="true" style="display: none;"></div>
---
mandatory: True
id: interview order
code: |
date_and_time
end
---
id: date and time
continue button field: date_and_time
question: |
Date and time
fields:
- date field: date_input
datatype: date
- time field: time_input
datatype: time
---
id: the end
event: end
question: |
Congratulations! Tests have passed!
Original file line number Diff line number Diff line change
Expand Up @@ -164,3 +164,11 @@ Scenario: I take a screenshot of the signature
And I sign
And I take a screenshot
Then I tap to continue

@fast @o14 @date @time
Scenario: I enter the date and time
Given I start the interview at "test_date_and_time.yml"
And I get to "the end" with this data:
| date_input | today | |
| time_input | 12:34 PM | |

7 changes: 7 additions & 0 deletions lib/scope.js
Original file line number Diff line number Diff line change
Expand Up @@ -1755,6 +1755,13 @@ module.exports = {
}
await scope.setText( scope, { handle, answer: answer_date });
await scope.afterStep(scope, { waitForShowIf: true });
} else if (type == `time`) {
// Authors should enter the time like 12:34 PM, but we shouldn't type ":", space, or M.
let answer_time = answer.replace(":", "").replace(" ", "").replace("M", "");
await handle.focus();
await handle.type( answer );
await handle.press("Enter");
await scope.afterStep(scope, { waitForShowIf: true });
} else {
await scope.setText( scope, { handle, answer });
await scope.afterStep(scope, { waitForShowIf: true });
Expand Down

0 comments on commit bc3f744

Please sign in to comment.