-
Notifications
You must be signed in to change notification settings - Fork 23
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
add-test-to-animint2 #176
base: master
Are you sure you want to change the base?
add-test-to-animint2 #176
Conversation
tests_init() | ||
tests_run(filter="renderer3-TestWorldBankTwoLayers") | ||
tests_exit() | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please remove mytests.r file
# Test that the visualization generates without warnings or errors | ||
test_that("worldbank two-layers visualization generated without any warnings or errors", { | ||
expect_no_warning({ | ||
info <- animint2HTML(scatter_plot) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this test does not use the renderer. please show that you understand how to inspect the output of the chromote renderer, and simulate interaction.
- first add an expectation about info$html (maybe all of the regions are shown by default at first?)
- then please use clickID() to simulate interaction (maybe with your legend?),
- and then use getHTML() to get the HTML after the simulated interaction,
- and then finally use another expectation about what the HTML looks like after interaction.
also this world bank data viz is not a very interesting test case, because you have no clickSelects/showSelected here. Instead can you write a test based on the animation example you created? https://busttech.github.io/deploy2/
also for the video can you please narrate next time? use your voice to explain what you are doing, what you observe after executing each command, etc. |
Sir I was not able to fullfill the changes that you given but I changed the test case to the animation example that I created https://busttech.github.io/deploy2/ .Can you please provide any manual or previous test cases so I can fullfill the other changes also. faces <- c("Head", "Tail", "Stand")
prob <- c(0.45, 0.45, 0.1)
n_tosses <- 100
flips <- sample(faces, size = n_tosses, replace = TRUE, prob = prob)
flip_data <- data.frame(
toss = seq_len(n_tosses),
result = flips
)
flip_data <- flip_data %>%
mutate(HEAD = cumsum(result == "Head"),
TAIL = cumsum(result == "Tail"),
STAND = cumsum(result == "Stand"))
flip_data_long <- flip_data %>%
pivot_longer(cols = c("HEAD", "TAIL", "STAND"),
names_to = "outcome",
values_to = "count") %>%
mutate(outcome = factor(outcome, levels = c("HEAD", "TAIL", "STAND")))
flip_data$result <- factor(flip_data$result, levels = c("Head", "Tail", "Stand"))
bar_plot <- ggplot(flip_data_long) +
geom_bar(aes(x = outcome, y = count, fill = outcome),
stat = "identity",
position = "identity",
showSelected = "toss") +
geom_text(aes(x = outcome, y = count, label = count),
vjust = 0,
showSelected = "toss") +
labs(title = "Coin Flip Frequencies (Interactive)",
x = "Face",
y = "Count") +
scale_x_discrete(labels = c("Head", "Tail", "Stand")) +
scale_fill_manual(values = c("HEAD" = "red",
"TAIL" = "green",
"STAND" = "blue")) +
guides(fill = "none")
line_plot <- ggplot(flip_data, aes(x = toss)) +
geom_line(aes(y = HEAD / toss, color = result, group = result), size = 1) +
geom_point(aes(y = HEAD / toss, color = result), size = 2, showSelected = "toss") +
geom_tallrect(aes(xmin = toss - 0.5, xmax = toss + 0.5), alpha = 0.2, clickSelects = "toss") +
labs(title = "Cumulative Frequency Over Tosses (Interactive)",
x = "Toss Number",
y = "Cumulative Frequency") +
scale_color_manual(values = c("Head" = "red",
"Tail" = "green",
"Stand" = "blue"))
plots <- list(
frequency = bar_plot,
cumulative = line_plot,
time = list(variable = "toss", ms = 200)
)
animint(plots)
# Test that the visualization generates without warnings or errors
test_that("Flip-coin animation generated without any warnings or errors", {
expect_no_warning({
info <- animint2HTML(plots)
})
}) |
please grep tests/testthat/test-renderer-* files for "clickID" to see examples. |
This solution of the hard-test(gsoc)
video = https://www.youtube.com/watch?v=Gog2Sv7t_cE
The visualization I used for testing --> https://busttech.github.io/deploy/