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

Last change on this file since 1430 was 1430, checked in by work@…, 10 years ago
  • set keyword expansion
  • Property svn:keywords set to Rev Author Date
File size: 5.2 KB
Line 
1package gscf
2
3
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
14                // make sure Canoo waits for AJAX calls
15                config(easyajax: true)
16
17                invoke "http://localhost:8080/gscf/"
18                clickLink(description: "Click link: Log In | Register", htmlId: "open")
19                setInputField(name: "j_username", value: "user")
20                setInputField(description: "Set password field j_password: useR123!", name: "j_password", value: "useR123!")
21                clickButton "Login"
22                clickLink "Studies"
23
24                clickLink "Create a new study"
25                setSelectField(name: "template", text: "Academic study")
26                setInputField(name: "title", value: "Test create study")
27                setInputField(name: "description", value: "Test study from CreateStudyWebTests.testCreateStudy()")
28                setInputField(name: "code", value: "TESTCREATE")
29                setInputField(name: "startdate", value: "01/01/2011")
30                clickButton "next »"
31
32                // Add 10 human subjects
33                setSelectField(name: "species", text: "Homo sapiens")
34                setSelectField(name: "template", text: "Human")
35                setInputField(name: "addNumber", value: "10")
36                clickButton "Add"
37
38                /* Stub code for testing of the template editor
39                           setSelectField(name: "template", text: "add / modify..")
40                           clickLink "Create new field"
41                           setInputField(name: "name", value: "Second Species")
42                           setSelectField(name: "type", text: "ONTOLOGYTERM")
43                           setSelectField(name: "ontologies", text: "NCBI organismal classification")
44                           clickButton "Save"
45                           clickButton "Close"
46                           setSelectField(name: "subject_793_second_species", text: "add more...")
47                           setInputField(name: "term", value: "rat")
48                           clickLink "Rattus norvegicus (Synonym) from: Rattus norvegicus"
49                           clickButton "Add term"
50                           clickButton "Close"   */
51                clickButton "next »"
52
53                // Add some events, sampling events, and groups
54                setSelectField(name: "eventTemplate", text: "Compound challenge")
55                setSelectField(name: "compound", text: "glucose")
56                clickButton "Add"
57                clickButton "add a new eventgroup"
58                setCheckbox(name: "event_15_group_13")
59                setCheckbox(name: "event_15_group_16")
60                setRadioButton(description: "Check radio button eventType: sample", name: "eventType", value: "sample")
61                setSelectField(name: "sampleTemplate", text: "Blood extraction")
62                setSelectField(name: "sampletemplate", text: "Human blood sample")
63                clickButton "Add"
64                setSelectField(name: "sampleTemplate", text: "Blood extraction")
65                setSelectField(name: "sampletemplate", text: "Human blood sample")
66                setInputField(name: "starttime", value: "1w")
67                clickButton "Add"
68                setCheckbox(name: "event_18_group_13")
69                setCheckbox(name: "event_19_group_16")
70                setRadioButton(description: "Check radio button eventType: event", name: "eventType", value: "event")
71                setSelectField(name: "eventTemplate", text: "Compound challenge")
72                setSelectField(name: "compound", text: "glucose")
73                clickButton "Add"
74                setCheckbox(name: "event_20_group_13")
75                setCheckbox(name: "event_20_group_16")
76
77                /* stub to test ontology term widget
78                           setSelectField(name: "event_20_compound", text: "add more...")
79                           setInputField(name: "term", value: "glu")
80                           clickLink "L-glutamic acid (Synonym) from: L-glutamic acid"
81                           clickButton "Add term"
82                           clickButton "Close"
83                           setSelectField(name: "event_1648_compound", text: "L-glutamic acid")
84                           */
85                clickButton "next »"
86
87                // assign subjects to event groups
88                setCheckbox(name: "subject_3_group_13")
89                setCheckbox(name: "subject_4_group_13")
90                setCheckbox(name: "subject_5_group_13")
91                setCheckbox(name: "subject_6_group_16")
92                setCheckbox(name: "subject_7_group_16")
93                setCheckbox(name: "subject_8_group_16")
94                clickButton "next »"
95
96                // accept the generated samples, check if the right names are in place
97                /* For some reason enabling this causes the whole webtest to blow. TODO: find out why...
98           verifyInputField(name: "sample_21_name", value="Subject1_BloodExtraction_Group1_0s")
99           verifyInputField(name: "sample_22_name", value="Subject2_BloodExtraction_Group1_0s")
100           verifyInputField(name: "sample_23_name", value="Subject3_BloodExtraction_Group1_0s")
101           verifyInputField(name: "sample_24_name", value="Subject4_BloodExtraction_Group2_1w")
102           verifyInputField(name: "sample_25_name", value="Subject5_BloodExtraction_Group2_1w")
103           verifyInputField(name: "sample_26_name", value="Subject6_BloodExtraction_Group2_1w")
104
105                   and this doesnt work apparently inside textfields: verifyText(text: "Subject1_BloodExtraction_Group1_0s")
106
107                */
108                clickButton "next »"
109
110
111                setSelectField(name: "template", text: "Clinical chemistry assay")
112                setInputField(name: "name", value: "test assay")
113                clickButton "Add"
114                clickButton "next »"
115
116                setCheckbox(name: "sample_21_assay_27")
117                clickButton "next »"
118                clickButton "next »"
119
120                // and we should be done, without exceptions
121                // verifyText(text:'Done')
122                // does not seem to work, also see --> http://grails.1312388.n4.nabble.com/webtest-verifyText-doesn-t-see-AJAX-update-with-easyAjax-td2225674.html
123
124                // and view the study
125                clickLink "view the study"
126        }
127
128}
Note: See TracBrowser for help on using the repository browser.