Skip to content

Commit 0d2533a

Browse files
committed
Update view-test-images.R
1 parent 6945307 commit 0d2533a

File tree

1 file changed

+30
-17
lines changed

1 file changed

+30
-17
lines changed

R/view-test-images.R

Lines changed: 30 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@ view_test_images <- function(repo_dir = ".") {
1616
# No debug snapshots
1717
# Not new png files
1818
app_pngs <- app_pngs[!grepl("(_|\\.new)\\.png$", app_pngs)]
19+
# Has _snaps folder
20+
app_pngs <- app_pngs[grepl("/_snaps/", app_pngs)]
1921

2022
test_name = dirname(app_pngs)
2123
variant = dirname(test_name)
@@ -59,25 +61,36 @@ view_test_images <- function(repo_dir = ".") {
5961
test_names$test_name,
6062
f = function(png_name_, test_name_) {
6163
test_dt <- dplyr::filter(app_png_dt, png_name == png_name_, test_name == test_name_)
62-
# row_pngs <- png_names[basename(png_names) %in% row]
63-
row_images <-
64-
Map(
65-
test_dt$variant,
66-
test_dt$path,
67-
f = function(variant, png_path) {
68-
shiny::column(
69-
max(3, round(12 / nrow(test_dt))),
70-
shiny::div(
71-
shiny::tags$p(paste0(variant, "/", test_name_)),
72-
shiny::imageOutput(png_path, height = "auto")
73-
)
64+
test_dt <- dplyr::arrange(test_dt, variant)
65+
platform_and_version <- strsplit(test_dt$variant, "-")
66+
test_dt$platform <- sapply(platform_and_version, "[", 1)
67+
test_dt$r_version <- sapply(platform_and_version, "[", 2)
68+
69+
rows <-
70+
lapply(unique(test_dt$platform), function(platform_) {
71+
p_dt <- dplyr::filter(test_dt, platform == platform_)
72+
row_images <-
73+
Map(
74+
p_dt$variant,
75+
p_dt$path,
76+
f = function(variant, png_path) {
77+
shiny::div(
78+
style="padding-right: 5px;",
79+
shiny::tags$p(variant, style="margin-bottom: 5px;margin-top: 5px;"),
80+
shiny::imageOutput(png_path, height = "auto", width = "100%")
81+
)
82+
}
7483
)
75-
}
76-
)
77-
row_images <- unname(row_images)
84+
row_images <- unname(row_images)
85+
shiny::div(
86+
style="display: flex;",
87+
!!!row_images
88+
)
89+
})
7890
shiny::wellPanel(
79-
shiny::h3(paste("Screenshot", png_name_)),
80-
shiny::br(), shiny::fluidRow(!!!row_images)
91+
shiny::h3(paste("Screenshot:", paste0(test_name_, "/", png_name_)), style="margin-top:0"),
92+
# shiny::br(),
93+
rows
8194
)
8295
}
8396
)

0 commit comments

Comments
 (0)