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..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, @@ -155,12 +196,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 +210,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 +221,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 +274,6 @@ answer_settings: { input_type: "single_line", }, - is_optional: false, ), ], question_section_completed: true, @@ -274,7 +307,6 @@ { "name": "No", value: "No" }, ], }, - is_optional: false, ), Page.create( question_text: "How many times have you filled out this form?", @@ -286,7 +318,6 @@ { "name": "More than once", value: "More than once" }, ], }, - is_optional: false, ), Page.create( question_text: "What’s your name?", @@ -295,14 +326,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 +337,6 @@ answer_settings: { input_type: "single_line", }, - is_optional: false, - is_repeatable: false, ), Page.create( question_text: "What’s your answer?", @@ -319,8 +344,6 @@ answer_settings: { input_type: "single_line", }, - is_optional: false, - is_repeatable: false, ), ], question_section_completed: true, @@ -423,15 +446,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 +463,6 @@ answer_settings: { input_type: "single_line", }, - is_optional: false, - is_repeatable: false, ), Page.create( question_text: "What’s your answer?", @@ -454,8 +471,6 @@ answer_settings: { input_type: "single_line", }, - is_optional: false, - is_repeatable: false, ), ], question_section_completed: true, @@ -492,7 +507,6 @@ { "name": "No", value: "No" }, ], }, - is_optional: false, ), Page.create( question_text: "Where do you currently live?", @@ -506,32 +520,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 +607,6 @@ input_type: "full_name", title_needed: false, }, - is_optional: false, ), ], question_section_completed: true, @@ -617,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