tests/testthat/test_filters.R

context("Filters are working")

# caps <- list(chromeOptions = list(args = c("--headless", "--disable-gpu")))
# start_browser(port = 4447L,
#               docker = FALSE,
#               browser = "chrome",
#               verbose = FALSE,
#               check = TRUE,
#               extraCapabilities = caps)
# main_page()
# on.exit(stop_browser())

id <- system2("docker",
              args = c("run", "-d", "-p", "4445:4444 selenium/standalone-firefox:3.10.0"),
              stdout = TRUE)
Sys.sleep(5)
start_browser(port = 4445L, docker = TRUE)
main_page()
on.exit({stop_browser()
  system2("docker", args = c("kill", id), stdout = FALSE)})

test_that("Filters can be obtained", {
  f <- get_filters()
  expect_identical(length(f), 5L)
})

test_that("XML names can be obtained with 'field' argument", {
  f <- get_filters(field = "value")
  expect_identical(length(unlist(f)), 8L)
})

test_that("Human-readable names can be obtained with 'field' argument", {
  f <- get_filters(field = "descriptors")
  expect_identical(length(unlist(f)), 8L)
})

test_that("Filtering through menu works", {
  expect_silent(use_filter("closed-consultations"))
})

test_that("Filter application through keywords search works", {
  expect_silent(use_filter("meetings", filter_type = "keywords"))
})

test_that("Filter application through date (from) search works", {
  expect_silent(use_filter("01/01/2018", filter_type = "from_date"))
})

test_that("Filter application through date (to) search works", {
  expect_silent(use_filter("01/01/2018", filter_type = "to_date"))
})
tpaskhalis/RgovUK documentation built on May 26, 2019, 9:37 a.m.