Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bslib::sidebar() tests #153

Merged
merged 12 commits into from
Jun 2, 2023
7 changes: 4 additions & 3 deletions R/data-apps-deps.R
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
# This file is automatically generated by `./inst/gha/data-apps-deps-update.R`
apps_deps <- c("base64enc", "BH", "Cairo", "clipr", "curl", "DBI", "dbplyr",
"DiagrammeR", "dplyr", "evaluate", "future", "ggplot2", "ggvis",
"hexbin", "highcharter", "jsonlite", "knitr", "magrittr", "maps",
"markdown", "memoise", "networkD3", "plogr", "png", "progress",
"hexbin", "highcharter", "jsonlite", "knitr", "lorem", "magrittr",
"maps", "markdown", "memoise", "networkD3", "plogr", "png", "progress",
"pryr", "radiant", "ragg", "RColorBrewer", "reactable", "reactR",
"reshape2", "rlang", "rmarkdown", "rprojroot", "rsconnect", "RSQLite",
"rversions", "scales", "sf", "shinyAce", "shinydashboard", "shinyjs",
Expand Down Expand Up @@ -58,7 +58,8 @@ apps_deps_map <- list(`001-hello` = "rsconnect", `012-datatables` = "ggplot2",
"reshape2", "rversions", "sf", "withr"), `302-bootswatch-themes` = c("ggplot2",
"progress", "rversions", "sf", "withr"), `304-bslib-card` = c("rlang",
"rversions"), `305-bslib-value-box` = c("rlang", "rversions"
), `306-accordion-add-remove` = "magrittr", `309-flexdashboard-tabs-navs` = "rmarkdown",
), `306-accordion-add-remove` = "magrittr", `308-sidebar-kitchen-sink` = c("lorem",
"rversions", "testthat"), `309-flexdashboard-tabs-navs` = "rmarkdown",
`310-bslib-sidebar-dynamic` = c("rversions", "testthat"),
`311-bslib-sidebar-toggle-methods` = c("rversions", "testthat"
), `313-bslib-card-tab-focus` = c("rversions", "testthat",
Expand Down
101 changes: 101 additions & 0 deletions inst/apps/308-sidebar-kitchen-sink/app.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
library(shiny)
library(bslib)
library(crosstalk)
library(plotly)

plotly_bars <- plot_ly(x = LETTERS[1:3], y = 1:3) %>%
add_bars()

sidebar_long <- sidebar(lorem::ipsum(3, 3))
sidebar_short <- sidebar(
p("A simple sidebar"),
actionButton("foo", "This button does nothing")
)

ui <- page_navbar(
title = "Sidebar kitchen sink",
fillable = c("Fill", "Fill+Scroll", "Global card sidebar"),
id = "navbar",
sidebar = sidebar(
open = FALSE,
position = "right",
id = "global_sidebar",
bg = "#1E1E1E",
shiny::markdown(
"Learn more about `bslib::sidebar()` [here](https://rstudio.github.io/bslib/articles/sidebars.html)"
)
),
header = tagList(
tags$style(HTML(".plotly .modebar-container { display: none; }")),
span("header", class = "bg-dark"),
span("content", class = "bg-dark")
),
footer = tagList(
span("footer", class = "bg-dark"),
span("content", class = "bg-dark")
),
nav_panel(
"Fill",
plotly_bars,
layout_sidebar(plotly_bars, sidebar = sidebar_short),
card(
card_header("Depth"),
layout_sidebar(plotly_bars, sidebar = sidebar_short)
)
),
nav_panel(
"Fill+Scroll",
plotly_bars,
card(
card_header("Depth"),
layout_sidebar(plotly_bars, sidebar = sidebar_long)
),
layout_sidebar(plotly_bars, sidebar = sidebar_long)
),
nav_panel(
"Scroll",
plotly_bars,
card(
card_header("Depth"),
layout_sidebar(plotly_bars, sidebar = sidebar_long)
),
layout_sidebar(plotly_bars, sidebar = sidebar_long)
),
nav_panel(
"Global card sidebar",
# Wrapping this up with layout_column_wrap() should keep
# the row height the same (even when switch tabs)
layout_columns(
col_widths = 12,
navs_tab_card(
title = "Global sidebar",
id = "card_tab_sidebar",
sidebar = sidebar_long,
full_screen = TRUE,
nav("Tab 1", plotly_bars, plotly_bars),
nav("Tab 2", plotly_bars)
),
navs_pill_card(
title = "Global sidebar",
id = "card_pill_sidebar",
sidebar = sidebar_long,
full_screen = TRUE,
nav("Pill 1", plotly_bars, plotly_bars),
nav("Pill 2", plotly_bars)
)
)
),
nav_spacer(),
nav_item(actionButton("toggle_sidebar", "Learn more"))
)


server <- function(input, output) {

observeEvent(input$toggle_sidebar, {
sidebar_toggle("global_sidebar")
})

}

shinyApp(ui, server)
1 change: 1 addition & 0 deletions inst/apps/308-sidebar-kitchen-sink/tests/testthat.R
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
shinytest2::test_app()
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# Load application support files into testing environment
shinytest2::load_app_env()
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
library(shinytest2)

# Only take screenshots on mac + r-release to reduce diff noise
release <- rversions::r_release()$version
release <- paste0(
strsplit(release, ".", fixed = TRUE)[[1]][1:2],
collapse = "."
)

is_testing_on_ci <- identical(Sys.getenv("CI"), "true") && testthat::is_testing()
is_mac_release <- identical(paste0("mac-", release), platform_variant())

DO_SCREENSHOT <- is_testing_on_ci && is_mac_release

test_that("{shinytest2} recording: 308-sidebar-kitchen-sink", {
height <- 1200
width <- 1600

app <- AppDriver$new(
variant = platform_variant(),
name = "308-sidebar-kitchen-sink",
view = interactive(),
height = height,
width = width
)

expect_screenshot <- function() {
if (DO_SCREENSHOT) app$expect_screenshot()
}

expect_screenshot()

app$set_inputs(navbar = "Fill+Scroll")
expect_screenshot()

# Contents should render to their natural height on mobile
app$set_window_size(width = 500, height = 1000)
expect_screenshot()
app$set_window_size(width = width, height = height)

app$set_inputs(navbar = "Scroll")
expect_screenshot()

app$set_inputs(navbar = "Global card sidebar")
app$set_inputs(card_tab_sidebar = "Tab 2")
Sys.sleep(1) # Wait for the tab to receive focus
expect_screenshot()

app$click("toggle_sidebar")
Sys.sleep(1) # Wait for transition to complete
expect_screenshot()
})
43 changes: 12 additions & 31 deletions inst/apps/sysinfo-linux-3.6.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
── Session info ────────────────────────────────────────────────────────────────
setting value
gha_image 20230507.1
gha_image 20230517.1
version R version 3.6.3 (2020-02-29)
os Ubuntu 20.04.6 LTS
system x86_64, linux-gnu
Expand All @@ -9,7 +9,7 @@
collate C.UTF-8
ctype C.UTF-8
tz UTC
date 2023-05-26
date 2023-06-02
pandoc 2.7.3 @ /usr/bin/pandoc
── Packages ────────────────────────────────────────────────────────────────────
package * version date (UTC) lib source
Expand All @@ -19,7 +19,6 @@
assertthat 0.2.1 2019-03-21 [1] RSPM
backports 1.4.1 2021-12-13 [1] RSPM
base64enc 0.1-3 2015-07-28 [1] RSPM
BH 1.81.0-1 2023-01-22 [1] RSPM
bigD 0.2.0 2022-09-05 [1] RSPM
bit 4.0.5 2022-11-15 [1] RSPM
bit64 4.0.5 2020-08-30 [1] RSPM
Expand All @@ -29,7 +28,7 @@
brio 1.1.3 2021-11-30 [1] RSPM
broom 1.0.4 2023-03-11 [1] RSPM
bsicons 0.1 2023-05-24 [1] Github (rstudio/bsicons@1a12bb6)
bslib 0.4.2.9000 2023-05-26 [1] Github (rstudio/bslib@d7eaa48)
bslib 0.4.2.9000 2023-06-02 [1] Github (rstudio/bslib@c277c4e)
cachem 1.0.8 2023-05-24 [1] Github (r-lib/cachem@62051fe)
Cairo 1.6-0 2022-07-05 [1] RSPM
callr 3.7.3 2022-11-02 [1] RSPM
Expand Down Expand Up @@ -57,10 +56,8 @@
dendextend 1.17.1 2023-03-25 [1] RSPM
desc 1.4.2 2022-09-08 [1] RSPM
deSolve 1.35 2023-03-12 [1] RSPM
DiagrammeR 1.0.10 2023-05-18 [1] RSPM
diffobj 0.3.5 2021-10-05 [1] RSPM
digest 0.6.31 2022-12-11 [1] RSPM
downloader 0.4 2015-07-09 [1] RSPM
dplyr 1.1.2 2023-04-20 [1] RSPM
DT 0.28.1 2023-05-24 [1] Github (rstudio/DT@6a82b6d)
dygraphs 1.1.1.7 2023-05-24 [1] Github (rstudio/dygraphs@b096395)
Expand All @@ -85,13 +82,12 @@
ggiraph 0.8.7 2023-03-17 [1] RSPM
ggplot2 3.4.2 2023-04-03 [1] RSPM
ggthemes 4.2.4 2021-01-20 [1] RSPM
ggvis 0.4.8 2023-03-08 [1] RSPM
gh 1.4.0 2023-02-22 [1] RSPM
gitcreds 0.1.2 2022-09-08 [1] RSPM
globals 0.16.2 2022-11-21 [1] RSPM
glue 1.6.2 2022-02-24 [1] RSPM
gridExtra 2.3 2017-09-09 [1] RSPM
gt 0.9.0.9000 2023-05-26 [1] Github (rstudio/gt@71d2a13)
gt 0.9.0.9000 2023-06-02 [1] Github (rstudio/gt@777a4cd)
gtable 0.3.3 2023-03-21 [1] RSPM
here 1.0.1 2020-12-13 [1] RSPM
hexbin 1.28.3 2023-03-21 [1] RSPM
Expand All @@ -103,15 +99,14 @@
httr 1.4.6 2023-05-08 [1] RSPM
httr2 0.2.3 2023-05-08 [1] RSPM
hunspell 3.0.2 2022-09-04 [1] RSPM
igraph 1.4.3 2023-05-22 [1] RSPM
ini 0.3.1 2018-05-20 [1] RSPM
IRdisplay 1.1 2022-01-04 [1] RSPM
isoband 0.2.7 2022-12-20 [1] RSPM
jquerylib 0.1.4 2021-04-26 [1] RSPM
jsonlite 1.8.4 2022-12-06 [1] RSPM
juicyjuice 0.1.0 2022-11-10 [1] RSPM
KernSmooth 2.23-16 2019-10-15 [3] CRAN (R 3.6.3)
knitr 1.42 2023-01-25 [1] RSPM
knitr 1.43 2023-05-25 [1] RSPM
labeling 0.4.2 2020-10-20 [1] RSPM
later 1.3.1 2023-05-24 [1] Github (r-lib/later@bc088f8)
lattice 0.20-38 2018-11-04 [3] CRAN (R 3.6.3)
Expand All @@ -121,34 +116,31 @@
lifecycle 1.0.3 2022-10-07 [1] RSPM
listenv 0.9.0 2022-12-16 [1] RSPM
listviewer 3.0.0 2019-11-02 [1] RSPM
lobstr 1.1.2 2022-06-22 [1] RSPM
lorem 1.0.0 2023-03-09 [1] RSPM
lubridate 1.9.2 2023-02-10 [1] RSPM
magrittr 2.0.3 2022-03-30 [1] RSPM
maps 3.4.1 2022-10-30 [1] RSPM
maptools 1.1-6 2022-12-14 [1] RSPM
maptools 1.1-7 2023-05-29 [1] RSPM
markdown 1.7 2023-05-16 [1] RSPM
MASS 7.3-51.5 2019-12-20 [3] CRAN (R 3.6.3)
Matrix 1.2-18 2019-11-27 [3] CRAN (R 3.6.3)
memoise 2.0.1 2021-11-26 [1] RSPM
mgcv 1.8-31 2019-11-09 [3] CRAN (R 3.6.3)
mime 0.12 2021-09-28 [1] RSPM
munsell 0.5.0 2018-06-12 [1] RSPM
networkD3 0.4 2017-03-18 [1] RSPM
nlme 3.1-144 2020-02-06 [3] CRAN (R 3.6.3)
NLP 0.2-1 2020-10-14 [1] RSPM
nnet 7.3-12 2016-02-02 [3] CRAN (R 3.6.3)
openssl 2.0.6 2023-03-09 [1] RSPM
packrat 0.9.1 2023-02-27 [1] RSPM
pak 0.5.1 2023-04-29 [2] local
paletteer 1.5.0 2022-10-19 [1] RSPM
palmerpenguins 0.1.1 2022-08-15 [1] RSPM
parallelly 1.35.0 2023-03-23 [1] RSPM
parallelly 1.36.0 2023-05-26 [1] RSPM
parsedate 1.3.1 2022-10-27 [1] RSPM
pillar 1.9.0 2023-03-22 [1] RSPM
pingr 2.0.2 2022-10-26 [1] RSPM
pkgconfig 2.0.3 2019-09-22 [1] RSPM
pkgload 1.3.2 2022-11-16 [1] RSPM
plogr 0.2.0 2018-03-25 [1] RSPM
plotly 4.10.1.9000 2023-05-24 [1] Github (ropensci/plotly@3e6099e)
plotlyGeoAssets 0.0.2 2019-01-08 [1] RSPM
plyr 1.8.8 2022-11-11 [1] RSPM
Expand All @@ -161,7 +153,6 @@
progress 1.2.2 2019-05-16 [1] RSPM
promises 1.2.0.9000 2023-05-24 [1] Github (rstudio/promises@dd2b792)
proxy 0.4-27 2022-06-09 [1] RSPM
pryr 0.1.6 2023-01-17 [1] RSPM
ps 1.7.5 2023-04-18 [1] RSPM
purrr 1.0.1 2023-01-10 [1] RSPM
R.cache 0.16.0 2022-07-21 [1] RSPM
Expand All @@ -178,20 +169,18 @@
reactable 0.4.4 2023-03-12 [1] RSPM
reactlog 1.1.1 2023-05-24 [1] Github (rstudio/reactlog@83a4958)
reactR 0.4.4 2021-02-22 [1] RSPM
readr 2.1.4 2023-02-10 [1] RSPM
rematch 1.0.1 2016-04-21 [1] RSPM
rematch2 2.1.2 2020-05-01 [1] RSPM
renv 0.17.3 2023-04-06 [1] RSPM
repr 1.1.6 2023-01-26 [1] RSPM
reshape 0.8.9 2022-04-12 [1] RSPM
reshape2 1.4.4 2020-04-09 [1] RSPM
reticulate 1.28 2023-01-27 [1] RSPM
rex 1.2.1 2021-11-26 [1] RSPM
rgeos 0.6-3 2023-05-24 [1] RSPM
rjson 0.2.20 2018-06-08 [1] url
RJSONIO 1.3-1.8 2023-01-31 [1] RSPM
rlang 1.1.1 2023-04-28 [1] RSPM
rmarkdown 2.21 2023-03-26 [1] RSPM
rmarkdown 2.22 2023-06-01 [1] RSPM
RMySQL 0.10.25 2022-12-06 [1] RSPM
rpart 4.1-15 2019-04-12 [3] CRAN (R 3.6.3)
rprojroot 2.0.3 2022-04-02 [1] RSPM
Expand All @@ -208,11 +197,9 @@
servr 0.27 2023-05-02 [1] RSPM
sessioninfo 1.2.2 2021-12-06 [1] RSPM
sf 1.0-13 2023-05-24 [1] RSPM
shiny 1.7.4.9002 2023-05-24 [1] Github (rstudio/shiny@5805895)
shiny 1.7.4.9002 2023-06-02 [1] Github (rstudio/shiny@e7b8307)
shinyAce 0.4.2 2022-05-06 [1] RSPM
shinycoreci 0.0.0.9008 2023-05-26 [1] local
shinydashboard 0.7.2 2021-09-30 [1] RSPM
shinyjs 2.1.0 2021-12-23 [1] RSPM
shinycoreci 0.0.0.9008 2023-06-02 [1] local
shinyjster 0.0.0.9010 2023-05-24 [1] Github (schloerke/shinyjster@1807304)
shinymeta 0.2.0.3 2023-05-24 [1] Github (rstudio/shinymeta@5af8086)
shinytest 1.5.3 2023-05-24 [1] Github (rstudio/shinytest@22322f4)
Expand All @@ -223,9 +210,8 @@
showimage 1.0.0 2018-01-24 [1] RSPM
showtext 0.9-6 2023-05-03 [1] RSPM
showtextdb 3.0 2020-06-04 [1] RSPM
slam 0.1-50 2022-01-08 [1] RSPM
sourcetools 0.1.7-1 2023-02-01 [1] RSPM
sp 1.6-0 2023-01-19 [1] RSPM
sp 1.6-1 2023-05-31 [1] RSPM
spatial 7.3-11 2015-08-30 [3] CRAN (R 3.6.3)
spelling 2.2.1 2023-03-22 [1] RSPM
stringi 1.7.12 2023-01-11 [1] RSPM
Expand All @@ -246,9 +232,7 @@
tidyselect 1.2.0 2022-10-10 [1] RSPM
timechange 0.2.0 2023-01-11 [1] RSPM
tinytex 0.45 2023-04-18 [1] RSPM
tm 0.7-11 2023-02-05 [1] RSPM
tweenr 2.0.2 2022-09-06 [1] RSPM
tzdb 0.4.0 2023-05-12 [1] RSPM
units 0.8-2 2023-04-27 [1] RSPM
usethis 2.1.6 2022-05-25 [1] RSPM
utf8 1.2.3 2023-01-31 [1] RSPM
Expand All @@ -259,8 +243,6 @@
vembedr 0.1.5 2021-12-11 [1] RSPM
viridis 0.6.3 2023-05-03 [1] RSPM
viridisLite 0.4.2 2023-05-02 [1] RSPM
visNetwork 2.1.2 2022-09-29 [1] RSPM
vroom 1.6.3 2023-04-28 [1] RSPM
waldo 0.5.1 2023-05-08 [1] RSPM
webdriver 1.0.6.9001 2023-05-24 [1] Github (rstudio/webdriver@35d3805)
webshot 0.5.4 2022-09-26 [1] RSPM
Expand All @@ -269,7 +251,6 @@
whisker 0.4.1 2022-12-05 [1] RSPM
withr 2.5.0 2022-03-03 [1] RSPM
wk 0.7.3 2023-05-06 [1] RSPM
wordcloud 2.6 2018-08-24 [1] RSPM
xfun 0.39 2023-04-20 [1] RSPM
xml2 1.3.4 2023-04-27 [1] RSPM
xtable 1.8-4 2019-04-21 [1] RSPM
Expand Down
Loading