snapshot: preserve configurable onboarding conditional logic
This commit is contained in:
@@ -4,7 +4,7 @@ from django.contrib.auth import get_user_model
|
||||
from django.test import TestCase
|
||||
|
||||
from workflows.branding import get_company_email_domain
|
||||
from workflows.models import FormFieldConfig, FormSectionConfig, OnboardingRequest
|
||||
from workflows.models import FormConditionalRuleConfig, FormFieldConfig, FormSectionConfig, OnboardingRequest
|
||||
|
||||
|
||||
class OnboardingFlowTests(TestCase):
|
||||
@@ -143,3 +143,31 @@ class OnboardingFlowTests(TestCase):
|
||||
self.assertEqual(submit_response.status_code, 302)
|
||||
self.assertTrue(OnboardingRequest.objects.filter(work_email=f'nora.section@{self.company_domain}').exists())
|
||||
mock_delay.assert_called_once()
|
||||
|
||||
def test_onboarding_page_renders_conditional_rules_payload(self):
|
||||
response = self.client.get('/onboarding/new/', HTTP_HOST='localhost')
|
||||
html = response.content.decode('utf-8')
|
||||
|
||||
self.assertEqual(response.status_code, 200)
|
||||
self.assertIn('id="onboarding-conditional-rules"', html)
|
||||
self.assertIn('business-card-box', html)
|
||||
self.assertIn('employment-end-box', html)
|
||||
self.assertIn('data-conditional-target="business-card-box"', html)
|
||||
self.assertIn('data-conditional-target="phone-box"', html)
|
||||
|
||||
def test_onboarding_page_uses_stored_conditional_rule_config(self):
|
||||
FormConditionalRuleConfig.objects.update_or_create(
|
||||
form_type='onboarding',
|
||||
target_key='employment-end-box',
|
||||
defaults={
|
||||
'is_active': True,
|
||||
'clauses': [{'field': 'employment_type', 'operator': 'equals', 'value': 'unbefristet'}],
|
||||
},
|
||||
)
|
||||
|
||||
response = self.client.get('/onboarding/new/', HTTP_HOST='localhost')
|
||||
html = response.content.decode('utf-8')
|
||||
|
||||
self.assertEqual(response.status_code, 200)
|
||||
self.assertIn('employment-end-box', html)
|
||||
self.assertIn('"value": "unbefristet"', html)
|
||||
|
||||
Reference in New Issue
Block a user