fix: timeout on spa manifest requests
The previous behaviour had a loop of requests between the front app and the api when querying the pwa manifest. This reduce the coupling around the pwa manifest file between the api and the front app, by uplicating the files so each "service" has a copy of it, while keeping them in sync and having the front pwa manifest as single source of truth. Part-of: <https://dev.funkwhale.audio/funkwhale/funkwhale/-/merge_requests/2291>
This commit is contained in:
parent
6abecfc904
commit
b359bb6498
9 changed files with 152 additions and 81 deletions
|
|
@ -1,4 +1,4 @@
|
|||
import json
|
||||
from unittest import mock
|
||||
|
||||
from django.urls import reverse
|
||||
|
||||
|
|
@ -38,20 +38,21 @@ def test_admin_settings_correct_permission(db, logged_in_api_client, preferences
|
|||
assert len(response.data) == len(preferences.all())
|
||||
|
||||
|
||||
def test_manifest_endpoint(api_client, mocker, preferences, tmp_path, settings):
|
||||
settings.FUNKWHALE_SPA_HTML_ROOT = str(tmp_path / "index.html")
|
||||
preferences["instance__name"] = "Test pod"
|
||||
preferences["instance__short_description"] = "Test description"
|
||||
base_payload = {}
|
||||
manifest = tmp_path / "manifest.json"
|
||||
expected = {
|
||||
"name": "Test pod",
|
||||
"short_name": "Test pod",
|
||||
"description": "Test description",
|
||||
}
|
||||
manifest.write_bytes(json.dumps(base_payload).encode())
|
||||
def test_manifest_endpoint(api_client, preferences):
|
||||
with mock.patch(
|
||||
"funkwhale_api.instance.views.PWA_MANIFEST",
|
||||
{"lang": "unchanged"},
|
||||
):
|
||||
preferences["instance__name"] = "Test pod"
|
||||
preferences["instance__short_description"] = "Test description"
|
||||
expected = {
|
||||
"lang": "unchanged",
|
||||
"name": "Test pod",
|
||||
"short_name": "Test pod",
|
||||
"description": "Test description",
|
||||
}
|
||||
|
||||
url = reverse("api:v1:instance:spa-manifest")
|
||||
response = api_client.get(url)
|
||||
assert response.status_code == 200
|
||||
assert response.data == expected
|
||||
url = reverse("api:v1:instance:spa-manifest")
|
||||
response = api_client.get(url)
|
||||
assert response.status_code == 200
|
||||
assert response.data == expected
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue