-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
0348999
commit 1247b5c
Showing
24 changed files
with
121 additions
and
296 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
""" | ||
Pytest configuration. | ||
""" | ||
|
||
from __future__ import annotations | ||
|
||
from betty.tests.conftest import * # noqa F403 |
51 changes: 51 additions & 0 deletions
51
betty/tests_playwright/project/extension/cotton_candy/test_search_ui.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
from collections.abc import AsyncIterator | ||
|
||
import pytest | ||
from playwright.async_api import expect, Page | ||
|
||
from betty import serve | ||
from betty.ancestry.person import Person | ||
from betty.ancestry.person_name import PersonName | ||
from betty.app import App | ||
from betty.project import Project | ||
from betty.project.extension.cotton_candy import CottonCandy | ||
from betty.project.generate import generate | ||
from betty.serve import Server | ||
|
||
|
||
class TestSearchUi: | ||
@pytest.fixture(scope="session") | ||
async def served_project(self) -> AsyncIterator[tuple[Project, Server]]: | ||
person_id = "I0001" | ||
person = Person(id=person_id) | ||
person_individual_name = "Janet" | ||
PersonName(individual=person_individual_name, person=person) | ||
async with ( | ||
App.new_temporary() as app, | ||
app, | ||
Project.new_temporary(app) as project, | ||
): | ||
project.configuration.extensions.enable(CottonCandy) | ||
project.ancestry[Person].add(person) | ||
async with project: | ||
await generate(project) | ||
async with await serve.BuiltinProjectServer.new_for_project( | ||
project | ||
) as server: | ||
yield project, server | ||
|
||
@pytest.mark.asyncio(loop_scope="session") | ||
async def test(self, page: Page, served_project: tuple[Project, Server]) -> None: | ||
project, server = served_project | ||
person = project.ancestry[Person]["I0001"] | ||
await page.goto(server.public_url) | ||
search_query = page.locator("#search-query") | ||
individual_name = person.names[0].individual | ||
assert individual_name | ||
await search_query.fill(individual_name) | ||
await search_query.press("ArrowDown") | ||
await expect(page.locator("#search-results")).to_be_visible() | ||
await page.keyboard.press("ArrowDown") | ||
await page.locator(":focus").press("Enter") | ||
assert page.url == f"{server.public_url}/person/{person.id}/index.html" | ||
await page.close() |
41 changes: 41 additions & 0 deletions
41
betty/tests_playwright/project/extension/http_api_doc/test_swagger_ui.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
from collections.abc import AsyncIterator | ||
|
||
import pytest | ||
from playwright.async_api import expect, Page | ||
|
||
from betty import serve | ||
from betty.app import App | ||
from betty.project import Project | ||
from betty.project.extension.http_api_doc import HttpApiDoc | ||
from betty.project.generate import generate | ||
from betty.serve import Server | ||
|
||
|
||
class TestSwaggerUi: | ||
@pytest.fixture(scope="session") | ||
async def served_project(self) -> AsyncIterator[tuple[Project, Server]]: | ||
async with ( | ||
App.new_temporary() as app, | ||
app, | ||
Project.new_temporary(app) as project, | ||
): | ||
project.configuration.extensions.enable(HttpApiDoc) | ||
async with project: | ||
await generate(project) | ||
async with await serve.BuiltinProjectServer.new_for_project( | ||
project | ||
) as server: | ||
yield project, server | ||
|
||
@pytest.mark.asyncio(loop_scope="session") | ||
async def test(self, page: Page, served_project: tuple[Project, Server]) -> None: | ||
project, server = served_project | ||
await page.goto(server.public_url + "/api/index.html") | ||
locator = page.locator("#swagger-ui") | ||
# Test a couple of keywords in the source. | ||
await expect(locator).to_contain_text("Betty") | ||
await expect(locator).to_contain_text("api/index.json") | ||
# Test a couple of keywords shown after successful rendering. | ||
await expect(locator).to_contain_text("Retrieve a single") | ||
await expect(locator).to_contain_text("Retrieve the collection") | ||
await page.close() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,3 +6,4 @@ cd "$(dirname "$0")/.." | |
|
||
# Install Python dependencies. | ||
pip install -e '.[development]' | ||
./bin/build-playwright |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
#!/usr/bin/env bash | ||
|
||
set -Eeuo pipefail | ||
|
||
cd "$(dirname "$0")/.." | ||
|
||
# Install Playwright browser dependencies, but allow those | ||
# to fail as Playwright runs on very few systems only. | ||
playwright install --with-deps || true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.