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

Extensive test for combination of inputs in shinytest2 #1136

Open
3 tasks done
kartikeyakirar opened this issue Apr 25, 2024 · 1 comment
Open
3 tasks done

Extensive test for combination of inputs in shinytest2 #1136

kartikeyakirar opened this issue Apr 25, 2024 · 1 comment
Labels

Comments

@kartikeyakirar
Copy link
Contributor

Feature description

extension to this :#1135

As an additional feature test with helper functions, we could also add tests to check the combination of inputs for all the encodings. This would be an extensive test, but it would thoroughly check the depth of combination input testing. I am adding an issue for this potential use case and discussion.

# Function to test all combinations of inputs
test_input_combinations <- function(app_driver, input_ids, input_options, pws = NULL, tws = NULL) {
  # Create a data frame of all possible combinations of encodings
  combinations <- expand.grid(input_options, stringsAsFactors = FALSE)
  names(combinations) <- input_ids
  
  # Iterate over each row in the combinations data frame
  for (i in seq_len(nrow(combinations))) {
    # Determine the type of output to capture based on the input parameters
    if (!is.null(pws)) {
      output_before <- app_driver$get_active_module_pws_output(pws)
      output_type <- "pws"
    } else if (!is.null(tws)) {
      output_before <- app_driver$get_active_module_tws_output(tws)
      output_type <- "tws"
    } else {
      stop("Either pws or tws must be provided.")
    }
    
    # Set each input and check for errors
    for (j in seq_along(input_ids)) {
      app_driver$set_active_module_input(input_ids[j], combinations[i, j])
      app_driver$expect_no_validation_error()
    }
    

    if (output_type == "pws") {
      testthat::expect_false(identical(output_before, app_driver$get_active_module_pws_output(pws)))
    } else {
      testthat::expect_false(identical(output_before, app_driver$get_active_module_tws_output(tws)))
    }
  }
}

# Example usage
input_ids <- c("input1", "input2", "input3")
input_options <- list(
  c("option1_1", "option1_2"),        # Input 1 has 2 options
  c("option2_1", "option2_2", "option2_3", "option2_4", "option2_5", 
    "option2_6", "option2_7", "option2_8", "option2_9", "option2_10"),  # Input 2 has 10 options
  c("option3_1", "option3_2", "option3_3", "option3_4", "option3_5", "option3_6")  # Input 3 has 6 options
)

# Fun call 
test_input_combinations(app_driver, input_ids, input_options, "example_pws")

Code of Conduct

  • I agree to follow this project's Code of Conduct.

Contribution Guidelines

  • I agree to follow this project's Contribution Guidelines.

Security Policy

  • I agree to follow this project's Security Policy.
@donyunardi
Copy link
Contributor

I would like to postpone this until we have consistent passing daily integration tests. Once that happens, we can start discussing it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants