refactor(forms): enable approved Form A placements by default

This commit is contained in:
DeCentN2Madness committed 2026-10-30 15:08:02 -07:00
1 parent 55adb79705
commit 95c5f229f5
41 files changed
+862 -523

No files matched your search

+35 -4
View File
@@ -1,6 +1,6 @@
/**
* Guarded consultation-only Form A browser regression.
* Run after an explicitly gated isolated-test build. Every Jotform request is
* Run after a normal live build. Every Jotform request is
* fulfilled or aborted locally; no Jotform request is transmitted.
*/
import { randomBytes } from 'node:crypto';
@@ -14,6 +14,8 @@ import { spawn } from 'node:child_process';
import { fileURLToPath, pathToFileURL } from 'node:url';
import { setTimeout as delay } from 'node:timers/promises';
const forms = process.argv.find(a => a.startsWith('--forms='))?.split('=')[1] ?? 'live';
assert.ok(['live', 'off', 'mock'].includes(forms));
const root = fileURLToPath(new URL('../', import.meta.url));
const moduleName = process.env.PLAYWRIGHT_MODULE
? pathToFileURL(path.resolve(process.env.PLAYWRIGHT_MODULE)).href
@@ -31,7 +33,7 @@ const routes = [
{ route: '/es/learner-social-club', locale: 'es', drawer: true, screenshot: 'es-learner-social-club' },
];
const widths = [320, 390, 768, 1440];
const evidence = { routes, widths, checks: 0, blocked: [], jotformAttempts: [], screenshots: [], fallbackChecks: [], status: 'failed' };
const evidence = { forms, routes, widths, checks: 0, blocked: [], jotformAttempts: [], screenshots: [], fallbackChecks: [], status: 'failed' };
const reserve = net.createServer();
await new Promise((resolve, reject) => { reserve.once('error', reject); reserve.listen(0, '127.0.0.1', resolve); });
const port = reserve.address().port;
@@ -93,7 +95,7 @@ try {
return route.abort();
});
};
if (!process.argv.includes('--portal-only') && !process.argv.includes('--correction-only')) {
if (forms === 'live' && !process.argv.includes('--portal-only') && !process.argv.includes('--correction-only')) {
for (const width of widths) {
for (const target of routes.filter((r) => r.drawer)) {
const context = await browser.newContext({ viewport: { width, height: 844 }, serviceWorkers: 'block', reducedMotion: 'reduce' });
@@ -196,7 +198,7 @@ try {
evidence.checks++;
await backContext.close();
}
if (!process.argv.includes('--portal-only')) {
if (forms === 'live' && !process.argv.includes('--portal-only')) {
// Completion messages originate from a locally fulfilled cross-origin frame.
// No fixture submits anything; malformed browser envelopes are injected only in tests.
for (const locale of ['en', 'es']) {
@@ -282,6 +284,35 @@ try {
await ctx.close();
}
}
if (forms !== 'live') {
for (const width of [390, 1440]) for (const target of routes.filter(r => r.drawer)) {
const ctx = await browser.newContext({ viewport: { width, height: 900 }, serviceWorkers: 'block', reducedMotion: 'reduce' });
await guard(ctx);
const p = await ctx.newPage();
await p.clock.install({ time: new Date('2026-10-30T12:00:00Z') });
await p.clock.pauseAt(new Date('2026-10-30T12:00:01Z'));
await p.goto(origin + target.route, { waitUntil: 'domcontentloaded' });
assert.equal(await p.locator('iframe[data-jotform-iframe-frame]').count(), 0);
await p.evaluate(() => scrollTo({ top: document.documentElement.scrollHeight, behavior: 'instant' }));
await p.clock.runFor(11000);
const dialog = p.locator('[data-service-inquiry-drawer]');
if (forms === 'off') {
assert.equal(await dialog.evaluate(d => d.open), false, 'off never auto-opens');
const destination = target.locale === 'es' ? '/es/client-consultation' : '/client-consultation';
const cta = p.locator('main a[href="' + destination + '"]').first();
assert.ok(await cta.count());
await cta.click();
await p.waitForURL(origin + destination);
} else {
assert.equal(await dialog.evaluate(d => d.open), true, 'existing synthetic drawer remains available');
assert.ok(await dialog.locator('[data-form-mode="mock"]').count());
assert.equal(await dialog.locator('form').count(), 0);
}
assert.equal(evidence.jotformAttempts.length, 0);
evidence.checks++;
await ctx.close();
}
}
// Actual portal UI with synthetic encrypted response fixtures, never real private source.
for (const width of widths) {
const ctx = await browser.newContext({ viewport: { width, height: 844 }, serviceWorkers: 'block' }); await guard(ctx, true);