diff --git a/tests/testthat/test-quarto_leanpub_prep.R b/tests/testthat/test-quarto_leanpub_prep.R index 735f72b..17f4837 100644 --- a/tests/testthat/test-quarto_leanpub_prep.R +++ b/tests/testthat/test-quarto_leanpub_prep.R @@ -1,28 +1,32 @@ -test_that("Tocless render for Quarto", { +test_that("Create Leanpub IFrames for Quarto", { - dir <- download_ottr_template(dir = "inst/extdata", type = "quarto") + dir <- download_ottr_template(dir = ".", type = "quarto") - # render_without_toc() + quarto::quarto_render('.', + metadata = list(sidebar = F, toc = F), + quarto_args = c('--output-dir', 'docs/no_toc/')) # TODO: This should be functionalized and incorporated into the package # curl -o make_screenshots.R https://raw.githubusercontent.com/jhudsl/ottr-reports/main/scripts/make_screenshots.R - # chapt_urls=$(Rscript --vanilla make_screenshots.R \ - # --git_pat ${{ secrets.GH_PAT }} \ - # --repo $GITHUB_REPOSITORY \ + # chapt_urls=$(Rscript --vanilla make_screenshots.R + # --git_pat sys.getEnv("GH_PAT") + # --repo fhdsl/OTTR_Quarto # --output_dir resources/chapt_screen_images) - unlink(dir, recursive = TRUE) -}) + ## TEST HERE: + # 1. Does each chapter have screenshot? + # 2. Is the file 'resources/chapt_screen_images/chapter_urls.tsv' made fresh? + # 2. Does chapter_urls.tsv file made have columns with information that are labeled "url", "chapt_title" and "img_path" -test_that("Create Leanpub IFrames for Quarto", { - # ottrpal::bookdown_to_embed_leanpub( - # render = FALSE, \ - # chapt_img_key = 'resources/chapt_screen_images/chapter_urls.tsv', \ - # make_book_txt = as.logical('${{needs.yaml-check.outputs.make_book_txt}}'), \ - # quiz_dir = NULL) + ottrpal::bookdown_to_embed_leanpub( + render = FALSE, + chapt_img_key = 'resources/chapt_screen_images/chapter_urls.tsv', + make_book_txt = TRUE) + + ## TEST HERE: + # 1. Did each chapter get a md in the manuscript folder? + # 2. Does each md link to the appropriate sceenshot? + # 3. Did the screenshot file path that's in the md lead to the appropriate file path? - # ottrpal::bookdown_to_embed_leanpub( - # render = FALSE, \ - # chapt_img_key = 'resources/chapt_screen_images/chapter_urls.tsv', \ - # make_book_txt = as.logical('${{needs.yaml-check.outputs.make_book_txt}}')) + unlink(dir, recursive = TRUE) }) diff --git a/tests/testthat/test-quizzes.R b/tests/testthat/test-quizzes.R index aaad097..68ee31b 100644 --- a/tests/testthat/test-quizzes.R +++ b/tests/testthat/test-quizzes.R @@ -17,7 +17,4 @@ test_that("Quiz checks", { ## Now check the quizzes in that directory all_quiz_results <- check_quizzes(quiz_dir = quiz_dir) - - # Need to download OTTR course for testing - # ottrpal::check_quizzes(quiz_dir = file.path(root_dir, "quizzes"), write_report = TRUE, verbose = TRUE) }) diff --git a/tests/testthat/test-rendering.R b/tests/testthat/test-rendering.R index 53126de..4880f6d 100644 --- a/tests/testthat/test-rendering.R +++ b/tests/testthat/test-rendering.R @@ -2,6 +2,7 @@ test_that("Rmd Rendering", { dir <- download_ottr_template(dir = ".", type = "rmd") bookdown::render_book("OTTR_Template-main") + unlink(dir) }) @@ -22,7 +23,7 @@ test_that("Rmd Website Rendering", { rmarkdown::clean_site(dir, preview = FALSE) rmarkdown::render_site(dir) - + unlink(dir) }) @@ -31,6 +32,6 @@ test_that("Quarto Website Rendering", { dir <- download_ottr_template(dir = ".", type = "quarto_website") quarto::quarto_render(dir) - + unlink(dir) }) diff --git a/tests/testthat/test-rmd_leanpub_prep.R b/tests/testthat/test-rmd_leanpub_prep.R index 14ccb4a..940d23c 100644 --- a/tests/testthat/test-rmd_leanpub_prep.R +++ b/tests/testthat/test-rmd_leanpub_prep.R @@ -1,33 +1,32 @@ -test_that("Tocless render for Rmd", { - # render_without_toc() +test_that("Create Leanpub IFrames for Rmd", { + dir <- download_ottr_template(dir = ".", type = "rmd") + bookdown::render_book("OTTR_Template-main") + # TODO: This should be functionalized and incorporated into the package # curl -o make_screenshots.R https://raw.githubusercontent.com/jhudsl/ottr-reports/main/scripts/make_screenshots.R - # chapt_urls=$(Rscript --vanilla make_screenshots.R \ - # --git_pat ${{ secrets.GH_PAT }} \ - # --repo $GITHUB_REPOSITORY \ + # Rscript --vanilla make_screenshots.R + # --git_pat sys.getEnv("GH_PAT") + # --repo fhdsl/OTTR_Template # --output_dir resources/chapt_screen_images) - unlink("dir", recursive = TRUE) -}) - - -test_that("Create Leanpub IFrames for Rmd", { - - dir <- download_ottr_template(dir = ".", type = "rmd") - - # ottrpal::bookdown_to_embed_leanpub( - # render = FALSE, \ - # chapt_img_key = 'resources/chapt_screen_images/chapter_urls.tsv', \ - # make_book_txt = as.logical('${{needs.yaml-check.outputs.make_book_txt}}'), \ - # quiz_dir = NULL) - - # ottrpal::bookdown_to_embed_leanpub( - # render = FALSE, \ - # chapt_img_key = 'resources/chapt_screen_images/chapter_urls.tsv', \ - # make_book_txt = as.logical('${{needs.yaml-check.outputs.make_book_txt}}')) + ## TEST HERE: + # 1. Does each chapter have screenshot? + # 2. Is the file 'resources/chapt_screen_images/chapter_urls.tsv' made fresh? + # 2. Does chapter_urls.tsv file made have columns with information that are labeled "url", "chapt_title" and "img_path" + + ottrpal::bookdown_to_embed_leanpub( + render = FALSE, + chapt_img_key = 'resources/chapt_screen_images/chapter_urls.tsv', + make_book_txt = TRUE, + quiz_dir = "quizzes") + + ## TEST HERE: + # 1. Did each chapter get a md in the manuscript folder? + # 2. Does each md link to the appropriate sceenshot? + # 3. Did the screenshot file path that's in the md lead to the appropriate file path? unlink(dir, recursive = TRUE) })