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

+7 -3
View File
@@ -19,9 +19,11 @@ import { setTimeout as delay } from 'node:timers/promises';
const root = fileURLToPath(new URL('../', import.meta.url));
const moduleName = process.env.PLAYWRIGHT_MODULE ? pathToFileURL(path.resolve(process.env.PLAYWRIGHT_MODULE)).href : 'playwright';
const mode = process.env.FORM_A_IFRAME_BROWSER_MODE ?? 'off';
if (!['off', 'mock', 'isolated-test'].includes(mode)) throw new Error(`Unsupported Form A browser mode: ${mode}`);
if (!['off', 'mock', 'isolated-test', 'production'].includes(mode)) throw new Error(`Unsupported Form A browser mode: ${mode}`);
const expectedIframe = mode === 'isolated-test';
const expectedIframe = mode === 'isolated-test' || mode === 'production';
const expectedFormMode = mode === 'production' ? 'live' : 'isolated-test';
const expectedEnvironment = mode === 'production' ? 'production' : 'isolated-test';
const routes = [
{ route: '/contact', locale: 'en', context: 'contact', screenshot: 'contact' },
{ route: '/es/contact', locale: 'es', context: 'contact', screenshot: 'es-contact' },
@@ -91,7 +93,8 @@ try {
assert.equal(await iframe.getAttribute('title'), locale === 'es' ? 'Formulario de consultas generales de AIA' : 'AIA general enquiries form', route);
assert.equal(await iframe.getAttribute('referrerpolicy'), 'no-referrer', route);
assert.equal(await iframe.getAttribute('sandbox'), 'allow-forms allow-scripts allow-same-origin', route);
assert.equal(await page.locator('[data-jotform-form-a][data-form-mode="isolated-test"]').count(), 1, route);
assert.equal(await page.locator(`[data-jotform-form-a][data-form-mode="${expectedFormMode}"]`).count(), 1, route);
assert.equal(await page.locator(`[data-jotform-form-a][data-form-environment="${expectedEnvironment}"]`).count(), 1, route);
assert.equal(await page.locator(`[data-jotform-form-a][data-form-context="${formContext}"]`).count(), 1, route);
const frameBox = await iframe.boundingBox();
const expectedFrameHeight = formContext === 'contact'
@@ -152,6 +155,7 @@ try {
const response = await page.goto(origin + route, { waitUntil: 'domcontentloaded', timeout: 15000 });
assert.equal(response?.status(), 200, `${route} without JavaScript`);
assert.equal(await page.locator('[data-jotform-form-a] iframe').count(), 1, `${route} without JavaScript`);
assert.equal(await page.locator(`[data-jotform-form-a][data-form-mode="${expectedFormMode}"]`).count(), 1, `${route} without JavaScript`);
const iframe = page.locator('[data-jotform-form-a] iframe');
assert.equal(await iframe.evaluate((element) => element.innerHTML.trim()), '', `${route} without JavaScript should not place fallback content inside the iframe`);
const noscriptFallback = page.locator('[data-jotform-form-a] .jotform-iframe__fallback--noscript');