feat(forms): add isolated Form A consultation testing
This commit is contained in:
25 files changed
+1046
-253
No files matched your search
@@ -3,6 +3,7 @@ import fs from 'node:fs';
|
||||
import test from 'node:test';
|
||||
import {
|
||||
buildFormAIframeUrl,
|
||||
formAConsultationTestPlacements,
|
||||
formAIframeId,
|
||||
formAIframeOrigin,
|
||||
formAIframePlacements,
|
||||
@@ -15,6 +16,7 @@ const isolated = (overrides = {}) => ({
|
||||
rawMode: 'isolated-test',
|
||||
liveApproved: 'false',
|
||||
isolatedTestApproved: 'true',
|
||||
consultationTestApproved: 'false',
|
||||
productionApproved: 'false',
|
||||
environmentRole: 'isolated-test',
|
||||
allowIndexing: 'false',
|
||||
@@ -23,10 +25,18 @@ const isolated = (overrides = {}) => ({
|
||||
...overrides,
|
||||
});
|
||||
|
||||
const consultation = (overrides = {}) => isolated({
|
||||
consultationTestApproved: 'true',
|
||||
route: '/client-consultation',
|
||||
locale: 'en',
|
||||
...overrides,
|
||||
});
|
||||
|
||||
const production = (overrides = {}) => ({
|
||||
rawMode: 'live',
|
||||
liveApproved: 'true',
|
||||
isolatedTestApproved: 'false',
|
||||
consultationTestApproved: 'true',
|
||||
productionApproved: 'true',
|
||||
environmentRole: 'production',
|
||||
allowIndexing: 'true',
|
||||
@@ -50,6 +60,10 @@ test('Form A iframe uses only fixed, approved route parameters', () => {
|
||||
buildFormAIframeUrl('en', 'landing'),
|
||||
'https://form.jotform.com/262946078314059?formContext=landing&language=en',
|
||||
);
|
||||
assert.equal(
|
||||
buildFormAIframeUrl('es', 'consultation'),
|
||||
'https://form.jotform.com/262946078314059?formContext=consultation&language=es',
|
||||
);
|
||||
const english = resolveFormAIframe(isolated());
|
||||
const spanish = resolveFormAIframe(isolated({ route: '/es/contact', locale: 'es' }));
|
||||
assert.equal(english.fallbackText, 'If the embedded form does not load,');
|
||||
@@ -65,6 +79,17 @@ test('Form A iframe uses only fixed, approved route parameters', () => {
|
||||
'/lp/aba-private-pay',
|
||||
'/lp/early-intervention',
|
||||
]);
|
||||
assert.deepEqual(formAConsultationTestPlacements.map((placement) => placement.route), [
|
||||
'/client-consultation',
|
||||
'/es/client-consultation',
|
||||
'/schedule-consultation',
|
||||
'/aba-therapy',
|
||||
'/autism-evaluations',
|
||||
'/learner-social-club',
|
||||
'/es/aba-therapy',
|
||||
'/es/autism-evaluations',
|
||||
'/es/learner-social-club',
|
||||
]);
|
||||
});
|
||||
|
||||
test('Form A iframe requires every isolated-test or production approval gate', () => {
|
||||
@@ -103,9 +128,44 @@ test('Form A iframe requires every isolated-test or production approval gate', (
|
||||
assert.equal(formModeForRuntime(resolveFormMode('live', 'true')), 'off');
|
||||
});
|
||||
|
||||
test('Only the seven allowlisted placements can render the adapter, with no helper, tracking, or parent submission code', () => {
|
||||
test('consultation is isolated-test-only and requires its additional explicit approval', () => {
|
||||
const enabled = resolveFormAIframe(consultation());
|
||||
assert.equal(enabled.enabled, true);
|
||||
assert.equal(enabled.context, 'consultation');
|
||||
assert.equal(enabled.title, 'AIA consultation form');
|
||||
assert.equal(enabled.url, 'https://form.jotform.com/262946078314059?formContext=consultation&language=en');
|
||||
|
||||
const spanish = resolveFormAIframe(consultation({ route: '/es/client-consultation', locale: 'es' }));
|
||||
assert.equal(spanish.enabled, true);
|
||||
assert.equal(spanish.title, 'Formulario de consulta de AIA');
|
||||
assert.equal(spanish.url, 'https://form.jotform.com/262946078314059?formContext=consultation&language=es');
|
||||
|
||||
for (const placement of formAConsultationTestPlacements) {
|
||||
const config = resolveFormAIframe(consultation({ route: placement.route, locale: placement.locale }));
|
||||
assert.equal(config.enabled, true, placement.route);
|
||||
assert.equal(config.context, 'consultation', placement.route);
|
||||
assert.equal(config.url, buildFormAIframeUrl(placement.locale, 'consultation'), placement.route);
|
||||
}
|
||||
|
||||
assert.equal(resolveFormAIframe(isolated({ route: '/client-consultation' })).reason, 'consultation-test-not-approved');
|
||||
assert.equal(resolveFormAIframe(consultation({ consultationTestApproved: undefined })).reason, 'consultation-test-not-approved');
|
||||
assert.equal(resolveFormAIframe(consultation({ consultationTestApproved: 'yes' })).reason, 'consultation-test-not-approved');
|
||||
assert.equal(resolveFormAIframe(consultation({ rawMode: 'mock' })).reason, 'mode-not-authorized');
|
||||
assert.equal(resolveFormAIframe(consultation({ liveApproved: 'true' })).reason, 'live-approval-not-disabled');
|
||||
assert.equal(resolveFormAIframe(consultation({ isolatedTestApproved: 'false' })).reason, 'isolated-test-not-approved');
|
||||
assert.equal(resolveFormAIframe(consultation({ environmentRole: 'staging' })).reason, 'invalid-environment-role');
|
||||
assert.equal(resolveFormAIframe(consultation({ allowIndexing: 'true' })).reason, 'indexing-enabled');
|
||||
assert.equal(resolveFormAIframe(consultation({ route: '/es/aba-therapy', locale: 'en' })).reason, 'locale-not-authorized');
|
||||
assert.equal(resolveFormAIframe(production({ route: '/client-consultation' })).reason, 'route-not-authorized');
|
||||
assert.equal(resolveFormAIframe(production({ route: '/client-consultation', consultationTestApproved: 'true' })).reason, 'route-not-authorized');
|
||||
});
|
||||
|
||||
test('the adapter preserves seven production routes and supports the separate bilingual consultation test surface', () => {
|
||||
const contact = fs.readFileSync('src/components/pages/ContactPage.astro', 'utf8');
|
||||
const adapter = fs.readFileSync('src/components/JotformIframe.astro', 'utf8');
|
||||
const shell = fs.readFileSync('src/components/FormShell.astro', 'utf8');
|
||||
const drawer = fs.readFileSync('src/components/ServiceInquiryDrawer.astro', 'utf8');
|
||||
const layout = fs.readFileSync('src/layouts/PageLayout.astro', 'utf8');
|
||||
const campaign = fs.readFileSync('src/components/campaign/ConsultationForm.astro', 'utf8');
|
||||
const earlyIntervention = fs.readFileSync('src/components/campaign/EarlyInterventionPage.astro', 'utf8');
|
||||
|
||||
@@ -113,6 +173,7 @@ test('Only the seven allowlisted placements can render the adapter, with no help
|
||||
assert.match(contact, /route = lang === 'es' \? '\/es\/contact' : '\/contact'/);
|
||||
assert.match(contact, /JotformIframe/);
|
||||
assert.match(contact, /PUBLIC_AIA_FORM_A_PRODUCTION_APPROVED/);
|
||||
assert.match(contact, /PUBLIC_AIA_FORMS_CONSULTATION_TEST_APPROVED/);
|
||||
assert.match(campaign, /resolveFormAIframe/);
|
||||
assert.match(campaign, /JotformIframe/);
|
||||
assert.match(campaign, /PUBLIC_AIA_FORM_A_PRODUCTION_APPROVED/);
|
||||
@@ -125,16 +186,32 @@ test('Only the seven allowlisted placements can render the adapter, with no help
|
||||
assert.match(earlyIntervention, /route: '\/lp\/early-intervention'/);
|
||||
assert.match(earlyIntervention, /JotformIframe/);
|
||||
assert.match(earlyIntervention, /PUBLIC_AIA_FORM_A_PRODUCTION_APPROVED/);
|
||||
assert.match(earlyIntervention, /PUBLIC_AIA_FORMS_CONSULTATION_TEST_APPROVED/);
|
||||
assert.match(campaign, /PUBLIC_AIA_FORMS_CONSULTATION_TEST_APPROVED/);
|
||||
assert.match(shell, /resolveFormAIframe/);
|
||||
assert.match(shell, /PUBLIC_AIA_FORMS_CONSULTATION_TEST_APPROVED/);
|
||||
assert.match(shell, /JotformIframe/);
|
||||
assert.match(drawer, /lang: SupportedLocale/);
|
||||
assert.match(drawer, /data-service-inquiry-open/);
|
||||
assert.match(drawer, /data-explicit-activation/);
|
||||
assert.match(drawer, /deferUntilActivated/);
|
||||
assert.match(drawer, /aia:jotform-activate/);
|
||||
assert.match(drawer, /Cerrar el formulario de consulta/);
|
||||
assert.doesNotMatch(drawer, /No WAITLIST!|guarantee your child|now open for enrollment/i);
|
||||
assert.match(layout, /entry\.data\.lang === 'en' \|\| entry\.data\.lang === 'es'/);
|
||||
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-url/);
|
||||
assert.match(adapter, /data-jotform-deferred/);
|
||||
assert.match(adapter, /data-jotform-iframe-fallback hidden aria-live="polite" role="status"/);
|
||||
assert.match(adapter, /<noscript>/);
|
||||
assert.match(adapter, /fallbackTimeoutMs = 15_000/);
|
||||
assert.match(adapter, /frame\.addEventListener\('load', onLoad, \{ once: true \}\)/);
|
||||
assert.match(adapter, /document\.addEventListener\('astro:before-swap', dispose, \{ once: true \}\)/);
|
||||
assert.match(adapter, /container\.addEventListener\('aia:jotform-activate'/);
|
||||
assert.doesNotMatch(adapter, /set:html=|fallbackMarkup|escapeHtml\(/);
|
||||
assert.match(adapter, /target="_blank" rel="noopener noreferrer"/);
|
||||
assert.match(adapter, /--jotform-frame-height: 60rem/);
|
||||
@@ -143,6 +220,8 @@ test('Only the seven allowlisted placements can render the adapter, with no help
|
||||
assert.match(adapter, /\.jotform-iframe--embedded \{\s*--jotform-frame-height: 42rem/);
|
||||
assert.match(adapter, /\.jotform-iframe__frame \{\s*height: 68rem/);
|
||||
assert.match(adapter, /\.jotform-iframe--embedded \.jotform-iframe__frame \{\s*height: 50rem/);
|
||||
assert.match(adapter, /\.jotform-iframe--drawer \{\s*--jotform-frame-height: 72rem/);
|
||||
assert.match(adapter, /\.jotform-iframe--drawer \.jotform-iframe__frame \{\s*height: 82rem/);
|
||||
assert.doesNotMatch(adapter, /for-form-embed-handler|jotformEmbedHandler|onload=|postMessage|fetch\(|form\.submit|analytics|googletag/i);
|
||||
assert.doesNotMatch(campaign, /262946078314059/);
|
||||
});
|
||||
|
||||
Reference in new issue
Block a user