|
| 1 | +test_that("pw_sys_files returns the correct paths", { |
| 2 | + result <- pw_sys_files("DESCRIPTION") |
| 3 | + expect_true(file.exists(result), info = "The DESCRIPTION file should exist in the package directory.") |
| 4 | + |
| 5 | + result <- pw_sys_files("non_existent_file.txt") |
| 6 | + expect_equal(result, "", info = "A non-existent file should return an empty string.") |
| 7 | + |
| 8 | + result <- pw_sys_files() |
| 9 | + expect_true(dir.exists(result), info = "Calling without arguments should return the root of the package.") |
| 10 | +}) |
| 11 | + |
| 12 | +test_that("stop_if_playwright_skeleton_not_present works as expected", { |
| 13 | + mock_golem_wd <- tempdir() |
| 14 | + on.exit({ |
| 15 | + unlink(file.path(mock_golem_wd, "tests", "playwright"), recursive = TRUE) |
| 16 | + }) |
| 17 | + dir.create(file.path(mock_golem_wd, "tests", "playwright"), recursive = TRUE) |
| 18 | + file.create(file.path(mock_golem_wd, "tests", "playwright", "playwright.config.ts")) |
| 19 | + |
| 20 | + # Test when the Playwright skeleton is present |
| 21 | + expect_silent(stop_if_playwright_skeleton_not_present(where = mock_golem_wd)) |
| 22 | + |
| 23 | + # Test when the Playwright skeleton directory is missing |
| 24 | + unlink(file.path(mock_golem_wd, "tests", "playwright"), recursive = TRUE) |
| 25 | + expect_error( |
| 26 | + stop_if_playwright_skeleton_not_present(where = mock_golem_wd), |
| 27 | + "Playwright skeleton not found. Please run `pw::pw_init()` first.", |
| 28 | + fixed = TRUE |
| 29 | + ) |
| 30 | + |
| 31 | + # Test when the Playwright configuration file is missing |
| 32 | + dir.create(file.path(mock_golem_wd, "tests", "playwright"), recursive = TRUE) |
| 33 | + unlink(file.path(mock_golem_wd, "tests", "playwright", "playwright.config.ts")) |
| 34 | + expect_error( |
| 35 | + stop_if_playwright_skeleton_not_present(where = mock_golem_wd), |
| 36 | + "Playwright skeleton not found. Please run `pw::pw_init()` first.", |
| 37 | + fixed = TRUE |
| 38 | + ) |
| 39 | +}) |
| 40 | + |
0 commit comments