fix(forms): close completed drawers and restore portal styling

This commit is contained in:
DeCentN2Madness committed 2026-10-30 14:21:27 -07:00
1 parent e97f0ea9b4
commit 55adb79705
15 files changed
+598 -9

No files matched your search

+30
View File
@@ -8,6 +8,36 @@ import { isSuppressed, reachedHalf, suppressionDuration } from '../src/utils/dra
import { serviceInquiryCopy } from '../src/data/service-inquiry.ts';
import { decryptPortalStream, encryptPortalStream, validatePortalPayload, portalAlgorithm } from '../src/utils/portal-crypto.mjs';
import { collectResource, resourceReferences, rewriteResources } from './portal-resources.mjs';
import { isFormACompletion } from '../src/utils/jotform-completion.ts';
import { portalLinkPresentation } from '../src/utils/portal-presentation.ts';
test('completion envelope requires exact origin, active frame window and string Form A ID', () => {
const source = {};
const check = (event, frame, active) => isFormACompletion(event, frame, active,
'https://form.jotform.com/262946078314059?formContext=consultation&language=en');
const data = { action: 'submission-completed', formID: '262946078314059' };
const event = { origin: 'https://form.jotform.com', source, data };
assert.equal(check(event, source, true), true);
assert.equal(check({ ...event, data: JSON.stringify(data) }, source, true), true);
for (const change of [
{ origin: 'https://form.jotform.com.evil.invalid' }, { origin: 'null' }, { origin: 'http://form.jotform.com' },
{ source: {} }, { source: null }, { data: { ...data, formID: 'other' } },
{ data: { ...data, formID: 262946078314059 } }, { data: { ...data, action: 'load' } },
{ data: '{broken' }, { data: [] }, { data: null }, { data: 'x'.repeat(4097) },
]) assert.equal(check({ ...event, ...change }, source, true), false);
assert.equal(check(event, source, false), false);
assert.equal(check(event, null, true), false);
assert.equal(isFormACompletion(event, source, true, undefined), false);
assert.equal(isFormACompletion(event, source, true, 'broken'), false);
});
test('portal presentation translates only explicit button tokens/brand fills and contact protocols', () => {
assert.equal(portalLinkPresentation(['hs-button', 'untrusted'], '', 'https:'), 'portal-resource-button');
assert.equal(portalLinkPresentation([], 'rgb(255, 189, 89)', 'https:'), 'portal-resource-button');
assert.equal(portalLinkPresentation(['arbitrary'], 'url(https://example.invalid)', 'https:'), undefined);
assert.equal(portalLinkPresentation([], '', 'mailto:'), 'portal-contact-link');
assert.equal(portalLinkPresentation([], '', 'tel:'), 'portal-contact-link');
});
test('global preference validates expiry, corrupted values and clock anomalies', () => {
const now = 10000000000;