feat(forms): gate Form A production embedding

This commit is contained in:
DeCentN2Madness committed 2026-10-28 18:29:32 -07:00
1 parent 1a56cd7603
commit 0eb3fcc3f6
17 files changed
+284 -47

No files matched your search

+35 -4
View File
@@ -15,6 +15,7 @@ const isolated = (overrides = {}) => ({
rawMode: 'isolated-test',
liveApproved: 'false',
isolatedTestApproved: 'true',
productionApproved: 'false',
environmentRole: 'isolated-test',
allowIndexing: 'false',
route: '/contact',
@@ -22,6 +23,18 @@ const isolated = (overrides = {}) => ({
...overrides,
});
const production = (overrides = {}) => ({
rawMode: 'live',
liveApproved: 'true',
isolatedTestApproved: 'false',
productionApproved: 'true',
environmentRole: 'production',
allowIndexing: 'true',
route: '/contact',
locale: 'en',
...overrides,
});
test('Form A iframe uses only fixed, approved route parameters', () => {
assert.equal(formAIframeOrigin, 'https://form.jotform.com');
assert.equal(formAIframeId, '262946078314059');
@@ -54,14 +67,15 @@ test('Form A iframe uses only fixed, approved route parameters', () => {
]);
});
test('Form A iframe requires every isolated-test gate and refuses live mode', () => {
test('Form A iframe requires every isolated-test or production approval gate', () => {
const enabled = resolveFormAIframe(isolated());
assert.equal(enabled.enabled, true);
assert.equal(enabled.reason, 'enabled');
assert.equal(enabled.title, 'AIA general enquiries form');
assert.equal(resolveFormAIframe(isolated({ rawMode: undefined })).reason, 'mode-not-isolated-test');
assert.equal(resolveFormAIframe(isolated({ rawMode: 'mock' })).reason, 'mode-not-isolated-test');
assert.equal(resolveFormAIframe(isolated({ rawMode: 'live', liveApproved: 'true' })).reason, 'mode-not-isolated-test');
assert.equal(enabled.mode, 'isolated-test');
assert.equal(enabled.environmentRole, 'isolated-test');
assert.equal(resolveFormAIframe(isolated({ rawMode: undefined })).reason, 'mode-not-authorized');
assert.equal(resolveFormAIframe(isolated({ rawMode: 'mock' })).reason, 'mode-not-authorized');
assert.equal(resolveFormAIframe(isolated({ liveApproved: undefined })).reason, 'live-approval-not-disabled');
assert.equal(resolveFormAIframe(isolated({ liveApproved: 'true' })).reason, 'live-approval-not-disabled');
assert.equal(resolveFormAIframe(isolated({ isolatedTestApproved: 'false' })).reason, 'isolated-test-not-approved');
@@ -73,6 +87,18 @@ test('Form A iframe requires every isolated-test gate and refuses live mode', ()
const campaign = resolveFormAIframe(isolated({ route: '/lp/aba-therapy' }));
assert.equal(campaign.url, 'https://form.jotform.com/262946078314059?formContext=landing&language=en');
assert.equal(campaign.context, 'landing');
const live = resolveFormAIframe(production());
assert.equal(live.enabled, true);
assert.equal(live.mode, 'live');
assert.equal(live.environmentRole, 'production');
assert.equal(live.url, 'https://form.jotform.com/262946078314059?formContext=contact&language=en');
assert.equal(resolveFormAIframe(production({ productionApproved: undefined })).reason, 'production-approval-not-granted');
assert.equal(resolveFormAIframe(production({ productionApproved: 'false' })).reason, 'production-approval-not-granted');
assert.equal(resolveFormAIframe(production({ environmentRole: 'isolated-test' })).reason, 'invalid-environment-role');
assert.equal(resolveFormAIframe(production({ liveApproved: 'false' })).reason, 'mode-not-authorized');
assert.equal(resolveFormAIframe(production({ rawMode: 'off' })).reason, 'mode-not-authorized');
assert.equal(resolveFormAIframe(production({ route: '/referrals' })).reason, 'route-not-authorized');
assert.equal(resolveFormAIframe(production({ route: '/es/contact', locale: 'es' })).url, 'https://form.jotform.com/262946078314059?formContext=contact&language=es');
assert.equal(formModeForRuntime(resolveFormMode('isolated-test', undefined)), 'off');
assert.equal(formModeForRuntime(resolveFormMode('live', 'true')), 'off');
});
@@ -86,8 +112,10 @@ test('Only the seven allowlisted placements can render the adapter, with no help
assert.match(contact, /resolveFormAIframe/);
assert.match(contact, /route = lang === 'es' \? '\/es\/contact' : '\/contact'/);
assert.match(contact, /JotformIframe/);
assert.match(contact, /PUBLIC_AIA_FORM_A_PRODUCTION_APPROVED/);
assert.match(campaign, /resolveFormAIframe/);
assert.match(campaign, /JotformIframe/);
assert.match(campaign, /PUBLIC_AIA_FORM_A_PRODUCTION_APPROVED/);
assert.match(campaign, /variant="embedded"/);
assert.match(campaign, /\/lp\/aba-therapy/);
assert.match(campaign, /const iframeDescription = 'Use this form to request a conversation\. An AIA team member can explain the next steps for your family\.'/);
@@ -96,8 +124,11 @@ test('Only the seven allowlisted placements can render the adapter, with no help
assert.match(earlyIntervention, /resolveFormAIframe/);
assert.match(earlyIntervention, /route: '\/lp\/early-intervention'/);
assert.match(earlyIntervention, /JotformIframe/);
assert.match(earlyIntervention, /PUBLIC_AIA_FORM_A_PRODUCTION_APPROVED/);
assert.match(adapter, /referrerpolicy="no-referrer"/);
assert.match(adapter, /sandbox="allow-forms allow-scripts allow-same-origin"/);
assert.match(adapter, /data-form-mode=\{config\.mode\}/);
assert.match(adapter, /data-form-environment=\{config\.environmentRole\}/);
assert.match(adapter, /data-jotform-iframe-frame/);
assert.match(adapter, /data-jotform-iframe-fallback hidden aria-live="polite" role="status"/);
assert.match(adapter, /<noscript>/);