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

Fix 316 and also make the update_popover() tests more exhaustive #263

Merged
merged 1 commit into from
Mar 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading