Skip to content

Commit

Permalink
Fix 316 and also make the update_popover() testing more exhaustive
Browse files Browse the repository at this point in the history
  • Loading branch information
cpsievert committed Mar 18, 2024
1 parent 71f027e commit 66e96fd
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 25 deletions.
21 changes: 9 additions & 12 deletions inst/apps/316-bslib-popovers/app.R
Original file line number Diff line number Diff line change
Expand Up @@ -82,15 +82,10 @@ ui <- page_navbar(
plotlyOutput("bars")
),
sidebar = list(
textInput("popover_msg", "Enter a popover message", "Popover message"),
textInput("popover_msg", "Popover message", "Popover message"),
textInput("popover_title", "Popover title", ""),
actionButton("show_popover", "Show popover", class = "mb-3"),
actionButton("hide_popover", "Hide popover"),
br(),
input_switch("show_title", "Add a popover title"),
conditionalPanel(
"input.show_title",
textInput("popover_title", "Enter a title", "Popover title"),
)
actionButton("hide_popover", "Hide popover")
)
)
),
Expand All @@ -112,11 +107,13 @@ ui <- page_navbar(
)

server <- function(input, output, session) {

observe({
update_popover(
"popover", input$popover_msg,
title = if (input$show_title) input$popover_title
)
update_popover("popover", input$popover_msg)
})

observe({
update_popover("popover", title = input$popover_title)
})

observeEvent(input$show_popover, {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -210,31 +210,36 @@ test_that("Can programmatically update/show/hide tooltip", {

app$click("show_popover")
expect_popover_content(app, "Popover message")
app$click("hide_popover")
expect_no_tip(app)

app$set_inputs("popover_msg" = "new")
expect_popover_content(app, "new")
app$click("show_popover")
app$set_inputs("popover_title" = "title 1")
expect_popover_content(app, "Popover message", "title 1")
app$set_inputs("popover_msg" = "msg 1")
expect_popover_content(app, "msg 1", "title 1")

app$click("hide_popover")
expect_no_tip(app)

app$set_inputs("popover_msg" = "newer")

app$set_inputs("popover_title" = "title 2")
app$click("show_popover")
expect_popover_content(app, "newer")
expect_popover_content(app, "msg 1", "title 2")
app$click("hide_popover")
app$click("show_popover")
app$set_inputs("popover_msg" = "msg 2")
expect_popover_content(app, "msg 2", "title 2")
click_close_button(app)
expect_no_tip(app)

app$click("show_popover")
expect_popover_content(app, "msg 2", "title 2")
app$set_inputs("navbar" = "Popover cases")
expect_no_tip(app)
app$set_inputs("navbar" = "Popover updates")

app$set_inputs("show_title" = TRUE)
app$click("show_popover")
expect_popover_content(app, "newer", "Popover title")

app$set_inputs("show_title" = FALSE)
expect_popover_content(app, "newer", "")

click_close_button(app)
expect_no_tip(app)
expect_popover_content(app, "msg 2", "title 2")
})


Expand Down

0 comments on commit 66e96fd

Please sign in to comment.