Commit 8808557f authored by Stephane Glondu's avatar Stephane Glondu

Add a button to trigger shuffle computation

parent e8236435
Pipeline #85383 passed with stages
in 19 minutes and 9 seconds
......@@ -19,6 +19,7 @@
(* <http://www.gnu.org/licenses/>. *)
(**************************************************************************)
open Js_of_ocaml
open Serializable_j
open Common
open Tool_js_common
......@@ -34,13 +35,18 @@ let shuffle election ciphertexts =
let () =
Lwt.async (fun () ->
let%lwt _ = Lwt_js_events.onload () in
let uuid = List.assoc "uuid" (get_params ()) in
let open Lwt_xmlHttpRequest in
let%lwt election = get ("../elections/" ^ uuid ^ "/election.json") in
let%lwt ciphertexts = get ("../election/nh-ciphertexts?uuid=" ^ uuid) in
let%lwt shuffle = shuffle election.content ciphertexts.content in
set_textarea "shuffle" shuffle;
set_element_display "wait_div" "none";
set_element_display "submit_form" "block";
Lwt.return_unit
match Dom_html.getElementById_coerce "compute_shuffle" Dom_html.CoerceTo.button with
| None -> Lwt.return_unit
| Some btn ->
let%lwt _ = Lwt_js_events.click btn in
set_element_display "controls_div" "none";
set_element_display "wait_div" "block";
let uuid = List.assoc "uuid" (get_params ()) in
let open Lwt_xmlHttpRequest in
let%lwt election = get ("../elections/" ^ uuid ^ "/election.json") in
let%lwt ciphertexts = get ("../election/nh-ciphertexts?uuid=" ^ uuid) in
let%lwt shuffle = shuffle election.content ciphertexts.content in
set_textarea "shuffle" shuffle;
set_element_display "wait_div" "none";
Lwt.return_unit
)
......@@ -2568,12 +2568,15 @@ let shuffle election token =
let title = params.e_name ^ " — Shuffle" in
let content = [
div [pcdata "It is now time to shuffle encrypted ballots."];
div ~a:[a_id "wait_div"] [
div ~a:[a_id "controls_div"] [
button_no_value ~button_type:`Button ~a:[a_id "compute_shuffle"] [pcdata "Compute shuffle"];
];
div ~a:[a_id "wait_div"; a_style "display:none;"] [
pcdata "Please wait... ";
img ~src:(static "encrypting.gif") ~alt:"Loading..." ();
];
post_form ~service:election_shuffle_post
~a:[a_id "submit_form"; a_style "display:none;"]
~a:[a_id "submit_form"]
(fun nshuffle ->
[
div [
......
......@@ -75,6 +75,10 @@ class BeleniosTestElectionScenario1(BeleniosElectionTestBase):
wait_a_bit()
# She clicks on the "Compute shuffle" button
wait_for_element_exists(browser, "#compute_shuffle", settings.EXPLICIT_WAIT_TIMEOUT).click()
wait_a_bit()
# She waits for the "shuffle" textarea to be filled
wait_for_element_exists_and_has_non_empty_attribute(browser, "#shuffle", "value", settings.EXPLICIT_WAIT_TIMEOUT)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment