Commit 54cb1b0
Forms: Allow submitting form previews as test responses (#48057)
* Forms: Allow submitting form previews as test responses
Form preview now lets you submit the form to test the full submission
flow end to end. Responses created from preview are stored normally in
the inbox but flagged as test responses: clearly badged in the dashboard
list and detail panel, prefixed with [TEST] in the notification email
with a banner, excluded from the default CSV export, and excluded from
exports unless explicitly selected.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
* Reorder export options before test warning
Move CSVExport and GoogleDriveExport components above the selected-test warning and remove the duplicate render. The Google Drive export remains conditionally rendered when enabled and preserves the autoConnect prop. This reordering makes export controls visible before the warning about exporting test responses.
* Forms: Carry is_test via signed JWT source; a11y + unread-count polish
Follow-ups from review feedback on #48057:
- Replace the hidden-field + nonce injection in form preview rendering
with a flag baked into the signed JWT. Feedback_Source::get_current()
now reads Form_Preview::is_preview_mode() at render time and records
is_test=true on the source, which travels tamper-proof inside the
JWT to submission. JWTs issued before this change omit the flag and
continue to behave as regular submissions.
- Remove the now-unused inject_preview_submission_fields() helper,
verify_preview_submission() helper, and the three PREVIEW_SUBMIT_*
constants from Form_Preview.
- Drop the test-feedback special case in Feedback::save(); test
responses are now created as STATUS_UNREAD like any other response
so they contribute to the unread count.
- Add aria-label="Test response" to the inline Test badge in the
dashboard From column so screen readers get a complete label.
- Add two PHPUnit round-trip tests covering the JWT backward-compat
contract: a JWT issued in preview mode marks the decoded form as
a test submission; a JWT issued outside preview mode (or from a
cached HTML fragment predating this feature) decodes to a regular
submission.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
* Forms: Polish test-response UI per review feedback
- List view: move Test badge to end of the From row, switch to the
neutral white badge, and show the form title (linked to preview)
in the Source column instead of the Form Preview badge.
- Detail panel: drop the standalone banner row, render the Test
badge inline (right-aligned) next to name/email, and link the
form title in the Source row.
- Export modal: drop the bottom info notice, move the top notice
above the content card, and tone it down from warning to info.
- Email: replace the amber test-submission banner with a simple
heading line above the feedback body.
* Forms: Show "Form preview" as Source label for test responses
Revert to surfacing "Form preview" (sentence case) as the Source
label for test feedback in both the list Source column and the
detail panel, linked to the regenerated preview URL when available.
* Forms: Show "Form preview" source label in legacy inbox list too
Apply the same "Form preview" Source label + preview-URL link to
the legacy DataViews inbox list so test responses surface
consistently whether or not CFM is enabled.
* Forms: Restore amber notice for test-submission emails, title only
Bring back the amber notice block at the top of test-submission
emails, but drop the secondary explanatory sentence — just the
"Test submission from form preview" heading now.
* Forms: Move test-submission banner to very top of email
Pass the test-submission banner through wrap_message_in_html_tags
as a new optional argument and render it above the white card in
the email template, so the rest of the body still reads like a
normal submission email.
* Forms: Reword test-submission email banner heading
Swap the banner copy from "Test submission from form preview" to
"Test response via form preview" to match the terminology used in
the dashboard.
* Forms: Show "Form preview" as email metadata source for test responses
Override the Source row in the notification email metadata table
so test responses read as "Form preview" (no link), matching the
dashboard treatment, instead of the hosting page URL.
* Forms: Restore top-left alignment for single response header
Keep the original top-left alignment for the gravatar/name block in
the single response header. The Test badge keeps itself vertically
centered with alignSelf so test rows still look balanced.
* Forms: Add bottom spacing to export modal test-response notice
Wrap the test-response notice in a spacer div so it doesn't
butt up against the CSV export card below.
* Forms: Add "Form preview" to Source filter for test responses
Replace the planned separate "Response type" filter with a virtual
"Form preview" option injected at the top of the existing Source filter.
When selected, the source value "form_preview" is translated to is_test=true
on the query. Keeps filtering UX to a single pill and avoids the extra
filter chrome.
Also exposes is_test on the feedback REST collection (GET /feedback) and
stamps test submissions with the _feedback_is_test post meta on insert,
so the filter can scope at the database level without unpacking the
serialized source.
* Forms: Place "Test" badge inline with respondent name
Move the "Test" badge out of a marginLeft:auto span and into a row next
to the respondent name in both the response list and the single-response
inspector. The auto-margin pushed the badge to the cell's far edge, which
on narrow widths could overflow into the adjacent Date column.
* Forms: Restyle test-submission email banner to match WPDS Notice
Drop the 4px left-border accent in favor of the @wordpress/ui Notice
warning palette: 1px amber border, 8px radius, warm amber fill
(#fff7e0 / #d0b381), and 13px/20px body copy in #2e1900. Punctuate the
body copy ("Test response via form preview.") and add mobile-only side
margin so the banner aligns with the rest of the email content on
narrow viewports.
Also fold the export modal's test-response Notice into the same VStack
as the export options instead of wrapping it in a bespoke marginBottom
div, so the 24px spacing comes from the VStack like every other child.
* Forms: Swap export modal Notice to @wordpress/ui Notice component
Replace the legacy @wordpress/components Notice (status="info",
isDismissible) with the @wordpress/ui Notice.Root + Notice.Description
(intent="info") so the test-response warning in the Export responses
modal matches the rest of the new WPDS-based surfaces.
* Forms: Don't fail PHPUnit run on deprecations
The phpunit.11.xml.dist config sets failOnDeprecation="true", which on
PHP 8.5 treats the ReflectionProperty::setAccessible() deprecation as a
fatal signal — making the packages/forms test job exit non-zero even
when every assertion passes.
Pass --do-not-fail-on-deprecation to phpunit-select-config so the run
succeeds on deprecation notices, and --display-deprecations so they
still surface in the CI log for visibility.
* Forms: Guard ReflectionProperty::setAccessible() by PHP version
Replace the composer-level --do-not-fail-on-deprecation / --display-deprecations
workaround with a version-guarded call at the source. PHP 8.1 made
setAccessible() a no-op for all reflection objects and PHP 8.5 deprecates
calling it on ReflectionProperty, so on 8.1+ the package-supported branch
now skips the call entirely.
The 7.2–8.0 codepath still invokes setAccessible() so the test keeps
working against the package's minimum PHP.
* Forms: Drop changelog entry for the PHPUnit deprecation guard
The guard is purely a test-only change (never ships to users), so it
doesn't need a changelog entry.
---------
Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>1 parent 9c3b2ec commit 54cb1b0
22 files changed
Lines changed: 964 additions & 99 deletions
File tree
- projects/packages/forms
- changelog
- routes/responses
- src
- contact-form
- templates
- dashboard
- components
- export-responses
- inspector/response-meta
- hooks
- inbox/stage
- modules/form
- types
- tests/php/contact-form
Lines changed: 4 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
53 | 53 | | |
54 | 54 | | |
55 | 55 | | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
56 | 60 | | |
57 | 61 | | |
58 | 62 | | |
| |||
65 | 69 | | |
66 | 70 | | |
67 | 71 | | |
| 72 | + | |
68 | 73 | | |
69 | 74 | | |
70 | 75 | | |
| |||
303 | 308 | | |
304 | 309 | | |
305 | 310 | | |
306 | | - | |
| 311 | + | |
| 312 | + | |
| 313 | + | |
| 314 | + | |
| 315 | + | |
307 | 316 | | |
308 | 317 | | |
309 | 318 | | |
| |||
485 | 494 | | |
486 | 495 | | |
487 | 496 | | |
488 | | - | |
489 | | - | |
490 | | - | |
| 497 | + | |
| 498 | + | |
| 499 | + | |
| 500 | + | |
| 501 | + | |
| 502 | + | |
| 503 | + | |
| 504 | + | |
| 505 | + | |
| 506 | + | |
491 | 507 | | |
492 | 508 | | |
493 | 509 | | |
| |||
526 | 542 | | |
527 | 543 | | |
528 | 544 | | |
| 545 | + | |
| 546 | + | |
| 547 | + | |
| 548 | + | |
| 549 | + | |
| 550 | + | |
| 551 | + | |
| 552 | + | |
| 553 | + | |
| 554 | + | |
| 555 | + | |
| 556 | + | |
529 | 557 | | |
530 | 558 | | |
531 | 559 | | |
| |||
538 | 566 | | |
539 | 567 | | |
540 | 568 | | |
541 | | - | |
542 | | - | |
| 569 | + | |
| 570 | + | |
| 571 | + | |
| 572 | + | |
| 573 | + | |
| 574 | + | |
543 | 575 | | |
544 | 576 | | |
545 | 577 | | |
546 | 578 | | |
547 | 579 | | |
548 | | - | |
549 | | - | |
| 580 | + | |
| 581 | + | |
550 | 582 | | |
551 | 583 | | |
552 | 584 | | |
| |||
Lines changed: 73 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
373 | 373 | | |
374 | 374 | | |
375 | 375 | | |
| 376 | + | |
| 377 | + | |
| 378 | + | |
| 379 | + | |
| 380 | + | |
| 381 | + | |
376 | 382 | | |
377 | 383 | | |
378 | 384 | | |
| |||
477 | 483 | | |
478 | 484 | | |
479 | 485 | | |
| 486 | + | |
480 | 487 | | |
481 | 488 | | |
482 | 489 | | |
| |||
509 | 516 | | |
510 | 517 | | |
511 | 518 | | |
| 519 | + | |
| 520 | + | |
| 521 | + | |
| 522 | + | |
| 523 | + | |
| 524 | + | |
512 | 525 | | |
513 | 526 | | |
514 | 527 | | |
| |||
807 | 820 | | |
808 | 821 | | |
809 | 822 | | |
| 823 | + | |
| 824 | + | |
| 825 | + | |
| 826 | + | |
| 827 | + | |
| 828 | + | |
| 829 | + | |
| 830 | + | |
| 831 | + | |
| 832 | + | |
| 833 | + | |
| 834 | + | |
| 835 | + | |
| 836 | + | |
| 837 | + | |
| 838 | + | |
| 839 | + | |
| 840 | + | |
| 841 | + | |
| 842 | + | |
810 | 843 | | |
811 | 844 | | |
812 | 845 | | |
| |||
988 | 1021 | | |
989 | 1022 | | |
990 | 1023 | | |
| 1024 | + | |
| 1025 | + | |
| 1026 | + | |
| 1027 | + | |
| 1028 | + | |
| 1029 | + | |
| 1030 | + | |
| 1031 | + | |
| 1032 | + | |
| 1033 | + | |
| 1034 | + | |
| 1035 | + | |
| 1036 | + | |
| 1037 | + | |
| 1038 | + | |
991 | 1039 | | |
992 | 1040 | | |
993 | 1041 | | |
| |||
1080 | 1128 | | |
1081 | 1129 | | |
1082 | 1130 | | |
| 1131 | + | |
| 1132 | + | |
| 1133 | + | |
| 1134 | + | |
| 1135 | + | |
| 1136 | + | |
| 1137 | + | |
| 1138 | + | |
| 1139 | + | |
| 1140 | + | |
| 1141 | + | |
| 1142 | + | |
| 1143 | + | |
| 1144 | + | |
| 1145 | + | |
| 1146 | + | |
| 1147 | + | |
| 1148 | + | |
| 1149 | + | |
1083 | 1150 | | |
1084 | 1151 | | |
1085 | 1152 | | |
| |||
1149 | 1216 | | |
1150 | 1217 | | |
1151 | 1218 | | |
| 1219 | + | |
| 1220 | + | |
| 1221 | + | |
| 1222 | + | |
| 1223 | + | |
| 1224 | + | |
1152 | 1225 | | |
1153 | 1226 | | |
1154 | 1227 | | |
| |||
Lines changed: 25 additions & 9 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1607 | 1607 | | |
1608 | 1608 | | |
1609 | 1609 | | |
1610 | | - | |
1611 | | - | |
1612 | | - | |
1613 | | - | |
1614 | | - | |
1615 | 1610 | | |
1616 | 1611 | | |
1617 | 1612 | | |
| |||
1721 | 1716 | | |
1722 | 1717 | | |
1723 | 1718 | | |
| 1719 | + | |
| 1720 | + | |
| 1721 | + | |
| 1722 | + | |
| 1723 | + | |
| 1724 | + | |
| 1725 | + | |
| 1726 | + | |
1724 | 1727 | | |
1725 | 1728 | | |
1726 | 1729 | | |
| |||
2906 | 2909 | | |
2907 | 2910 | | |
2908 | 2911 | | |
2909 | | - | |
| 2912 | + | |
| 2913 | + | |
| 2914 | + | |
| 2915 | + | |
2910 | 2916 | | |
2911 | 2917 | | |
2912 | 2918 | | |
2913 | | - | |
| 2919 | + | |
2914 | 2920 | | |
2915 | 2921 | | |
2916 | 2922 | | |
| |||
2921 | 2927 | | |
2922 | 2928 | | |
2923 | 2929 | | |
| 2930 | + | |
| 2931 | + | |
| 2932 | + | |
| 2933 | + | |
| 2934 | + | |
2924 | 2935 | | |
2925 | 2936 | | |
2926 | 2937 | | |
| |||
3078 | 3089 | | |
3079 | 3090 | | |
3080 | 3091 | | |
3081 | | - | |
| 3092 | + | |
| 3093 | + | |
3082 | 3094 | | |
3083 | 3095 | | |
3084 | 3096 | | |
| |||
3125 | 3137 | | |
3126 | 3138 | | |
3127 | 3139 | | |
3128 | | - | |
| 3140 | + | |
| 3141 | + | |
| 3142 | + | |
| 3143 | + | |
| 3144 | + | |
3129 | 3145 | | |
3130 | 3146 | | |
3131 | 3147 | | |
| |||
0 commit comments