-
Notifications
You must be signed in to change notification settings - Fork 2
/
test-modules-gee.R
206 lines (157 loc) · 7.98 KB
/
test-modules-gee.R
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
if (!exists("context_of")) source("initialize.R")
# test functions ----
test_gee <- function(applyFilter = FALSE) {
pageURL <- paste0(site_url, "/GeneExpressionExplorer/Studies/SDY269/begin.view")
context_of(
file = "test-modules-gee.R",
what = paste0("Gene Expression Explorer (applyFilter = ", applyFilter, ")"),
url = pageURL
)
test_connection(remDr, pageURL, "Gene Expression Explorer: /Studies/SDY269")
test_module("'Gene Expression Explorer'")
test_tabs(c("Input / View", "Data", "About", "Help"))
test_that("parameters are present and working", {
sleep_for(3)
# parameters
parameters <- remDr$findElements(using = "class", value = "ui-test-parameters")
expect_equal(length(parameters), 1)
formItems <- parameters[[1]]$findChildElements(using = "class", value = "x-form-item")
expect_equal(length(formItems), 5)
# parameters: response
response_input <- formItems[[1]]$findChildElements(using = "class", value = "ui-test-response")
expect_equal(length(response_input), 1)
response_arrow <- formItems[[1]]$findChildElements(using = "class", value = "x-form-arrow-trigger")
expect_equal(length(response_arrow), 1)
response_arrow[[1]]$clickElement()
sleep_for(1)
response_list <- remDr$findElements(using = "css selector", value = "div.x-combo-list[style*='visibility: visible']")
expect_equal(response_list[[1]]$getElementText()[[1]], "HAI")
response_clear <- formItems[[1]]$findChildElements(using = "class", value = "x-form-clear-trigger")
expect_equal(length(response_clear), 1)
# parameters: time point
timePoint_input <- formItems[[2]]$findChildElements(using = "class", value = "ui-test-timepoint")
expect_equal(length(timePoint_input), 1)
timePoint_arrow <- formItems[[2]]$findChildElements(using = "class", value = "x-form-arrow-trigger")
expect_equal(length(timePoint_arrow), 1)
timePoint_arrow[[1]]$clickElement()
sleep_for(1)
timePoint_list <- remDr$findElements(using = "css selector", value = "div.x-combo-list[style*='visibility: visible']")
expect_equal(
timePoint_list[[1]]$getElementText()[[1]],
"0 days (2 cohorts)\n3 days (2 cohorts)\n7 days (2 cohorts)"
)
timePoint_items <- timePoint_list[[1]]$findChildElements(using = "class", value = "x-combo-list-item")
timePoint_items[[2]]$clickElement()
sleep_for(1)
timePoint_clear <- formItems[[2]]$findChildElements(using = "class", value = "x-form-clear-trigger")
expect_equal(length(timePoint_clear), 1)
# parameters: cohorts
cohorts_input <- formItems[[3]]$findChildElements(using = "class", value = "ui-test-cohorts")
expect_equal(length(cohorts_input), 1)
cohorts_arrow <- formItems[[3]]$findChildElements(using = "class", value = "x-form-arrow-trigger")
expect_equal(length(cohorts_arrow), 1)
cohorts_list <- remDr$findElements(using = "css selector", value = "div.x-combo-list[style*='visibility: visible']")
expect_equal(
cohorts_list[[1]]$getElementText()[[1]],
"Select all\nLAIV group 2008_PBMC (SDY269)\nTIV Group 2008_PBMC (SDY269)"
)
cohorts_items <- cohorts_list[[1]]$findChildElements(using = "class", value = "x-combo-list-item")
cohorts_items[[2]]$clickElement()
sleep_for(1)
cohorts_clear <- formItems[[3]]$findChildElements(using = "class", value = "x-form-clear-trigger")
expect_equal(length(cohorts_clear), 1)
cohorts_arrow[[1]]$clickElement()
sleep_for(1)
# parameters: normalize
normalize <- formItems[[4]]$findChildElements(using = "class", value = "ui-test-normalize")
expect_equal(length(normalize), 1)
# parameters: genes
genes_input <- formItems[[5]]$findChildElements(using = "class", value = "ui-test-genes")
expect_equal(length(genes_input), 1)
genes_input[[1]]$clickElement()
sleep_for(1)
genes_list <- remDr$findElements(using = "css selector", value = "div.x-combo-list[style*='visibility: visible']")
expect_equal(length(genes_input), 1)
genes_items <- genes_list[[1]]$findChildElements(using = "class", value = "x-combo-list-item")
genes_items[[1]]$clickElement()
sleep_for(1)
# addiational options
additionalOptions <- remDr$findElements(using = "class", value = "ui-test-additional-options")
expect_equal(length(additionalOptions), 1)
additionalOptions_header <- additionalOptions[[1]]$findChildElements(using = "class", value = "x-fieldset-header")
additionalOptions_header[[1]]$clickElement()
sleep_for(1)
interactivePlot <- additionalOptions[[1]]$findChildElements(using = "class", value = "ui-test-interactive")
expect_equal(length(interactivePlot), 1)
textSize <- additionalOptions[[1]]$findChildElements(using = "class", value = "ui-test-textsize")
expect_equal(length(textSize), 1)
facet_grid <- additionalOptions[[1]]$findChildElements(using = "class", value = "ui-test-facet-grid")
expect_equal(length(facet_grid), 1)
facet_wrap <- additionalOptions[[1]]$findChildElements(using = "class", value = "ui-test-facet-wrap")
expect_equal(length(facet_wrap), 1)
color <- additionalOptions[[1]]$findChildElements(using = "class", value = "ui-test-color")
expect_equal(length(color), 1)
shape <- additionalOptions[[1]]$findChildElements(using = "class", value = "ui-test-shape")
expect_equal(length(shape), 1)
size <- additionalOptions[[1]]$findChildElements(using = "class", value = "ui-test-size")
expect_equal(length(size), 1)
alpha <- additionalOptions[[1]]$findChildElements(using = "class", value = "ui-test-alpha")
expect_equal(length(alpha), 1)
additionalOptions_header[[1]]$clickElement()
sleep_for(1)
# buttons
buttons <- remDr$findElements(using = "class", value = "x-btn-noicon")
expect_equal(length(buttons), 2)
plot_button <- buttons[[1]]$findChildElements(using = "class", value = "x-btn-text")
expect_equal(plot_button[[1]]$getElementText()[[1]], "Plot")
reset_button <- buttons[[2]]$findChildElements(using = "class", value = "x-btn-text")
expect_equal(reset_button[[1]]$getElementText()[[1]], "Reset")
})
test_that("loading dataset is working", {
tab_header <- remDr$findElements(using = "class", value = "x-tab-panel-header")
tabs <- tab_header[[1]]$findChildElements(using = "css selector", value = "li[id^=ext-comp]")
# switch to "Data" tab
tabs[[2]]$clickElement()
sleep_for(1)
headers <- remDr$findElements(using = "css selector", value = "[id$=-column-header-row]")
if (headers[[1]]$getElementText()[[1]] != "") {
headers_text <- strsplit(headers[[1]]$getElementText()[[1]], split = " ")[[1]]
headers_text <- strsplit(headers_text[length(headers_text)], split = "\n")[[1]]
} else {
headers_text <- headers[[1]]$getElementText()[[1]]
}
expect_equal(
headers_text,
c(
"Participant ID", "Age Reported", "Gender", "Race",
"Study Time Collected", "Study Time Collected Unit",
"Virus", "Value Preferred"
)
)
if (applyFilter) {
test_filtering()
}
# back to "Input / View" tab
tabs[[1]]$clickElement()
sleep_for(1)
})
test_that("plot and reset buttons are working", {
buttons <- remDr$findElements(using = "class", value = "x-btn-noicon")
plot_button <- buttons[[1]]$findChildElements(using = "class", value = "x-btn-text")
plot_button[[1]]$clickElement()
sleep_for(1)
# check if output is there
while (length(remDr$findElements(using = "class", value = "ext-el-mask-msg")) != 0) sleep_for(1)
visualization <- remDr$findElements(using = "css selector", value = "img[id*=imgModuleHtmlView_]")
expect_equal(length(visualization), 1)
reset_button <- buttons[[2]]$findChildElements(using = "class", value = "x-btn-text")
reset_button[[1]]$clickElement()
sleep_for(1)
# check if plot is clear
no_visualization <- remDr$findElements(using = "css selector", value = "img[id*=imgModuleHtmlView_]")
expect_equal(length(no_visualization), 0)
})
}
# tests ----
test_gee()
test_gee(applyFilter = TRUE)