diff --git a/craft/src/components/forms/ContactForm.toHtml.test.ts b/craft/src/components/forms/ContactForm.toHtml.test.ts index bdb091c..210dbcb 100644 --- a/craft/src/components/forms/ContactForm.toHtml.test.ts +++ b/craft/src/components/forms/ContactForm.toHtml.test.ts @@ -6,7 +6,7 @@ const toHtml = (ContactForm as any).toHtml; describe('ContactForm.toHtml relay wiring', () => { test('with recipientEmail: emits marker, placeholder action, honeypot', () => { const { html } = toHtml({ recipientEmail: 'a@b.com', thankYouUrl: '/thx', fields: [] }, ''); - expect(html).toMatch(//); + expect(html).toMatch(//); expect(html).toMatch(/action="__WHP_FORM_ACTION__F_[0-9a-z]+__"/); expect(html).toContain('method="POST"'); expect(html).toContain('name="_gotcha"'); @@ -244,7 +244,9 @@ describe('ContactForm.toHtml destination marker', () => { // if it has to be edited, every already-published site's forms have changed // shape and that is the thing to stop, not the test. const FROZEN_LEGACY_MARKER = - ''; + ''; + // (captcha="1" was added when captcha became mandatory on every relay form: that is the one deliberate + // shape change since 071f3447; the fid and everything else is unchanged.) const legacy = toHtml({ ...defaultProps, recipientEmail: 'a@example.com', thankYouUrl: '/thx' }, '', 'n1'); expect(legacy.html.startsWith(`${FROZEN_LEGACY_MARKER}
); }; @@ -64,7 +64,6 @@ FormContainer.craft = { method: 'POST', recipientEmail: '', thankYouUrl: '', - captcha: true, style: { padding: '24px', backgroundColor: tokenRef('bg'), @@ -91,7 +90,7 @@ FormContainer.craft = { padding: '24px', ...props.style, }); - const { useRelay, marker, actionAttr, honeypot } = relayFormWiring(props.recipientEmail, props.thankYouUrl, props.action, nodeId, undefined, props.captcha); + const { useRelay, marker, actionAttr, honeypot } = relayFormWiring(props.recipientEmail, props.thankYouUrl, props.action, nodeId); const method = useRelay ? 'POST' : sanitizeFormMethod(props.method); // relay requires POST const body = honeypot + childrenHtml; // honeypot as first child return { diff --git a/craft/src/components/forms/SubscribeForm.toHtml.test.ts b/craft/src/components/forms/SubscribeForm.toHtml.test.ts index 68fb15e..6775a1b 100644 --- a/craft/src/components/forms/SubscribeForm.toHtml.test.ts +++ b/craft/src/components/forms/SubscribeForm.toHtml.test.ts @@ -50,7 +50,7 @@ describe('SubscribeForm.toHtml is functional (not a dead POST)', () => { test('with recipientEmail: emits the relay marker, placeholder action, and honeypot -- a working submission path', () => { const { html } = toHtml({ recipientEmail: 'news@example.com', thankYouUrl: '/thanks' }, '', 'node-sub1'); - expect(html).toMatch(//); + expect(html).toMatch(//); expect(html).toMatch(/action="__WHP_FORM_ACTION__F_[0-9a-z]+__"/); expect(html).toContain('name="_gotcha"'); const mid = html.match(/id="(F_[0-9a-z]+)"/)![1]; diff --git a/craft/src/components/forms/SubscribeForm.tsx b/craft/src/components/forms/SubscribeForm.tsx index ebb9db4..efea748 100644 --- a/craft/src/components/forms/SubscribeForm.tsx +++ b/craft/src/components/forms/SubscribeForm.tsx @@ -2,7 +2,7 @@ import React, { CSSProperties } from 'react'; import { useNode, UserComponent } from '@craftjs/core'; import { cssPropsToString } from '../../utils/style-helpers'; import { CaptchaMock } from './CaptchaMock'; -import { relayFormWiring } from '../../utils/form-relay-wiring'; +import { relayFormWiring, isRelayWired } from '../../utils/form-relay-wiring'; import { escapeHtml, escapeAttr } from '../../utils/escape'; import { tokenRef } from '../../utils/tokens'; import { textOnSurface } from '../../utils/color'; @@ -26,7 +26,7 @@ interface SubscribeFormProps { * published form then has no working action at all, which is the bug * this prop exists to fix. */ recipientEmail?: string; - /** ALTCHA captcha (relay path). undefined = legacy design: no marker attr, stored flag untouched. */ + /** @deprecated Captcha is mandatory on relay forms. Old saved designs may still hold true/false here; it is ignored. */ captcha?: boolean; thankYouUrl?: string; animation?: string; @@ -43,7 +43,7 @@ export const SubscribeForm: UserComponent