Skip to content

Commit b963368

Browse files
committed
Add tests
1 parent c873d89 commit b963368

File tree

11 files changed

+231
-2
lines changed

11 files changed

+231
-2
lines changed

.RData

797 Bytes
Binary file not shown.

.travis.yml

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,27 @@
1+
# dist: trusty # Use Ubuntu 14.04 image (instead of 12.04)
12
language: r
2-
cache: packages
3+
sudo: false
4+
r: 3.4.1
5+
6+
cache:
7+
# Main R library
8+
packages: true
9+
directories:
10+
# PhantomJS
11+
- travis_phantomjs
12+
13+
# Install PhantomJS (if not cached)
14+
before_install:
15+
- "export PHANTOMJS_VERSION=2.1.1"
16+
- "phantomjs --version"
17+
- "export PATH=$PWD/travis_phantomjs/phantomjs-$PHANTOMJS_VERSION-linux-x86_64/bin:$PATH"
18+
- "hash -r"
19+
- "phantomjs --version"
20+
- "if [ $(phantomjs --version) != $PHANTOMJS_VERSION ]; then rm -rf $PWD/travis_phantomjs; mkdir -p $PWD/travis_phantomjs; fi"
21+
- "if [ $(phantomjs --version) != $PHANTOMJS_VERSION ]; then wget https://github.com/Medium/phantomjs/releases/download/v$PHANTOMJS_VERSION/phantomjs-$PHANTOMJS_VERSION-linux-x86_64.tar.bz2 -O $PWD/travis_phantomjs/phantomjs-$PHANTOMJS_VERSION-linux-x86_64.tar.bz2; fi"
22+
- "if [ $(phantomjs --version) != $PHANTOMJS_VERSION ]; then tar -xvf $PWD/travis_phantomjs/phantomjs-$PHANTOMJS_VERSION-linux-x86_64.tar.bz2 -C $PWD/travis_phantomjs; fi"
23+
- "if [ $(phantomjs --version) != $PHANTOMJS_VERSION ]; then hash -r; fi"
24+
- "phantomjs --version"
25+
26+
script:
27+
- R -f run_tests.R

DESCRIPTION

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ Description: A 'Shiny' web application for energy industry analytics.
66
identify changes in the industry over time, and discover new relationships in the data.
77
URL: https://github.com/paulgovan/eanalytics
88
BugReports: https://github.com/paulgovan/eanalytics/issues
9-
Authors@R: person("Paul", "Govan", email = "pgovan1@aggienetwork.com", role = c("aut", "cre"))
9+
Authors@R: person("Paul", "Govan", email = "pgovan1@aggienetwork.com", role = c("aut", "cre"), comment = c(ORCID = "0000-0002-1821-8492"))
1010
Depends:
1111
R (>= 2.10.0),
1212
License: Apache License
@@ -20,6 +20,7 @@ Imports:
2020
plotly (>= 4.5.2),
2121
shiny,
2222
shinydashboard,
23+
shinytest,
2324
shinyWidgets
2425
RoxygenNote: 6.0.1
2526
Suggests: knitr,

R/eAnalytics.R

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
#' @importFrom shinydashboard dashboardPage dashboardHeader dropdownMenu
1717
#' messageItem dashboardSidebar sidebarMenu menuItem menuSubItem dashboardBody
1818
#' tabItems tabItem box tabBox
19+
#' @import shinytest
1920
#' @importFrom shinyWidgets dropdownButton tooltipOptions
2021
#' @export
2122
#' @seealso \url{http://paulgovan.github.io/eAnalytics/}

inst/app/dependencies.r

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,3 +7,4 @@ require(leaflet)
77
require(plotly)
88
require(shiny)
99
require(shinydashboard)
10+
require(shinytest)
Lines changed: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
1+
{
2+
"input": {
3+
"drop287577521": 0,
4+
"drop408976922": 0,
5+
"drop45556500": 0,
6+
"drop528105489": 0,
7+
"drop788305136": 0,
8+
"drop883017405": 0,
9+
"drop892419045": 0,
10+
"drop940467285": 0,
11+
"elec": "Revenue",
12+
"gas": "cost",
13+
"gasRates": "Revenue",
14+
"hydroCol": "status",
15+
"hydroSize": "Total",
16+
"lngColor": "type",
17+
"lngSize": "Total",
18+
"oil": "Revenue",
19+
"perform": "costMile",
20+
"sensitivity": "varr",
21+
"sidebarCollapsed": false,
22+
"sidebarItemExpanded": null,
23+
"storageColor": "type",
24+
"storageSize": "Total"
25+
},
26+
"output": {
27+
"companyBox": {
28+
"html": "<div class=\"col-sm-4\">\n <div class=\"small-box bg-purple\">\n <div class=\"inner\">\n <h3>1098<\/h3>\n <p>Company Profiles<\/p>\n <\/div>\n <div class=\"icon-large\">\n <i class=\"fa fa-users\"><\/i>\n <\/div>\n <\/div>\n<\/div>",
29+
"deps": [
30+
{
31+
"name": "font-awesome",
32+
"version": "4.7.0",
33+
"src": {
34+
"href": "shared/font-awesome"
35+
},
36+
"meta": null,
37+
"script": null,
38+
"stylesheet": "css/font-awesome.min.css",
39+
"head": null,
40+
"attachment": null,
41+
"package": null,
42+
"all_files": true
43+
}
44+
]
45+
},
46+
"facilityBox": {
47+
"html": "<div class=\"col-sm-4\">\n <div class=\"small-box bg-yellow\">\n <div class=\"inner\">\n <h3>1264<\/h3>\n <p>Facility Profiles<\/p>\n <\/div>\n <div class=\"icon-large\">\n <i class=\"fa fa-building\"><\/i>\n <\/div>\n <\/div>\n<\/div>",
48+
"deps": [
49+
{
50+
"name": "font-awesome",
51+
"version": "4.7.0",
52+
"src": {
53+
"href": "shared/font-awesome"
54+
},
55+
"meta": null,
56+
"script": null,
57+
"stylesheet": "css/font-awesome.min.css",
58+
"head": null,
59+
"attachment": null,
60+
"package": null,
61+
"all_files": true
62+
}
63+
]
64+
},
65+
"projectBox": {
66+
"html": "<div class=\"col-sm-4\">\n <div class=\"small-box bg-green\">\n <div class=\"inner\">\n <h3>940<\/h3>\n <p>Projects in Database<\/p>\n <\/div>\n <div class=\"icon-large\">\n <i class=\"fa fa-database\"><\/i>\n <\/div>\n <\/div>\n<\/div>",
67+
"deps": [
68+
{
69+
"name": "font-awesome",
70+
"version": "4.7.0",
71+
"src": {
72+
"href": "shared/font-awesome"
73+
},
74+
"meta": null,
75+
"script": null,
76+
"stylesheet": "css/font-awesome.min.css",
77+
"head": null,
78+
"attachment": null,
79+
"package": null,
80+
"all_files": true
81+
}
82+
]
83+
}
84+
},
85+
"export": {
86+
87+
}
88+
}
101 KB
Loading

inst/app/tests/mytest.R

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
app <- ShinyDriver$new("../", seed = 123, loadTimeout = 1e+05)
2+
app$snapshotInit("mytest")
3+
4+
Sys.sleep(2)
5+
app$setInputs(sidebarItemExpanded = "Electric")
6+
Sys.sleep(2)
7+
app$setInputs(sidebarItemExpanded = "Hydropower")
8+
# Input 'map1_groups' was set, but doesn't have an input binding.
9+
# Input 'hydroTable_rows_current' was set, but doesn't have an input binding.
10+
# Input 'hydroTable_rows_all' was set, but doesn't have an input binding.
11+
Sys.sleep(2)
12+
app$setInputs(sidebarItemExpanded = "NaturalGas")
13+
# Input 'map2_groups' was set, but doesn't have an input binding.
14+
# Input 'map3_groups' was set, but doesn't have an input binding.
15+
# Input 'pipelineTable_rows_current' was set, but doesn't have an input binding.
16+
# Input 'pipelineTable_rows_all' was set, but doesn't have an input binding.
17+
Sys.sleep(2)
18+
app$setInputs(sidebarItemExpanded = "Oil")
19+
app$snapshot()
Lines changed: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
1+
{
2+
"input": {
3+
"drop287577521": 0,
4+
"drop408976922": 0,
5+
"drop45556500": 0,
6+
"drop528105489": 0,
7+
"drop788305136": 0,
8+
"drop883017405": 0,
9+
"drop892419045": 0,
10+
"drop940467285": 0,
11+
"elec": "Revenue",
12+
"gas": "cost",
13+
"gasRates": "Revenue",
14+
"hydroCol": "status",
15+
"hydroSize": "Total",
16+
"lngColor": "type",
17+
"lngSize": "Total",
18+
"oil": "Revenue",
19+
"perform": "costMile",
20+
"sensitivity": "varr",
21+
"sidebarCollapsed": false,
22+
"sidebarItemExpanded": null,
23+
"storageColor": "type",
24+
"storageSize": "Total"
25+
},
26+
"output": {
27+
"companyBox": {
28+
"html": "<div class=\"col-sm-4\">\n <div class=\"small-box bg-purple\">\n <div class=\"inner\">\n <h3>1098<\/h3>\n <p>Company Profiles<\/p>\n <\/div>\n <div class=\"icon-large\">\n <i class=\"fa fa-users\"><\/i>\n <\/div>\n <\/div>\n<\/div>",
29+
"deps": [
30+
{
31+
"name": "font-awesome",
32+
"version": "4.7.0",
33+
"src": {
34+
"href": "shared/font-awesome"
35+
},
36+
"meta": null,
37+
"script": null,
38+
"stylesheet": "css/font-awesome.min.css",
39+
"head": null,
40+
"attachment": null,
41+
"package": null,
42+
"all_files": true
43+
}
44+
]
45+
},
46+
"facilityBox": {
47+
"html": "<div class=\"col-sm-4\">\n <div class=\"small-box bg-yellow\">\n <div class=\"inner\">\n <h3>1264<\/h3>\n <p>Facility Profiles<\/p>\n <\/div>\n <div class=\"icon-large\">\n <i class=\"fa fa-building\"><\/i>\n <\/div>\n <\/div>\n<\/div>",
48+
"deps": [
49+
{
50+
"name": "font-awesome",
51+
"version": "4.7.0",
52+
"src": {
53+
"href": "shared/font-awesome"
54+
},
55+
"meta": null,
56+
"script": null,
57+
"stylesheet": "css/font-awesome.min.css",
58+
"head": null,
59+
"attachment": null,
60+
"package": null,
61+
"all_files": true
62+
}
63+
]
64+
},
65+
"projectBox": {
66+
"html": "<div class=\"col-sm-4\">\n <div class=\"small-box bg-green\">\n <div class=\"inner\">\n <h3>940<\/h3>\n <p>Projects in Database<\/p>\n <\/div>\n <div class=\"icon-large\">\n <i class=\"fa fa-database\"><\/i>\n <\/div>\n <\/div>\n<\/div>",
67+
"deps": [
68+
{
69+
"name": "font-awesome",
70+
"version": "4.7.0",
71+
"src": {
72+
"href": "shared/font-awesome"
73+
},
74+
"meta": null,
75+
"script": null,
76+
"stylesheet": "css/font-awesome.min.css",
77+
"head": null,
78+
"attachment": null,
79+
"package": null,
80+
"all_files": true
81+
}
82+
]
83+
}
84+
},
85+
"export": {
86+
87+
}
88+
}
97 KB
Loading

run_tests.R

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
library(testthat)
2+
library(shinytest)
3+
4+
testthat::test_that("Application works", {
5+
shinytest::expect_pass(shinytest::testApp("inst/app", "mytest", quiet = TRUE, compareImages = FALSE))
6+
})

0 commit comments

Comments
 (0)