namespace eval ::twt::simulation {} ad_proc ::twt::simulation::get_object_short_name { name } { set short_name [string tolower $name] regsub -all {\s} $short_name {-} short_name return $short_name } ad_proc ::twt::simulation::add_image { {-title:required} {-description ""} {-content_file:required} } { Create a new simulation image } { do_request /simulation/object-list link follow ~u object-edit?.*parent # Choose object type image set_object_form_type image foreach input_name {title description content_file} { field fill [set $input_name] ~n $input_name } form submit } ad_proc ::twt::simulation::set_object_form_type { type } { form find ~n object field find ~n content_type field select2 ~v $type field find ~n __refreshing_p field fill 1 form submit } ad_proc ::twt::simulation::add_object { {-type:required} {-title:required} } { Create a new simulation object } { do_request /simulation/object-list link follow ~u object-edit?.*parent set_object_form_type $type field find ~n title field fill $title form submit } ad_proc ::twt::simulation::visit_template_page { template_name } { do_request /simulation/sim-template-list link follow ~u sim-template-edit ~c $template_name } if { [catch { source [file dirname [info script]]/../../../etc/install/tcl/test-procs.tcl # Test Execution START # TODO: Create users with different roles and for different # actions below be logged in with an appropriate user # Demo data start set actors_list { Teacher Student Agent1 Agent2 } array set characters { Bernadette "Bernadette" MOTORHOME "MOTORHOME" "A of Lawfirm X" "Her lawyer" "A of Lawfirm Y" "Its lawyer" "B of Lawfirm X" "Partner firm X" "B of Lawfirm Y" "Partner firm Y" "C of Lawfirm X" "Secretary firm X" "C of Lawfirm Y" "Secretary firm Y" "Portal" "Library" } array set tasks { "Ask information from Bernadette" {assigned_role "Her lawyer" recipient_role "Bernadette"} "Ask information from MOTORHOME" {assigned_role "Her lawyer" recipient_role "MOTORHOME"} "Ask information from opponent's lawyer 1" {assigned_role "Its lawyer" recipient_role "Her lawyer"} "Ask information from opponent's lawyer 2" {assigned_role "Her lawyer" recipient_role "Its lawyer"} "Ask information from library" {assigned_role "Her lawyer" recipient_role "Library"} "Ask information from partner" {assigned_role "Her lawyer" recipient_role "Partner firm X"} "Intervene" {assigned_role "Partner firm X" recipient_role "Her lawyer"} "Reply to intervention" {assigned_role "Her lawyer" recipient_role "Partner firm X"} "Give information as Bernadette" {assigned_role "Bernadette" recipient_role "Her lawyer"} "Give information as Motorhome" {assigned_role "MOTORHOME" recipient_role "Her lawyer"} "Make/edit draft report" {assigned_role "Her lawyer" recipient_role "Her lawyer"} "Edit draft report" {assigned_role "Her lawyer" recipient_role "Her lawyer"} "Give information to opponent's lawyer" {assigned_role "Her lawyer" recipient_role "Its lawyer"} "Send final report" {assigned_role "Her lawyer" recipient_role "Partner firm X"} "Send draft report" {assigned_role "Her lawyer" recipient_role "Partner firm X"} } # Demo data end ::twt::log_section "Login the site wide admin" ::twt::user::login_site_wide_admin ::twt::log_section "Create an image object" do_request /simulation/object-list link follow ~u object-edit?.*parent form find ~n object field find ~n content_type field select2 ~v image field find ~n __refreshing_p field fill 1 form submit field find ~n title field fill "New Jersey Lawyers" field find ~n description field fill "New Jersey Lawyers and Consumers" field find ~n content_file field fill [::twt::config::serverroot]/packages/simulation/test/new-jersey-lawyer-logo.gif form submit ::twt::log_section "Create characters" foreach character_name [array names characters] { ::twt::simulation::add_object -type character -title $character_name } ::twt::log_section "Create simulation template" do_request /simulation/sim-template-edit set template_name "Elementary Private Law" field fill $template_name ~n name form submit ::twt::log_section "Add characters to template" ::twt::simulation::visit_template_page $template_name link follow ~u sim-template-add-objects foreach character_add_url [::twt::get_url_list [response url] sim-template-add-objects-2] { do_request $character_add_url } ::twt::log_section "Create roles for template" ::twt::simulation::visit_template_page $template_name link follow ~u role-edit set add_role_url [response url] foreach character_name [array names characters] { do_request $add_role_url field find ~n character_id field select [::twt::simulation::get_object_short_name $character_name] field find ~n name field fill $characters($character_name) form submit } ::twt::log_section "Add tasks to template" ::twt::simulation::visit_template_page $template_name link follow ~u task-edit set add_task_url [response url] foreach task_name [array names tasks] { array set task $tasks($task_name) do_request $add_task_url field find ~n name field fill $task_name field find ~n assigned_role field select $task(assigned_role) field find ~n recipient_role field select $task(recipient_role) field find ~n description field fill "This is the task description for task $task_name" form submit } } result] } { global errorInfo # Output error stack trace and HTML response body ::twt::log $result ::twt::log "*** Tcl TRACE ***" ::twt::log $errorInfo ::twt::log "The response body is: [response body]" error "Test failed: $result" }