-
Notifications
You must be signed in to change notification settings - Fork 2
/
test-modules-gsea.R
154 lines (118 loc) · 5.8 KB
/
test-modules-gsea.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
if (!exists("context_of")) source("initialize.R")
pageURL <- paste0(site_url, "/GeneSetEnrichmentAnalysis/Studies/SDY269/begin.view")
context_of(
file = "test-modules-gsea.R",
what = "Gene Set Enrichment Analysis",
url = pageURL
)
test_connection(remDr, pageURL, "Gene Set Enrichment Analysis: /Studies/SDY269")
test_module("'Gene Set Enrichment Analysis'")
test_tabs(c("Input", "View", "About", "Help"))
test_that("parameters are present", {
sleep_for(3)
tab_bwrap <- remDr$findElements(using = "class", value = "x-tab-panel-bwrap")
expect_equal(length(tab_bwrap), 1)
form_items <- tab_bwrap[[1]]$findChildElements(using = "class", value = "x-form-item")
expect_equal(length(form_items), 2)
# cohort
cohort_input <- form_items[[1]]$findChildElements(using = "id", value = "cbCohort")
expect_equal(length(cohort_input), 1)
cohort_arrow <- form_items[[1]]$findChildElements(using = "class", value = "x-form-arrow-trigger")
expect_equal(length(cohort_arrow), 1)
cohort_arrow[[1]]$clickElement()
sleep_for(1)
combo_lists <- remDr$findElements(using = "class", value = "x-combo-list-inner")
expect_equal(
combo_lists[[1]]$getElementText()[[1]],
"LAIV group 2008_PBMC (SDY269)\nTIV Group 2008_PBMC (SDY269)"
)
cohort_clear <- form_items[[1]]$findChildElements(using = "class", value = "x-form-clear-trigger")
expect_equal(length(cohort_clear), 1)
cohort_clear[[1]]$clickElement()
sleep_for(1)
# modules
modules_input <- form_items[[2]]$findChildElements(using = "id", value = "cbModules")
expect_equal(length(modules_input), 1)
modules_arrow <- form_items[[2]]$findChildElements(using = "class", value = "x-form-arrow-trigger")
expect_equal(length(modules_arrow), 1)
modules_arrow[[1]]$clickElement()
sleep_for(1)
combo_lists <- remDr$findElements(using = "class", value = "x-combo-list-inner")
expect_equal(
combo_lists[[2]]$getElementText()[[1]],
"Blood transcription\nMSigDB c7\nG2 (Trial 8) Modules"
)
modules_clear <- form_items[[2]]$findChildElements(using = "class", value = "x-form-clear-trigger")
expect_equal(length(modules_clear), 1)
modules_clear[[1]]$clickElement()
sleep_for(1)
# buttons
buttons <- remDr$findElements(using = "class", value = "x-btn-text")
expect_equal(length(buttons), 2)
expect_equal(buttons[[1]]$getElementText()[[1]], "Run")
expect_equal(buttons[[2]]$getElementText()[[1]], "Reset")
})
test_that("selecting cohort is working", {
tab_bwrap <- remDr$findElements(using = "class", value = "x-tab-panel-bwrap")
form_items <- tab_bwrap[[1]]$findChildElements(using = "class", value = "x-form-item")
combo_lists <- remDr$findElements(using = "class", value = "x-combo-list-inner")
cohort_arrow <- form_items[[1]]$findChildElements(using = "class", value = "x-form-arrow-trigger")
cohort_arrow[[1]]$clickElement()
sleep_for(1)
chorot_TIV <- combo_lists[[1]]$findChildElements(using = "class", value = "x-combo-list-item")
chorot_TIV[[2]]$clickElement()
sleep_for(1)
cohort_input <- form_items[[1]]$findChildElements(using = "id", value = "cbCohort")
expect_equal(
cohort_input[[1]]$getElementAttribute("value")[[1]],
"TIV Group 2008_PBMC (SDY269)"
)
})
test_that("selecting modules is working", {
tab_bwrap <- remDr$findElements(using = "class", value = "x-tab-panel-bwrap")
form_items <- tab_bwrap[[1]]$findChildElements(using = "class", value = "x-form-item")
combo_lists <- remDr$findElements(using = "class", value = "x-combo-list-inner")
module_arrow <- form_items[[2]]$findChildElements(using = "class", value = "x-form-arrow-trigger")
module_arrow[[1]]$clickElement()
sleep_for(1)
module_MSigDB_c7 <- combo_lists[[2]]$findChildElements(using = "class", value = "x-combo-list-item")
module_MSigDB_c7[[2]]$clickElement()
sleep_for(1)
module_input <- form_items[[2]]$findChildElements(using = "id", value = "cbModules")
expect_equal(module_input[[1]]$getElementAttribute("value")[[1]], "MSigDB c7")
})
test_that("run button is working", {
buttons <- remDr$findElements(using = "class", value = "x-btn-text")
buttons[[1]]$clickElement()
sleep_for(1)
# check if output is there by waiting on mask msg to disappear
while (length(remDr$findElements(using = "class", value = "ext-el-mask-msg")) != 0) sleep_for(1)
active_tab <- remDr$findElements(using = "class", value = "x-tab-strip-active")
expect_equal(active_tab[[1]]$getElementText()[[1]], "View")
})
test_that("report is present", {
labkey_knitr <- remDr$findElements(using = "class", value = "labkey-knitr")
expect_equal(length(labkey_knitr), 1)
report_header <- labkey_knitr[[1]]$findChildElements(using = "id", value = "gene-set-enrichment-analysis-of-tiv-group-2008_pbmc")
expect_equal(length(report_header), 1)
widget_data <- labkey_knitr[[1]]$findChildElements(using = "css selector", value = "script[data-for]")
expect_equal(length(widget_data), 2)
dataTable <- labkey_knitr[[1]]$findChildElements(using = "class", value = "dataTables_wrapper")
expect_equal(length(dataTable), 1)
plot_svg <- labkey_knitr[[1]]$findChildElements(using = "class", value = "plot-container")
expect_equal(length(plot_svg), 1)
})
test_that("reset button 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]")
tabs[[1]]$clickElement()
sleep_for(1)
buttons <- remDr$findElements(using = "class", value = "x-btn-text")
buttons[[2]]$clickElement()
sleep_for(1)
# check if parameters are clear
cohort_input <- remDr$findElements(using = "id", value = "cbCohort")
expect_equal(cohort_input[[1]]$getElementAttribute("value")[[1]], "Select...")
module_input <- remDr$findElements(using = "id", value = "cbModules")
expect_equal(module_input[[1]]$getElementAttribute("value")[[1]], "Blood transcription")
})