-
-
Notifications
You must be signed in to change notification settings - Fork 49
Add comprehensive test coverage for teal_modifiers.R and init.R to improve package coverage #1623
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
Merged
Merged
Changes from 8 commits
Commits
Show all changes
15 commits
Select commit
Hold shift + click to select a range
37de139
Initial plan
Copilot ad49da3
Add comprehensive tests for teal_modifiers.R public functions
Copilot 368109b
Merge branch 'main' into copilot/update-unit-test-coverage
m7pr 5e5b6af
Add header comment to test-teal_modifiers.R
Copilot a6b9d2c
Add UI and server execution tests to improve teal_modifiers.R coverage
Copilot 7da85e3
Add tests for init() module_specific filters and reporter parameter
Copilot 992ea49
Add tests for deprecated init() parameters (title, header, footer, id)
Copilot b7421b5
Refactor teal_modifiers tests using describe/it structure and add e2e…
Copilot 81b5cae
Fix e2e tests: improve descriptions, remove invalid id arguments, use…
Copilot a65f199
remove impossible
gogonzo 295f0cf
Fix TealAppDriver usage in e2e tests - pass modifiers as constructor …
Copilot 878c1f9
- change TealAppDriver$initialize to accept teal_app
gogonzo 3ab2d48
fix docs
gogonzo 44cd106
[skip style] [skip vbump] Restyle files
github-actions[bot] 7946766
full coverage init/teal_modifiers
gogonzo File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,180 @@ | ||
| testthat::skip_if_not_installed("shinytest2") | ||
| testthat::skip_if_not_installed("rvest") | ||
|
|
||
| testthat::describe("e2e: modify_title", { | ||
| testthat::it("displays custom title in the app", { | ||
| skip_if_too_deep(5) | ||
|
|
||
| app <- init( | ||
| data = teal.data::teal_data(iris = iris), | ||
| modules = modules(example_module()) | ||
| ) |> | ||
| modify_title(title = "Custom Test Title") | ||
|
|
||
| app_driver <- TealAppDriver$new(app) | ||
|
|
||
| # Check that the title is present in the page | ||
| page_title <- app_driver$get_text("head title") | ||
| testthat::expect_equal(page_title, "Custom Test Title") | ||
|
|
||
| app_driver$stop() | ||
| }) | ||
|
|
||
| testthat::it("displays custom favicon in the app", { | ||
| skip_if_too_deep(5) | ||
|
|
||
| custom_favicon <- "https://raw.githubusercontent.com/insightsengineering/hex-stickers/main/PNG/teal.png" | ||
| app <- init( | ||
| data = teal.data::teal_data(iris = iris), | ||
| modules = modules(example_module()) | ||
| ) |> | ||
| modify_title(title = "Test App", favicon = custom_favicon) | ||
|
|
||
| app_driver <- TealAppDriver$new(app) | ||
|
|
||
| # Check that favicon link is present | ||
| testthat::expect_true(app_driver$is_visible("link[rel='icon']")) | ||
|
|
||
| app_driver$stop() | ||
| }) | ||
| }) | ||
|
|
||
| testthat::describe("e2e: modify_header", { | ||
| testthat::it("displays custom header in the app", { | ||
| skip_if_too_deep(5) | ||
|
|
||
| app <- init( | ||
| data = teal.data::teal_data(iris = iris), | ||
| modules = modules(example_module()) | ||
| ) |> | ||
| modify_header(element = tags$h1("Custom App Header", id = "test-header")) | ||
gogonzo marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| app_driver <- TealAppDriver$new(app) | ||
|
|
||
| # Check that the header content is visible | ||
| testthat::expect_true(app_driver$is_visible("#test-header")) | ||
| header_text <- app_driver$get_text("#test-header") | ||
| testthat::expect_equal(header_text, "Custom App Header") | ||
gogonzo marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| app_driver$stop() | ||
| }) | ||
| }) | ||
|
|
||
| testthat::describe("e2e: modify_footer", { | ||
| testthat::it("displays custom footer in the app", { | ||
| skip_if_too_deep(5) | ||
|
|
||
| app <- init( | ||
| data = teal.data::teal_data(iris = iris), | ||
| modules = modules(example_module()) | ||
| ) |> | ||
| modify_footer(element = tags$p("Custom Footer Text", id = "test-footer")) | ||
gogonzo marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| app_driver <- TealAppDriver$new(app) | ||
|
|
||
| # Check that the footer content is visible | ||
| testthat::expect_true(app_driver$is_visible("#test-footer")) | ||
| footer_text <- app_driver$get_text("#test-footer") | ||
| testthat::expect_equal(footer_text, "Custom Footer Text") | ||
|
|
||
| app_driver$stop() | ||
| }) | ||
| }) | ||
|
|
||
| testthat::describe("e2e: add_landing_modal", { | ||
| testthat::it("displays landing modal on app startup", { | ||
| skip_if_too_deep(5) | ||
|
|
||
| app <- init( | ||
| data = teal.data::teal_data(iris = iris), | ||
| modules = modules(example_module()) | ||
| ) |> | ||
| add_landing_modal( | ||
| title = "Welcome to the App", | ||
| content = "Please read these instructions before proceeding." | ||
| ) | ||
|
|
||
| app_driver <- TealAppDriver$new(app) | ||
|
|
||
| # Check that modal is visible on startup | ||
| testthat::expect_true(app_driver$is_visible(".modal")) | ||
|
|
||
| # Check modal title | ||
| modal_title <- app_driver$get_text(".modal-title") | ||
| testthat::expect_equal(modal_title, "Welcome to the App") | ||
|
|
||
| # Check modal content is present | ||
| modal_body <- app_driver$get_text(".modal-body") | ||
| testthat::expect_match(modal_body, "Please read these instructions") | ||
|
|
||
| app_driver$stop() | ||
| }) | ||
|
|
||
| testthat::it("modal can be dismissed", { | ||
| skip_if_too_deep(5) | ||
|
|
||
| app <- init( | ||
| data = teal.data::teal_data(iris = iris), | ||
| modules = modules(example_module()) | ||
| ) |> | ||
| add_landing_modal( | ||
| title = "Welcome", | ||
| content = "Test content", | ||
| footer = modalButton("Accept") | ||
| ) | ||
|
|
||
| app_driver <- TealAppDriver$new(app) | ||
|
|
||
| # Modal should be visible initially | ||
| testthat::expect_true(app_driver$is_visible(".modal")) | ||
|
|
||
| # Click the Accept button | ||
| app_driver$click("button:contains('Accept')") | ||
|
|
||
| # Wait a moment for modal to close | ||
| Sys.sleep(0.5) | ||
|
|
||
| # Modal should no longer be visible | ||
| testthat::expect_false(app_driver$is_visible(".modal")) | ||
|
|
||
| app_driver$stop() | ||
| }) | ||
| }) | ||
|
|
||
| testthat::describe("e2e: combined modifiers", { | ||
| testthat::it("displays all customizations when chained together", { | ||
| skip_if_too_deep(5) | ||
|
|
||
| app <- init( | ||
| data = teal.data::teal_data(iris = iris), | ||
| modules = modules(example_module()) | ||
| ) |> | ||
| modify_title(title = "Complete Custom App") |> | ||
| modify_header(element = tags$div("Custom Header", id = "custom-header")) |> | ||
| modify_footer(element = tags$div("Custom Footer", id = "custom-footer")) |> | ||
gogonzo marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| add_landing_modal(title = "Welcome", content = "Welcome message") | ||
|
|
||
| app_driver <- TealAppDriver$new(app) | ||
|
|
||
| # Check title | ||
| page_title <- app_driver$get_text("head title") | ||
| testthat::expect_equal(page_title, "Complete Custom App") | ||
|
|
||
| # Check modal is visible | ||
| testthat::expect_true(app_driver$is_visible(".modal")) | ||
|
|
||
| # Dismiss modal | ||
| app_driver$click("button:contains('Accept')") | ||
| Sys.sleep(0.5) | ||
|
|
||
| # Check header is visible | ||
| testthat::expect_true(app_driver$is_visible("#custom-header")) | ||
| testthat::expect_equal(app_driver$get_text("#custom-header"), "Custom Header") | ||
|
|
||
| # Check footer is visible | ||
| testthat::expect_true(app_driver$is_visible("#custom-footer")) | ||
| testthat::expect_equal(app_driver$get_text("#custom-footer"), "Custom Footer") | ||
|
|
||
| app_driver$stop() | ||
| }) | ||
| }) | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.