- serve manifest and service worker from the app root for install compatibility - add manifest metadata, service worker registration, and Apple touch icon links to the base template - add install icon assets for Android, iOS, and desktop install flows - document deployment and validation notes for the new PWA support - cover the new endpoints and template output with tests
This commit is contained in:
@@ -111,6 +111,39 @@ def test_boxes_page_uses_relative_stylesheet_path(client):
|
||||
assert "http://" not in response.text.split("/static/style.css")[0]
|
||||
|
||||
|
||||
def test_base_template_includes_pwa_metadata(client):
|
||||
response = client.get("/boxes")
|
||||
|
||||
assert response.status_code == 200
|
||||
assert 'rel="manifest" href="/manifest.webmanifest"' in response.text
|
||||
assert 'name="theme-color" content="#0b57d0"' in response.text
|
||||
assert 'rel="apple-touch-icon" href="/static/icons/apple-touch-icon.png"' in response.text
|
||||
assert 'navigator.serviceWorker.register("/service-worker.js")' in response.text
|
||||
|
||||
|
||||
def test_manifest_is_served_with_pwa_fields(client):
|
||||
response = client.get("/manifest.webmanifest")
|
||||
|
||||
assert response.status_code == 200
|
||||
assert response.headers["content-type"].startswith("application/manifest+json")
|
||||
|
||||
manifest = response.json()
|
||||
assert manifest["name"] == "搬家助手"
|
||||
assert manifest["short_name"] == "搬家助手"
|
||||
assert manifest["start_url"] == "/boxes"
|
||||
assert manifest["display"] == "standalone"
|
||||
assert any(icon["sizes"] == "192x192" for icon in manifest["icons"])
|
||||
assert any(icon["purpose"] == "maskable" for icon in manifest["icons"])
|
||||
|
||||
|
||||
def test_service_worker_is_served_from_root(client):
|
||||
response = client.get("/service-worker.js")
|
||||
|
||||
assert response.status_code == 200
|
||||
assert response.headers["content-type"].startswith("application/javascript")
|
||||
assert 'self.addEventListener("install"' in response.text
|
||||
|
||||
|
||||
def test_boxes_overview_card_shows_note_and_item_count_without_room_or_status(client, db_session):
|
||||
box = Box(
|
||||
name="Kitchen Box",
|
||||
|
||||
Reference in New Issue
Block a user