browsertrix/backend/test/test_api.py
Tessa Walsh dc41468daf
Allow users to run crawls with 1 or 2 browser windows (#2627)
Fixes #2425 

## Changed

- Switch backend to primarily using number of browser windows rather
than scale multiplier (including migration to calculate `browserWindows`
from `scale` for existing workflows and crawls)
- Still support `scale` in addition to `browserWindows` in input models
for creating and updating workflows and re-adjusting live crawl scale
for backwards compatibility
- Adds new `max_browser_windows` value to Helm chart, but calculates the
value from `max_crawl_scale` as fallback for users with that value
already set in local charts
- Rework frontend to allow users to select multiples of
`crawler_browser_instances` or any value below
`crawler_browser_instances` for browser windows. For instance, with
`crawler_browser_instances=4` and `max_browser_windows=8`, the user
would be presented with the following options: 1, 2, 3, 4, 8
- Sets maximum width of screencast to image width returned by `message`

---------

Co-authored-by: Ilya Kreymer <ikreymer@gmail.com>
Co-authored-by: sua yoo <sua@suayoo.com>
Co-authored-by: Ilya Kreymer <ikreymer@users.noreply.github.com>
2025-06-03 13:37:30 -07:00

56 lines
1.3 KiB
Python

import requests
from .conftest import API_PREFIX
def test_api_docs():
r = requests.get(f"{API_PREFIX}/docs")
assert r.status_code == 200
text = r.text
assert "<title>Browsertrix API</title>" in text
assert "/favicon.ico" in text
assert "/api/openapi.json" in text
def test_api_redoc():
r = requests.get(f"{API_PREFIX}/redoc")
assert r.status_code == 200
text = r.text
assert "<title>Browsertrix API</title>" in text
assert "/favicon.ico" in text
assert "/api/openapi.json" in text
def test_api_openapi():
r = requests.get(f"{API_PREFIX}/openapi.json")
assert r.status_code == 200
json = r.json()
assert json["info"]["title"] == "Browsertrix"
assert json["info"]["x-logo"]["url"] == "/docs-logo.svg"
def test_api_settings():
r = requests.get(f"{API_PREFIX}/settings")
assert r.status_code == 200
data = r.json()
assert data == {
"registrationEnabled": False,
"jwtTokenLifetime": 1440,
"defaultBehaviorTimeSeconds": 300,
"maxPagesPerCrawl": 4,
"maxBrowserWindows": 8,
"numBrowsersPerInstance": 2,
"defaultPageLoadTimeSeconds": 120,
"billingEnabled": True,
"signUpUrl": "",
"salesEmail": "",
"supportEmail": "",
"localesEnabled": None,
"pausedExpiryMinutes": 10080,
}