Skip to content

Commit

Permalink
Confirm search form with Playwright, refs #19
Browse files Browse the repository at this point in the history
  • Loading branch information
simonw committed Jan 8, 2024
1 parent 04089a1 commit 3ecd8e6
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 3 deletions.
14 changes: 12 additions & 2 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,25 @@ def db_path(tmpdir):


@pytest.fixture
def ds_server(db_path):
def db_path_searchable(db_path):
sqlite_utils.Database(db_path)["creatures"].enable_fts(["name", "description"])
# Copy to /tmp
import shutil

shutil.copyfile(str(db_path), "/tmp/data.db")
return db_path


@pytest.fixture
def ds_server(db_path_searchable):
process = Popen(
[
sys.executable,
"-m",
"datasette",
"--port",
"8126",
str(db_path),
str(db_path_searchable),
],
stdout=PIPE,
)
Expand Down
5 changes: 4 additions & 1 deletion tests/test_playwright.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,13 @@
sync_api = None
import pytest


@pytest.mark.skipif(sync_api is None, reason="playwright not installed")
def test_search(ds_server):
def test_ds_server(ds_server):
with sync_api.sync_playwright() as playwright:
browser = playwright.chromium.launch()
page = browser.new_page()
page.goto(ds_server + "/")
assert page.title() == "Datasette: data"
# It should have a search form
assert page.query_selector('form[action="/-/search"]')

0 comments on commit 3ecd8e6

Please sign in to comment.