diff --git a/inst/examples/autocomplete/app.R b/inst/examples/autocomplete/app.R new file mode 100644 index 00000000..8494ab34 --- /dev/null +++ b/inst/examples/autocomplete/app.R @@ -0,0 +1,38 @@ +library(shiny) +library(shinyMobile) + +app <- shinyApp( + ui = f7Page( + title = "My app", + f7SingleLayout( + navbar = f7Navbar(title = "Update autocomplete"), + f7Block(f7Button(inputId = "update", label = "Update autocomplete")), + f7Block( + f7AutoComplete( + inputId = "myautocomplete", + placeholder = "Some text here!", + openIn = "dropdown", + label = "Type a fruit name", + choices = c( + "Apple", "Apricot", "Avocado", "Banana", "Melon", + "Orange", "Peach", "Pear", "Pineapple" + ) + ), + verbatimTextOutput("autocompleteval") + ) + ) + ), + server = function(input, output, session) { + output$autocompleteval <- renderText(input$myautocomplete) + + observeEvent(input$update, { + updateF7AutoComplete( + inputId = "myautocomplete", + value = "plip", + choices = c("plip", "plap", "ploup") + ) + }) + } +) + +if (interactive() || identical(Sys.getenv("TESTTHAT"), "true")) app diff --git a/tests/testthat/_snaps/mac-4.3/f7ActionSheet/actionsheet-app-004_.new.png b/tests/testthat/_snaps/mac-4.3/f7ActionSheet/actionsheet-app-004_.new.png index a2eb8fb7..244d0546 100644 Binary files a/tests/testthat/_snaps/mac-4.3/f7ActionSheet/actionsheet-app-004_.new.png and b/tests/testthat/_snaps/mac-4.3/f7ActionSheet/actionsheet-app-004_.new.png differ diff --git a/tests/testthat/_snaps/mac-4.3/f7ActionSheet/actionsheet-app-005_.new.png b/tests/testthat/_snaps/mac-4.3/f7ActionSheet/actionsheet-app-005_.new.png new file mode 100644 index 00000000..972e775a Binary files /dev/null and b/tests/testthat/_snaps/mac-4.3/f7ActionSheet/actionsheet-app-005_.new.png differ diff --git a/tests/testthat/_snaps/mac-4.3/f7AutoComplete/autocomplete-app-001.json b/tests/testthat/_snaps/mac-4.3/f7AutoComplete/autocomplete-app-001.json new file mode 100644 index 00000000..1f913b7f --- /dev/null +++ b/tests/testthat/_snaps/mac-4.3/f7AutoComplete/autocomplete-app-001.json @@ -0,0 +1,5 @@ +{ + "input": { + "myautocomplete": "Apple" + } +} diff --git a/tests/testthat/_snaps/mac-4.3/f7AutoComplete/autocomplete-app-001_.png b/tests/testthat/_snaps/mac-4.3/f7AutoComplete/autocomplete-app-001_.png new file mode 100644 index 00000000..1b374de9 Binary files /dev/null and b/tests/testthat/_snaps/mac-4.3/f7AutoComplete/autocomplete-app-001_.png differ diff --git a/tests/testthat/_snaps/mac-4.3/f7AutoComplete/autocomplete-app-002.json b/tests/testthat/_snaps/mac-4.3/f7AutoComplete/autocomplete-app-002.json new file mode 100644 index 00000000..76104972 --- /dev/null +++ b/tests/testthat/_snaps/mac-4.3/f7AutoComplete/autocomplete-app-002.json @@ -0,0 +1,5 @@ +{ + "input": { + "myautocomplete": "plip" + } +} diff --git a/tests/testthat/_snaps/mac-4.3/f7AutoComplete/autocomplete-app-002_.png b/tests/testthat/_snaps/mac-4.3/f7AutoComplete/autocomplete-app-002_.png new file mode 100644 index 00000000..a37c4822 Binary files /dev/null and b/tests/testthat/_snaps/mac-4.3/f7AutoComplete/autocomplete-app-002_.png differ diff --git a/tests/testthat/test-f7ActionSheet.R b/tests/testthat/test-f7ActionSheet.R index c7e4b739..0e6ef547 100644 --- a/tests/testthat/test-f7ActionSheet.R +++ b/tests/testthat/test-f7ActionSheet.R @@ -51,20 +51,20 @@ test_that("actionSheet work as expected", { app$expect_values(input = c("sheet1-action1", "sheet1-action1_button")) app$click(selector = "#sheet1-go") - app$wait_for_idle(2000) + app$wait_for_idle(3000) app$expect_values(input = c("sheet1-action1")) app$click(selector = ".actions-button:first-child") - app$wait_for_idle(2000) + app$wait_for_idle(3000) app$expect_values(input = c("sheet1-action1", "sheet1-action1_button")) app$click(selector = "#sheet1-go") - app$wait_for_idle(2000) + app$wait_for_idle(3000) app$click(selector = ".actions-button:nth-child(2)") app$expect_values(input = c("sheet1-action1", "sheet1-action1_button")) app$click(selector = "#sheet1-update") app$click(selector = "#sheet1-go") - app$wait_for_idle(2000) + app$wait_for_idle(3000) app$expect_values(input = c("sheet1-action1", "sheet1-action1_button")) }) diff --git a/tests/testthat/test-f7AutoComplete.R b/tests/testthat/test-f7AutoComplete.R new file mode 100644 index 00000000..7af84d41 --- /dev/null +++ b/tests/testthat/test-f7AutoComplete.R @@ -0,0 +1,16 @@ +test_that("autocomplete works", { + # Don't run these tests on the CRAN build servers + skip_on_cran() + shiny_app_path <- + system.file("examples/autocomplete/app.R", package = "shinyMobile") + app <- AppDriver$new( + shiny_app_path, + name = "autocomplete-app", + variant = platform_variant() + ) + app$expect_values(input = "myautocomplete") + app$click(selector = "#update") + # Wait for any animation to complete + app$wait_for_idle(1000) + app$expect_values(input = "myautocomplete") +})