6 use Test::More 'tests' => 43;
8 use SGN::Test::Fixture;
9 use SGN::Test::WWW::WebDriver;
11 my $f = SGN::Test::Fixture->new();
12 my $t = SGN::Test::WWW::WebDriver->new();
15 $t->while_logged_in_as("submitter", sub {
18 $t->get_ok('/breeders/crosses');
20 $t->find_element_ok("create_crossingtrial_link", "name", 'find "create crossing trial link" and click')->click();
23 # ADD NEW CROSSING EXPERIMENT
24 # SCREEN 1 - Add New Crossing Experiment Intro/ modal
25 $t->find_element_ok('next_step_add_new_intro', 'id', 'go to next screen in Add New Experiment modal')->click();
27 # SCREEN 2 - Add New Crossing Experiment Information/ modal
28 my $experiment_name = "Selenium_create_cross_trial";
29 $t->find_element_ok('crossingtrial_name', 'id', 'find "crossing trial name" input and give a name')->send_keys($experiment_name);
31 $t->find_element_ok('crossingtrial_program', 'id', 'find "crossing trial program" select input and click')->click();
33 $t->find_element_ok('//select[@id="crossingtrial_program"]/option[text()="test"]', 'xpath', 'select "test" as value for crossing trial program')->click();
35 $t->find_element_ok('crossingtrial_location', 'id', 'find "crossing trial location" select input and click')->click();
37 $t->find_element_ok('//select[@id="crossingtrial_location"]/option[@value="test_location"]', 'xpath', 'select "test_location" as value for crossing trial location')->click();
39 $t->find_element_ok('crosses_add_project_year_select', 'id', 'find "crossing trial year" select input and click')->click();
41 $t->find_element_ok('//select[@id="crosses_add_project_year_select"]/option[@value="2018"]', 'xpath', 'select "2018" as value for crossing trial year')->click();
43 $t->find_element_ok('crosses_add_project_description', 'id', 'find "crossing trial description" input and give a description')->send_keys("Selenium_create_cross_trial_description");
45 $t->find_element_ok('create_crossingtrial_submit', 'id', 'find and click "crossing trial submit" input and give a description')->click();
48 # check if added successfully
49 my $trial_submit_info = $t->find_element_ok(
50 '//div[@id="add_crossing_trial_workflow"]//div[contains(@class, "workflow-complete-message")]',
52 'find feedback info after trial submition')->get_attribute('innerHTML');
54 ok($trial_submit_info =~ /Crossing experiment was added successfully/, "Verify feedback after submission, looking for: 'Crossing experiment was added successfully'");
56 $t->find_element_ok('add_crossing_experiment_dismiss_button_2', 'id', 'find and close "Add New Experiment" modal')->click();
60 $t->find_element_ok("create_cross_link", "name", 'find "create cross link" and click')->click();
64 $t->find_element_ok('next_step_cross_intro', 'id', 'go to next screen in Add New Cross / Intro')->click();
67 # SCREEN 2 - Crossing Experiment
68 $t->find_element_ok('next_step_cross_experiment', 'id', 'go to next screen in Add New Cross modal / Crossing Experiment')->click();
71 # SCREEN 3 - Cross Informatio
72 $t->find_element_ok('add_cross_breeding_program_id', 'id', 'find "cross breeding program" select input and click')->click();
74 $t->find_element_ok('//select[@id="add_cross_breeding_program_id"]/option[@title="test"]', 'xpath', 'select "test" as value for breeding program')->click();
77 $t->find_element_ok('add_cross_crossing_experiment_id', 'id', 'find "crossing trial program" select input and click')->click();
79 $t->find_element_ok("//select[\@id='add_cross_crossing_experiment_id']/option[\@title='$experiment_name']", 'xpath', "select '$experiment_name' as value for crossing experiment")->click();
81 my $cross_unique_name = "selenium_cross_create_123";
82 $t->find_element_ok('cross_name', 'id', 'find "cross name" input and create a name')->send_keys($cross_unique_name);
84 $t->find_element_ok('dialog_cross_combination', 'id', 'find "cross combination name" input and create a name')->send_keys("TMEB419xTMEB693");
86 $t->find_element_ok('cross_type', 'id', 'find "cross type" select input and click')->click();
88 $t->find_element_ok("//select[\@id='cross_type']/option[\@value='biparental']", 'xpath', "select 'biparental' as value for cross type")->click();
90 $t->find_element_ok('next_step_cross_information', 'id', 'go to next screen in Add New Cross modal / Cross Information')->click();
93 # SCREEN 4 - Basic Information
94 $t->find_element_ok('maternal_parent', 'id', 'find "maternal parent" input')->send_keys("TMEB419");
96 $t->find_element_ok('paternal_parent', 'id', 'find "paternal parent" input')->send_keys("TMEB693");
98 $t->find_element_ok('next_step_basic_information', 'id', 'go to next screen in Add New Cross modal / Basic Information')->click();
101 # SCREEN 5 - Additional cross info
102 $t->find_element_ok('create_cross_submit', 'id', 'find "create cross submit" and click')->click();
105 my $cross_submit_info = $t->find_element_ok(
106 '//div[@id="add_cross_workflow"]//div[contains(@class, "panel-body")]//div[contains(@class, "workflow-complete-message")]',
108 'find feedback info after add cross')->get_attribute('innerHTML');
110 ok($cross_submit_info =~ /The cross was added successfully/, "Verify feedback after submission, looking for: 'The cross was added successfully'");
112 $t->find_element_ok('new_cross_close_modal', 'id', 'find "new cross close modal" and click')->click();
115 $t->find_element_ok("refresh_crosses_jstree_html_trialtree_button", "id", "find and click 'refresh crosses trial jstree'")->click();
118 $t->find_element_ok('//div[@id="crosses_list"]//i[contains(@class, "jstree-icon")]', 'xpath', 'open a tree with crosses trial list')->click();
121 my $href_to_trial = $t->find_element_ok("//div[\@id='crosses_list']//a[contains(text(), '$experiment_name')]", 'xpath', 'find created cross and take link href')->get_attribute('href');
123 # check if added successfully
124 $t->get_ok($href_to_trial);
127 my $cross_table_content = $t->find_element_ok('parent_information', 'id', 'find table with parent information')->get_attribute('innerHTML');
129 ok($cross_table_content =~ /TMEB419xTMEB693/, "Verify info in the table: TMEB419xTMEB693");
130 ok($cross_table_content =~ /TMEB419/, "Verify info in the table: TMEB419");
131 ok($cross_table_content =~ /TMEB693/, "Verify info in the table: TMEB693");
132 ok($cross_table_content =~ /biparental/, "Verify info in the table: biparental");
136 $t->driver()->close();