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

Last change on this file since 1590 was 1590, checked in by work@…, 9 years ago
  • fixing remaining test issues
  • Property svn:keywords set to Rev Author Date
File size: 5.4 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 "next »"
33
34                // Add 10 human subjects
35                setSelectField(name: "species", text: "Homo sapiens")
36                setSelectField(name: "template", text: "Human")
37                setInputField(name: "addNumber", value: "10")
38                clickButton "Add"
39
40                /* Stub code for testing of the template editor
41                           setSelectField(name: "template", text: "add / modify..")
42                           clickLink "Create new field"
43                           setInputField(name: "name", value: "Second Species")
44                           setSelectField(name: "type", text: "ONTOLOGYTERM")
45                           setSelectField(name: "ontologies", text: "NCBI organismal classification")
46                           clickButton "Save"
47                           clickButton "Close"
48                           setSelectField(name: "subject_793_second_species", text: "add more...")
49                           setInputField(name: "term", value: "rat")
50                           clickLink "Rattus norvegicus (Synonym) from: Rattus norvegicus"
51                           clickButton "Add term"
52                           clickButton "Close"   */
53                clickButton "next »"
54
55                // Add some events, sampling events, and groups
56                setSelectField(name: "eventTemplate", text: "Compound challenge")
57                setSelectField(name: "compound", text: "glucose")
58                clickButton "Add"
59                clickButton "add a new eventgroup"
60                setCheckbox(name: "event_13_group_11") // 51_49
61                setCheckbox(name: "event_13_group_14") // 51_52
62                setRadioButton(description: "Check radio button eventType: sample", name: "eventType", value: "sample")
63                setSelectField(name: "sampleTemplate", text: "Blood extraction")
64                setSelectField(name: "sampletemplate", text: "Human blood sample")
65                clickButton "Add"
66                setSelectField(name: "sampleTemplate", text: "Blood extraction")
67                setSelectField(name: "sampletemplate", text: "Human blood sample")
68                setInputField(name: "starttime", value: "1w")
69                clickButton "Add"
70                setCheckbox(name: "event_16_group_11") // 54_49
71                setCheckbox(name: "event_17_group_14") // 55_52
72                setRadioButton(description: "Check radio button eventType: event", name: "eventType", value: "event")
73                setSelectField(name: "eventTemplate", text: "Compound challenge")
74                setSelectField(name: "compound", text: "glucose")
75                clickButton "Add"
76                setCheckbox(name: "event_18_group_11")  // 56_49
77                setCheckbox(name: "event_18_group_14")  // 56_52
78
79                /* stub to test ontology term widget
80                           setSelectField(name: "event_20_compound", text: "add more...")
81                           setInputField(name: "term", value: "glu")
82                           clickLink "L-glutamic acid (Synonym) from: L-glutamic acid"
83                           clickButton "Add term"
84                           clickButton "Close"
85                           setSelectField(name: "event_1648_compound", text: "L-glutamic acid")
86                           */
87                clickButton "next »"
88
89                // assign subjects to event groups
90                setCheckbox(name: "subject_1_group_11") // 39_49
91                setCheckbox(name: "subject_2_group_11") // 40_49
92                setCheckbox(name: "subject_3_group_11") // 41_49
93                setCheckbox(name: "subject_4_group_14") // 42_52
94                setCheckbox(name: "subject_5_group_14") // 43_52
95                setCheckbox(name: "subject_6_group_14") // 44_52
96                clickButton "next »"
97
98                // accept the generated samples, check if the right names are in place
99                /* For some reason enabling this causes the whole webtest to blow. TODO: find out why...
100           verifyInputField(name: "sample_21_name", value="Subject1_BloodExtraction_Group1_0s")
101           verifyInputField(name: "sample_22_name", value="Subject2_BloodExtraction_Group1_0s")
102           verifyInputField(name: "sample_23_name", value="Subject3_BloodExtraction_Group1_0s")
103           verifyInputField(name: "sample_24_name", value="Subject4_BloodExtraction_Group2_1w")
104           verifyInputField(name: "sample_25_name", value="Subject5_BloodExtraction_Group2_1w")
105           verifyInputField(name: "sample_26_name", value="Subject6_BloodExtraction_Group2_1w")
106
107                   and this doesnt work apparently inside textfields: verifyText(text: "Subject1_BloodExtraction_Group1_0s")
108
109                */
110                clickButton "next »"
111
112
113                setSelectField(name: "template", text: "Clinical chemistry assay")
114                setInputField(name: "name", value: "test assay")
115                clickButton "Add"
116                clickButton "next »"
117
118                setCheckbox(name: "sample_22_assay_25") // 60_63
119                clickButton "next »"
120                clickButton "next »"
121
122                // and we should be done, without exceptions
123                // verifyText(text:'Done')
124                // does not seem to work, also see --> http://grails.1312388.n4.nabble.com/webtest-verifyText-doesn-t-see-AJAX-update-with-easyAjax-td2225674.html
125
126                // and view the study
127                clickLink "view the study"
128        }
129
130}
Note: See TracBrowser for help on using the repository browser.