-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[#1661] Moved contact form link display test to plugin
- Loading branch information
Bart van der Schoor
committed
Aug 21, 2023
1 parent
3557f47
commit 3682d82
Showing
3 changed files
with
47 additions
and
34 deletions.
There are no files selected for viewing
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,47 @@ | ||
from django.test import TestCase | ||
from django.utils.translation import gettext as _ | ||
|
||
from open_inwoner.cms.footer.cms_plugins import FooterPagesPlugin | ||
from open_inwoner.cms.tests import cms_tools | ||
from open_inwoner.openklant.models import OpenKlantConfig | ||
from open_inwoner.openklant.tests.factories import ContactFormSubjectFactory | ||
from open_inwoner.utils.test import ClearCachesMixin | ||
|
||
|
||
class ContactFormTestCase(ClearCachesMixin, TestCase): | ||
def setUp(self): | ||
super().setUp() | ||
# clear config | ||
config = OpenKlantConfig.get_solo() | ||
config.klanten_service = None | ||
config.contactmomenten_service = None | ||
config.register_email = "" | ||
config.register_contact_moment = False | ||
config.register_bronorganisatie_rsin = "" | ||
config.register_type = "" | ||
config.register_employee_id = "" | ||
config.save() | ||
|
||
def test_no_form_link_shown_in_footer_if_not_has_configuration(self): | ||
# set nothing | ||
config = OpenKlantConfig.get_solo() | ||
self.assertFalse(config.has_form_configuration()) | ||
|
||
html, context = cms_tools.render_plugin(FooterPagesPlugin) | ||
|
||
self.assertNotIn(_("Contact formulier"), html) | ||
|
||
def test_form_link_is_shown_in_footer_when_has_configuration(self): | ||
ok_config = OpenKlantConfig.get_solo() | ||
self.assertFalse(ok_config.has_form_configuration()) | ||
|
||
ContactFormSubjectFactory(config=ok_config) | ||
|
||
ok_config.register_email = "[email protected]" | ||
ok_config.save() | ||
|
||
self.assertTrue(ok_config.has_form_configuration()) | ||
|
||
html, context = cms_tools.render_plugin(FooterPagesPlugin) | ||
|
||
self.assertIn(_("Contact formulier"), html) |
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 |
---|---|---|
|
@@ -2,15 +2,13 @@ | |
|
||
from django.contrib import messages | ||
from django.core import mail | ||
from django.test import override_settings | ||
from django.urls import reverse | ||
from django.utils.translation import gettext as _ | ||
|
||
import requests_mock | ||
from django_webtest import WebTest | ||
|
||
from open_inwoner.accounts.tests.factories import UserFactory | ||
from open_inwoner.cms.tests import cms_tools | ||
from open_inwoner.openklant.models import OpenKlantConfig | ||
from open_inwoner.openklant.tests.data import MockAPICreateData | ||
from open_inwoner.openklant.tests.factories import ContactFormSubjectFactory | ||
|
@@ -79,38 +77,6 @@ def test_no_form_shown_if_not_has_configuration(self, m): | |
self.assertContains(response, _("Contact formulier niet geconfigureerd.")) | ||
self.assertEqual(0, len(response.pyquery("#contactmoment-form"))) | ||
|
||
@override_settings(ROOT_URLCONF="open_inwoner.cms.tests.urls") | ||
def test_no_form_link_shown_in_footer_if_not_has_configuration(self, m): | ||
# set nothing | ||
config = OpenKlantConfig.get_solo() | ||
self.assertFalse(config.has_form_configuration()) | ||
|
||
cms_tools.create_homepage() | ||
|
||
response = self.app.get(reverse("pages-root")) | ||
links = response.pyquery(".footer__list-item") | ||
|
||
self.assertEqual(len(links), 0) | ||
|
||
@override_settings(ROOT_URLCONF="open_inwoner.cms.tests.urls") | ||
def test_form_link_is_shown_in_footer_when_has_configuration(self, m): | ||
ok_config = OpenKlantConfig.get_solo() | ||
self.assertFalse(ok_config.has_form_configuration()) | ||
|
||
ContactFormSubjectFactory(config=ok_config) | ||
|
||
ok_config.register_email = "[email protected]" | ||
ok_config.save() | ||
|
||
self.assertTrue(ok_config.has_form_configuration()) | ||
|
||
cms_tools.create_homepage() | ||
|
||
response = self.app.get(reverse("pages-root")) | ||
links = response.pyquery(".footer__list-item") | ||
|
||
self.assertIn(_("Contact formulier"), links[0].text_content()) | ||
|
||
def test_anon_form_requires_either_email_or_phonenumber(self, m): | ||
config = OpenKlantConfig.get_solo() | ||
config.register_email = "[email protected]" | ||
|