root/trunk/test/webtest/gscf/CreateStudyWebTests.groovy @ 1806

Revision 1806, 5.6 KB (checked in by work@…, 3 years ago)

- reverted latest change.... seems like webtests + contact ajax is not working properly

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