Widget: Fix language on first iframe request

This commit is contained in:
Raphael Michel
2024-01-26 11:44:02 +01:00
parent 734b376e05
commit eac88b5ef7
5 changed files with 52 additions and 21 deletions

View File

@@ -24,9 +24,9 @@ import time
import pytest
from bs4 import BeautifulSoup
from django.test import Client
from tests.base import extract_form_fields
from pretix.base.models import Organizer
from tests.base import extract_form_fields
@pytest.mark.django_db

View File

@@ -58,9 +58,13 @@ class WidgetCartTest(CartTestMixin, TestCase):
)
def test_iframe_entry_view_wrapper(self):
self.client.get('/%s/%s/?iframe=1&locale=de' % (self.orga.slug, self.event.slug))
self.event.settings.locales = ["de", "en"]
r = self.client.get('/%s/%s/?iframe=1&locale=de' % (self.orga.slug, self.event.slug), headers={
"Accept-Language": "en-GB,en-US;q=0.9,en;q=0.8",
})
assert 'iframe_session' in self.client.session
assert self.client.cookies[settings.LANGUAGE_COOKIE_NAME].value == "de"
assert r.headers["Content-Language"] == "de"
def test_allow_frame_if_namespaced(self):
response = self.client.get('/%s/%s/' % (self.orga.slug, self.event.slug))