source: trunk/test/webtest/gscf/CreateStudyWebTests.groovy @ 1805

Last change on this file since 1805 was 1805, checked in by work@…, 9 years ago
  • fixed webtests?
  • Property svn:keywords set to Rev Author Date
File size: 5.7 KB
Line 
1package gscf
2
3import org.dbnp.gdt.*
4
5class CreateStudyWebTests extends grails.util.WebTest {
6
7        // Unlike unit tests, functional tests are sometimes sequence dependent.
8        // Methods starting with 'test' will be run automatically in alphabetical order.
9        // If you require a specific sequence, prefix the method name (following 'test') with a sequence
10        // e.g. test001XclassNameXListNewDelete
11
12        void testCreateStudy() {
13                // reset Identity to be able to predict identifiers
14                Identity.resetIdentifier()
15
16                // make sure Canoo waits for AJAX calls
17                config(easyajax: true)
18
19                invoke "http://localhost:8080/gscf/?nostats=true"
20                clickLink(description: "Click link: Log In | Register", htmlId: "open")
21                setInputField(name: "j_username", value: "user")
22                setInputField(description: "Set password field j_password: useR123!", name: "j_password", value: "useR123!")
23                clickButton "Login"
24                clickLink "Studies"
25
26                clickLink "Create a new study"
27                setSelectField(name: "template", text: "Academic study")
28                setInputField(name: "title", value: "Test create study")
29                setInputField(name: "description", value: "Test study from CreateStudyWebTests.testCreateStudy()")
30                setInputField(name: "code", value: "TESTCREATE")
31                setInputField(name: "startdate", value: "01/01/2011")
32                clickButton "Add Contact"
33                verifyListPage(0)    // <- internal method call for extracting common steps
34                setSelectField(name: "contacts_person", text: "Scientist, John")
35                setSelectField(name: "contacts_role", text: "Principal Investigator")
36                clickButton "Add"
37                clickButton "next »"
38
39                // Add 10 human subjects
40                setSelectField(name: "species", text: "Homo sapiens")
41                setSelectField(name: "template", text: "Human")
42                setInputField(name: "addNumber", value: "10")
43                clickButton "Add"
44
45                /* Stub code for testing of the template editor
46                           setSelectField(name: "template", text: "add / modify..")
47                           clickLink "Create new field"
48                           setInputField(name: "name", value: "Second Species")
49                           setSelectField(name: "type", text: "ONTOLOGYTERM")
50                           setSelectField(name: "ontologies", text: "NCBI organismal classification")
51                           clickButton "Save"
52                           clickButton "Close"
53                           setSelectField(name: "subject_793_second_species", text: "add more...")
54                           setInputField(name: "term", value: "rat")
55                           clickLink "Rattus norvegicus (Synonym) from: Rattus norvegicus"
56                           clickButton "Add term"
57                           clickButton "Close"   */
58                clickButton "next »"
59
60                // Add some events, sampling events, and groups
61                setSelectField(name: "eventTemplate", text: "Compound challenge")
62                setSelectField(name: "compound", text: "glucose")
63                clickButton "Add"
64                clickButton "add a new eventgroup"
65                setCheckbox(name: "event_13_group_11") // 51_49
66                setCheckbox(name: "event_13_group_14") // 51_52
67                setRadioButton(description: "Check radio button eventType: sample", name: "eventType", value: "sample")
68                setSelectField(name: "sampleTemplate", text: "Blood extraction")
69                setSelectField(name: "sampletemplate", text: "Human blood sample")
70                clickButton "Add"
71                setSelectField(name: "sampleTemplate", text: "Blood extraction")
72                setSelectField(name: "sampletemplate", text: "Human blood sample")
73                setInputField(name: "starttime", value: "1w")
74                clickButton "Add"
75                setCheckbox(name: "event_16_group_11") // 54_49
76                setCheckbox(name: "event_17_group_14") // 55_52
77                setRadioButton(description: "Check radio button eventType: event", name: "eventType", value: "event")
78                setSelectField(name: "eventTemplate", text: "Compound challenge")
79                setSelectField(name: "compound", text: "glucose")
80                clickButton "Add"
81                setCheckbox(name: "event_18_group_11")  // 56_49
82                setCheckbox(name: "event_18_group_14")  // 56_52
83
84                /* stub to test ontology term widget
85                           setSelectField(name: "event_20_compound", text: "add more...")
86                           setInputField(name: "term", value: "glu")
87                           clickLink "L-glutamic acid (Synonym) from: L-glutamic acid"
88                           clickButton "Add term"
89                           clickButton "Close"
90                           setSelectField(name: "event_1648_compound", text: "L-glutamic acid")
91                           */
92                clickButton "next »"
93
94                // assign subjects to event groups
95                setCheckbox(name: "subject_1_group_11") // 39_49
96                setCheckbox(name: "subject_2_group_11") // 40_49
97                setCheckbox(name: "subject_3_group_11") // 41_49
98                setCheckbox(name: "subject_4_group_14") // 42_52
99                setCheckbox(name: "subject_5_group_14") // 43_52
100                setCheckbox(name: "subject_6_group_14") // 44_52
101                clickButton "next »"
102
103                // accept the generated samples, check if the right names are in place
104                /* For some reason enabling this causes the whole webtest to blow. TODO: find out why...
105           verifyInputField(name: "sample_21_name", value="Subject1_BloodExtraction_Group1_0s")
106           verifyInputField(name: "sample_22_name", value="Subject2_BloodExtraction_Group1_0s")
107           verifyInputField(name: "sample_23_name", value="Subject3_BloodExtraction_Group1_0s")
108           verifyInputField(name: "sample_24_name", value="Subject4_BloodExtraction_Group2_1w")
109           verifyInputField(name: "sample_25_name", value="Subject5_BloodExtraction_Group2_1w")
110           verifyInputField(name: "sample_26_name", value="Subject6_BloodExtraction_Group2_1w")
111
112                   and this doesnt work apparently inside textfields: verifyText(text: "Subject1_BloodExtraction_Group1_0s")
113
114                */
115                clickButton "next »"
116
117
118                setSelectField(name: "template", text: "Clinical chemistry assay")
119                setInputField(name: "name", value: "test assay")
120                clickButton "Add"
121                clickButton "next »"
122
123                setCheckbox(name: "sample_22_assay_25") // 60_63
124                clickButton "next »"
125                clickButton "next »"
126
127                // and we should be done, without exceptions
128                // verifyText(text:'Done')
129                // does not seem to work, also see --> http://grails.1312388.n4.nabble.com/webtest-verifyText-doesn-t-see-AJAX-update-with-easyAjax-td2225674.html
130
131                // and view the study
132                clickLink "view the study"
133        }
134
135}
Note: See TracBrowser for help on using the repository browser.