snapshot: preserve configurable onboarding conditional logic

This commit is contained in:
Md Bayazid Bostame
2026-03-27 12:54:47 +01:00
parent eb0fb811e4
commit 2e5e941d41
9 changed files with 431 additions and 41 deletions

View File

@@ -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)