From bf026ea3a7713ae3ab8af45af12f96c90f64fd84 Mon Sep 17 00:00:00 2001 From: Laurence de Bruxelles Date: Tue, 7 Jul 2026 16:13:04 +0300 Subject: [PATCH 1/2] Add default for is_optional to the page model By default a question should be not optional and not repeatable. We shouldn't need to specify `is_optional: false` every time we create a `Page`. This commit updates the default in the database column, and updates our database seed to be less verbose. --- ...ge_column_default_for_pages_is_optional.rb | 5 +++ db/schema.rb | 2 +- db/seeds.rb | 34 ------------------- 3 files changed, 6 insertions(+), 35 deletions(-) create mode 100644 db/migrate/20260707132052_change_column_default_for_pages_is_optional.rb diff --git a/db/migrate/20260707132052_change_column_default_for_pages_is_optional.rb b/db/migrate/20260707132052_change_column_default_for_pages_is_optional.rb new file mode 100644 index 000000000..88894b370 --- /dev/null +++ b/db/migrate/20260707132052_change_column_default_for_pages_is_optional.rb @@ -0,0 +1,5 @@ +class ChangeColumnDefaultForPagesIsOptional < ActiveRecord::Migration[8.1] + def change + change_column_default :pages, :is_optional, from: nil, to: false + end +end diff --git a/db/schema.rb b/db/schema.rb index a419bb51d..2bfc5c277 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -276,7 +276,7 @@ t.bigint "form_id" t.text "guidance_markdown" t.text "hint_text" - t.boolean "is_optional", null: false + t.boolean "is_optional", default: false, null: false t.boolean "is_repeatable", default: false, null: false t.text "page_heading" t.integer "position" diff --git a/db/seeds.rb b/db/seeds.rb index 4a06fb129..a52e336c9 100644 --- a/db/seeds.rb +++ b/db/seeds.rb @@ -155,12 +155,10 @@ answer_settings: { input_type: "single_line", }, - is_optional: false, ), Page.create( question_text: "Number", answer_type: "number", - is_optional: false, ), Page.create( question_text: "Address", @@ -171,12 +169,10 @@ uk_address: true, }, }, - is_optional: false, ), Page.create( question_text: "Email address", answer_type: "email", - is_optional: false, ), Page.create( question_text: "Todays Date", @@ -184,17 +180,14 @@ answer_settings: { input_type: "other_date", }, - is_optional: false, ), Page.create( question_text: "National Insurance number", answer_type: "national_insurance_number", - is_optional: false, ), Page.create( question_text: "Phone number", answer_type: "phone_number", - is_optional: false, ), Page.create( question_text: "Selection from a list of options", @@ -240,7 +233,6 @@ answer_settings: { input_type: "single_line", }, - is_optional: false, ), ], question_section_completed: true, @@ -274,7 +266,6 @@ { "name": "No", value: "No" }, ], }, - is_optional: false, ), Page.create( question_text: "How many times have you filled out this form?", @@ -286,7 +277,6 @@ { "name": "More than once", value: "More than once" }, ], }, - is_optional: false, ), Page.create( question_text: "What’s your name?", @@ -295,14 +285,10 @@ input_type: "full_name", title_needed: false, }, - is_optional: false, - is_repeatable: false, ), Page.create( question_text: "What’s your email address?", answer_type: "email", - is_optional: false, - is_repeatable: false, ), Page.create( question_text: "What was the reference of your previous submission?", @@ -310,8 +296,6 @@ answer_settings: { input_type: "single_line", }, - is_optional: false, - is_repeatable: false, ), Page.create( question_text: "What’s your answer?", @@ -319,8 +303,6 @@ answer_settings: { input_type: "single_line", }, - is_optional: false, - is_repeatable: false, ), ], question_section_completed: true, @@ -423,15 +405,11 @@ input_type: "full_name", title_needed: false, }, - is_optional: false, - is_repeatable: false, ), Page.create( question_text: "What’s your email address?", question_text_cy: "Beth yw eich cyfeiriad e-bost?", answer_type: "email", - is_optional: false, - is_repeatable: false, page_heading: "Email", page_heading_cy: "E-bost", guidance_markdown: "We'll use your email to:\n\n- contact you if there are any issues with your submission\n\n- send you your digital licence", @@ -444,8 +422,6 @@ answer_settings: { input_type: "single_line", }, - is_optional: false, - is_repeatable: false, ), Page.create( question_text: "What’s your answer?", @@ -454,8 +430,6 @@ answer_settings: { input_type: "single_line", }, - is_optional: false, - is_repeatable: false, ), ], question_section_completed: true, @@ -492,7 +466,6 @@ { "name": "No", value: "No" }, ], }, - is_optional: false, ), Page.create( question_text: "Where do you currently live?", @@ -506,32 +479,26 @@ { "name": "Northern Ireland", value: "Northern Ireland" }, ], }, - is_optional: false, ), Page.create( question_text: "How many years have you lived in England?", answer_type: "number", - is_optional: false, ), Page.create( question_text: "How many years have you lived in Scotland?", answer_type: "number", - is_optional: false, ), Page.create( question_text: "How many years have you lived in Wales?", answer_type: "number", - is_optional: false, ), Page.create( question_text: "How many years have you lived in Northern Ireland?", answer_type: "number", - is_optional: false, ), Page.create( question_text: "How many years have you lived in the United Kingdom?", answer_type: "number", - is_optional: false, ), ], question_section_completed: true, @@ -599,7 +566,6 @@ input_type: "full_name", title_needed: false, }, - is_optional: false, ), ], question_section_completed: true, From 85f7266e28e55a6d76a4750d6bfd889eb533be17 Mon Sep 17 00:00:00 2001 From: Laurence de Bruxelles Date: Tue, 7 Jul 2026 16:06:48 +0300 Subject: [PATCH 2/2] Add smoke test form to database seed In each environment in AWS we have a smoke test form which is used by the tests in the forms-e2e-tests repo. This commit adds a form with the same setup as what is in the production environment to our database seed. We also add a smoke tests group to the database seed, again matching what we have in production. Note that the forms-e2e-tests repo can't use the "All question types form" for the smoke tests, as it currently doesn't know how to answer all question types. --- db/seeds.rb | 46 ++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 44 insertions(+), 2 deletions(-) diff --git a/db/seeds.rb b/db/seeds.rb index a52e336c9..71a28c1ff 100644 --- a/db/seeds.rb +++ b/db/seeds.rb @@ -136,6 +136,7 @@ # create some test groups end_to_end_group = Group.create! name: "End to end tests", organisation: gds, status: :active + smoke_test_group = Group.create! name: "Smoke tests", organisation: gds, status: :active test_group = Group.create! name: "Test Group", organisation: gds, creator: default_user, status: :active, send_filler_answers_enabled: true multiple_branches_test_group = Group.create! name: "Test Group with multiple branches", organisation: gds, creator: default_user, status: :active, multiple_branches_enabled: true Group.create! name: "Ministry of Tests forms", organisation: mot_org @@ -145,6 +146,46 @@ submission_email = ENV["EMAIL"].presence || `git config --get user.email`.strip.presence || "example@example.com" + smoke_test_form = Form.create!( + name: "Scheduled smoke test", + creator_id: nil, + pages: [ + Page.create( + question_text: "A text question", + hint_text: "No specific answer is required for the tests to pass", + answer_type: "text", + answer_settings: { + input_type: "single_line", + }, + ), + Page.create( + question_text: "A number question", + hint_text: "No specific answer is required for the tests to pass", + answer_type: "number", + ), + Page.create( + question_text: "A full name question", + hint_text: "No specific answer is required for the tests to pass", + answer_type: "name", + answer_settings: { + input_type: "full_name", + title_needed: false, + }, + ), + ], + question_section_completed: true, + declaration_markdown: "", + declaration_section_completed: true, + privacy_policy_url: "https://www.gov.uk/help/privacy-notice", + submission_email: "govuk-forms-automation-tests@digital.cabinet-office.gov.uk", + support_url: "https://www.forms.service.gov.uk", + support_url_text: "This form is for internal scheduled testing. Find out more about GOV.UK Forms.", + what_happens_next_markdown: "This form is for the scheduled smoke tests only", + share_preview_completed: true, + ) + smoke_test_form.set_task_status_service(TaskStatusService.new(form: smoke_test_form, current_user: nil)) + smoke_test_form.make_live! + all_question_types_form = Form.create!( name: "All question types form", creator_id: craig.id, @@ -583,8 +624,9 @@ copy_of_answers_form.make_live! # add forms to groups - GroupForm.create! group: end_to_end_group, form_id: all_question_types_form.id # All question types form - GroupForm.create! group: end_to_end_group, form_id: e2e_s3_forms.id # s3 submission test form + GroupForm.create! group: smoke_test_group, form_id: smoke_test_form.id # s3 submission test form + GroupForm.create! group: smoke_test_group, form_id: e2e_s3_forms.id # s3 submission test form + GroupForm.create! group: test_group, form_id: all_question_types_form.id # All question types form GroupForm.create! group: test_group, form_id: branch_route_form.id # Branch routing form GroupForm.create! group: test_group, form_id: none_of_the_above_form.id # None of the above form GroupForm.create! group: test_group, form_id: welsh_form.id # Welsh form