Skip to content

Adds validate_input() -- previously named as "picks"#1642

Open
gogonzo wants to merge 35 commits into
mainfrom
redesign_extraction@main
Open

Adds validate_input() -- previously named as "picks"#1642
gogonzo wants to merge 35 commits into
mainfrom
redesign_extraction@main

Conversation

@gogonzo
Copy link
Copy Markdown
Contributor

@gogonzo gogonzo commented Oct 30, 2025

Closes insightsengineering/NEST-roadmap#36

Check also with:

Introduces validate_input as an alternative to shinyvalidate package. Function is easier to handle than shinyvalidate, as one can use validate_input() in reactive and display-validation-error on the input and throw shiny-validate-error in the same time. See tmg PR to see how it works

@gogonzo gogonzo added the core label Oct 30, 2025
@gogonzo gogonzo changed the title Redesign extraction@main picks Oct 30, 2025
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Oct 30, 2025

badge

Code Coverage Summary

Filename                          Stmts    Miss  Cover    Missing
------------------------------  -------  ------  -------  ---------------------------------------------------------------------------------------
R/after.R                            59      21  64.41%   42-52, 64, 69, 77-79, 81-89, 100, 104-105
R/checkmate.R                        24       0  100.00%
R/decorators-helpers.R               59       1  98.31%   97
R/dummy_functions.R                  61       2  96.72%   54, 56
R/include_css_js.R                   11       0  100.00%
R/init.R                            136       0  100.00%
R/module_bookmark_manager.R          99      54  45.45%   78-133
R/module_data_summary.R             177       8  95.48%   40, 50, 205, 236-240
R/module_filter_data.R               64       0  100.00%
R/module_filter_manager.R           210       7  96.67%   119-120, 316, 343, 355, 362-363
R/module_nested_tabs.R              411      54  86.86%   117-129, 178-183, 211, 315-330, 350-354, 372, 409, 527-530, 534-537, 541-544
R/module_session_info.R              18       0  100.00%
R/module_snapshot_manager.R         272       9  96.69%   302-306, 373, 376-378
R/module_source_code.R               69       0  100.00%
R/module_teal_lockfile.R            131      53  59.54%   45-57, 60-62, 76, 86-88, 100-102, 110-119, 122, 124, 126-127, 142-146, 161-162, 177-186
R/module_teal_reporter.R            122       9  92.62%   60, 77-78, 81, 98, 128, 142, 144, 158
R/module_teal.R                     304      28  90.79%   130, 145-146, 179, 235, 265-285, 315-316
R/module_transform_data.R           164      25  84.76%   77-81, 85-89, 106, 112, 119-120, 134-138, 188, 273-277
R/module_validate_error.R            73       0  100.00%
R/modules.R                         345      50  85.51%   170-174, 229-232, 332, 339, 353, 472, 570-576, 706-712, 725-733, 748-763, 796, 808-816
R/reporter_previewer_module.R        41      12  70.73%   41, 45, 68-85
R/teal_data_module-eval_code.R       23       0  100.00%
R/teal_data_module-within.R           7       0  100.00%
R/teal_data_module.R                 23       0  100.00%
R/teal_data_utils.R                  49       0  100.00%
R/teal_modifiers.R                   57       0  100.00%
R/teal_slices-store.R                29       0  100.00%
R/teal_slices.R                      48       2  95.83%   153-154
R/teal_transform_module.R            45       0  100.00%
R/TealAppDriver.R                   355     355  0.00%    50-753
R/utils.R                           291      49  83.16%   38, 408-457, 545-554
R/validate_inputs.R                  52       0  100.00%
R/validations.R                      58       0  100.00%
R/zzz.R                              20       0  100.00%
TOTAL                              3907     739  81.09%

Diff against main

Filename               Stmts    Miss  Cover
-------------------  -------  ------  --------
R/module_teal.R           +1       0  +0.03%
R/validate_inputs.R      +20       0  +100.00%
TOTAL                    +21       0  +0.10%

Results for commit: c6e6ee1

Minimum allowed coverage is 80%

♻️ This comment has been updated with latest results

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Oct 30, 2025

Unit Tests Summary

  1 files   36 suites   2m 43s ⏱️
480 tests 414 ✅ 66 💤 0 ❌
743 runs  677 ✅ 66 💤 0 ❌

Results for commit c6e6ee1.

♻️ This comment has been updated with latest results.

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Oct 30, 2025

Unit Test Performance Difference

Test Suite $Status$ Time on main $±Time$ $±Tests$ $±Skipped$ $±Failures$ $±Errors$
module_session_info 💔 $18.26$ $+2.99$ $0$ $0$ $0$ $0$
module_teal 💔 $109.36$ $+18.09$ $0$ $0$ $0$ $0$
shinytest2-disable_report 👶 $+0.41$ $+4$ $+4$ $0$ $0$
shinytest2-disable_src 👶 $+0.20$ $+2$ $+2$ $0$ $0$
shinytest2-show-rcode 👶 $+0.31$ $+3$ $+3$ $0$ $0$
shinytest2-teal_modifiers 👶 $+0.56$ $+7$ $+7$ $0$ $0$
shinytest2-validate_input 👶 $+0.30$ $+3$ $+3$ $0$ $0$
validate_input 👶 $+0.20$ $+15$ $0$ $0$ $0$
Additional test case details
Test Suite $Status$ Time on main $±Time$ Test Case
module_session_info 💔 $18.13$ $+3.11$ srv_session_info_lockfile_creation_process_is_invoked_for_teal.lockfile.mode_enabled_and_snapshot_is_copied_to_teal_app.lock_and_removed_after_session_ended
module_teal 💔 $5.76$ $+1.77$ srv_teal_summary_table_summary_table_displays_MAE_dataset_added_in_transformators
module_teal 💔 $1.30$ $+1.01$ srv_teal_teal_module_s_transformator_evaluates_custom_qenv_call_after_filter_is_applied
module_teal 💔 $0.81$ $+1.14$ teal_reporter_Card_added_to_the_report_contains_Filter_settings_section_teal_slices_yaml_and_code_if_filters_are_set
shinytest2-decorators 💀 $0.03$ $-0.03$ unnamed
shinytest2-disable_report 👶 $+0.10$ Add_to_report_button_is_not_disabled_by_default.
shinytest2-disable_report 👶 $+0.10$ Report_button_is_active_on_a_nested_module_by_default
shinytest2-disable_report 👶 $+0.11$ Report_button_is_disabled_on_a_module_changed_by_disable_report_
shinytest2-disable_report 👶 $+0.10$ Report_button_is_disabled_on_nested_modules_changed_by_disable_report_
shinytest2-disable_src 👶 $+0.10$ Show_R_Code_button_is_disabled_on_a_module
shinytest2-disable_src 👶 $+0.10$ Show_R_Code_is_disabled_on_nested_modules_changed_with_disable_src
shinytest2-reporter 💀 $0.01$ $-0.01$ unnamed
shinytest2-show-rcode 👶 $+0.10$ e2e_Module_with_Show_R_Code_has_code
shinytest2-show-rcode 👶 $+0.10$ e2e_Module_with_Show_R_Code_has_modal_with_two_dismiss_and_two_copy_to_clipboard_buttons
shinytest2-show-rcode 👶 $+0.11$ e2e_Module_with_Show_R_Code_initializes_with_visible_button
shinytest2-teal_data_module 💀 $0.01$ $-0.01$ unnamed
shinytest2-teal_modifiers 👶 $+0.08$ e2e_add_landing_modal_displays_landing_modal_on_app_startup
shinytest2-teal_modifiers 👶 $+0.08$ e2e_add_landing_modal_modal_can_be_dismissed
shinytest2-teal_modifiers 👶 $+0.08$ e2e_combined_modifiers_displays_all_customizations_when_chained_together
shinytest2-teal_modifiers 👶 $+0.08$ e2e_modify_footer_displays_custom_footer_in_the_app
shinytest2-teal_modifiers 👶 $+0.08$ e2e_modify_header_displays_custom_header_in_the_app
shinytest2-teal_modifiers 👶 $+0.08$ e2e_modify_title_sets_custom_title_in_the_page_title_head_title_displays_custom_favicon_in_the_app
shinytest2-teal_modifiers 👶 $+0.10$ e2e_modify_title_sets_custom_title_in_the_page_title_head_title_displays_custom_title_in_the_app
shinytest2-validate_input 👶 $+0.10$ e2e_validate_input_displays_validation_message_when_input_is_invalid_no_message_when_valid
shinytest2-validate_input 👶 $+0.10$ e2e_validate_input_validates
shinytest2-validate_input 👶 $+0.10$ e2e_validate_input_validates_many_inputs_and_linked_output_when_they_return_invalid_value
validate_input 👶 $+0.05$ validate_input_condition_has_to_be_a_logical_1_or_function_with_nargs_length_inputId_
validate_input 👶 $+0.02$ validate_input_inputId_has_to_be_a_character_1_
validate_input 👶 $+0.01$ validate_input_message_has_to_be_a_character_1_
validate_input 👶 $+0.02$ validate_input_returns_NULL_when_condition_is_TRUE
validate_input 👶 $+0.02$ validate_input_throws_message_as_shiny.silent.error_when_condition_FALSE_
validate_input 👶 $+0.01$ validate_input_with_multiple_inputIds_doesn_t_throw_shiny.silent.error_if_all_inputs_are_valid
validate_input 👶 $+0.02$ validate_input_with_multiple_inputIds_throws_shiny.silent.error_when_any_input_is_invalid
validate_input 👶 $+0.02$ validate_input_works_with_function_condition_that_returns_FALSE_for_input_with_inputId_
validate_input 👶 $+0.02$ validate_input_works_with_function_condition_that_returns_TRUE_for_input_with_inputId_

Results for commit c4632e4

♻️ This comment has been updated with latest results.

@m7pr
Copy link
Copy Markdown
Collaborator

m7pr commented Nov 3, 2025

8 failed tests in R CMD CHECK

[ FAIL 8 | WARN 3 | SKIP 56 | PASS 482 ]
 Error in `testthat::test_that("e2e: validate_input validates dateRangeInput")`: argument "code" is missing, with no default

does validate_input needs some default value?

https://github.com/insightsengineering/teal/actions/runs/19031248490/job/54345566087?pr=1642#step:44:618

@m7pr
Copy link
Copy Markdown
Collaborator

m7pr commented Nov 3, 2025

@gogonzo
Copy link
Copy Markdown
Contributor Author

gogonzo commented Nov 3, 2025

Ah ok, those are those 8 tests that do not have any body yet

https://github.com/insightsengineering/teal/pull/1642/files#diff-1701b89782ded4509f0394359d889ddd3b2ffdf2a3532c898cf75ed77dfe3201R117-R124

Yup, this is for the first volunteer

Comment thread inst/js/extendShinyJs.js
Copy link
Copy Markdown
Contributor

@averissimo averissimo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good! I've added missing tests with shinytest2

Pending CI run, but this feature has been heavily tested with tmg and tmc development

)
})

testthat::describe("e2e: validate_input validates", {
Copy link
Copy Markdown
Contributor

@averissimo averissimo May 4, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@osenan @m7pr can 1 of you review this describe spec I filled in 🙏

Goal was to test in a single app as one should not affect the other

@averissimo averissimo changed the title picks Adds validate_input() -- previously named as "picks" May 11, 2026
Comment thread tests/testthat/test-shinytest2-validate_input.R
Comment thread tests/testthat/test-shinytest2-validate_input.R
Comment thread tests/testthat/test-shinytest2-validate_input.R
app_driver <- TealAppDriver$new(init(data = simple_teal_data(), modules = all_inputs_mod))
withr::defer(app_driver$stop())

it("selectInput", {
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Each it() assumes the previous steps left the app in a good state. That matches the “one journey” goal, but it means you cannot reorder it() blocks or run a single it() in isolation for a focused failure. If a middle step flakes, everything after it is harder to interpret. For that case, the “traditional” pattern (one test_that + one driver per widget type) is easier to debug

Copy link
Copy Markdown
Contributor

@averissimo averissimo May 14, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point, I made a change in the new branch that gets out of this dependency on the test.

I kept the same 1 App as the errors are now fully independent (removed the only one that checks for no errors overall which is redundant)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I made the changes in the new branch as it uses the new API natively

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Design data extract and data merge

5 participants