Skip to content

DF-1193: Add allowCopy service, repository and Postman integration tests - #890

Draft
nayij wants to merge 2 commits into
mainfrom
test/DF-1193-allow-copy-tests
Draft

nayij wants to merge 2 commits into
mainfrom
test/DF-1193-allow-copy-tests

Conversation

@nayij

@nayij nayij commented Nov 6, 2026

Copy link
Copy Markdown
Contributor

Adds tests for allowCopy (DF-1193, "Reuse previous answers") that the unit tests from #878 left out. Tests only, no production code changes.

Unit tests

form-definition-repository.test.js (updateOption, which goes through modifyDraft and the real V2 validation):

  • turning allowCopy on saves metadata.options.allowCopy: true, turns on the reference number, and switches the summary page to SummaryPageWithConfirmationEmailController, leaving the question pages unchanged
  • turning it off saves allowCopy: false and keeps the reference number and confirmation email on

options.test.js (updateOptionOnDraftDefinition):

  • for 'true' and 'false', the value is passed to the repository, returned as { option: { allowCopy } }, and published in the FORM_UPDATED / UPDATE_OPTION audit event
  • if saving fails, the audit isn't updated and no event is published

Postman integration tests

Ten requests added before "Save secret", on the go-live form:

  1. turning allowCopy on returns 200, and the draft has allowCopy, the reference number, the confirmation email summary page, and $$__formVersion
  2. turning the reference number off while allowCopy is on returns 400 InvalidFormDefinitionError, and the draft is unchanged
  3. allowCopy is still set on the live definition after create-live, and on the new draft after create-draft
  4. turning allowCopy off keeps the reference number and confirmation email

Testing

  • npx jest: 51 suites, 962 tests pass. ESLint, Prettier and tsc are clean.
  • Temporarily turning off the confirmation email switch in modifyUpdateOption makes the new "turned on" repository test fail.
  • Newman run locally against the integration compose stack: 58 requests, 61 assertions, 0 failures. Host ports were removed locally to avoid clashing with other services, so CI's own run hasn't happened yet.

Not covered here

Turning allowCopy on fails when the summary page uses the legacy ./pages/summary.js controller path. enableConfirmationEmail only matches ControllerType.Summary exactly, while the validator accepts legacy paths through controllerNameFromPath. That needs a code fix, so it isn't in this PR.

nayij added 2 commits November 6, 2026 13:52
Cover saving allowCopy through the real draft update path, the audit
event payload for each value, and that a failed save publishes nothing.

The Postman collection now checks that turning allowCopy on also turns
on the reference number and confirmation email, that turning the
reference number off is rejected and not saved, that allowCopy survives
create-live and create-draft, and that turning it off keeps both settings.
@sonarqubecloud

sonarqubecloud Bot commented Nov 6, 2026

Copy link
Copy Markdown

@nayij
nayij marked this pull request as draft November 6, 2026 13:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant