|
| 1 | +require "rails_helper" |
| 2 | + |
| 3 | +describe "forms/make_language_live/confirmation.html.erb" do |
| 4 | + let(:has_welsh_translation) { false } |
| 5 | + let(:welsh_completed) { false } |
| 6 | + let(:go_to_make_welsh_live_input) { Forms::GoToMakeWelshLiveInput.new } |
| 7 | + let(:current_form) { OpenStruct.new(id: 1, name: "Form 1", name_cy: "Ffurflen 1", form_slug: "form-1", has_welsh_translation?: has_welsh_translation, welsh_completed:) } |
| 8 | + let(:language) { "en" } |
| 9 | + |
| 10 | + before do |
| 11 | + assign(:go_to_make_welsh_live_input, go_to_make_welsh_live_input) |
| 12 | + render template: "forms/make_language_live/confirmation", locals: { current_form:, confirmation_page_title: "Your form is live", confirmation_page_body: I18n.t("make_changes_live.confirmation.body_html").html_safe, language: } |
| 13 | + end |
| 14 | + |
| 15 | + context "when the language made live was English" do |
| 16 | + it "contains a confirmation panel with a title" do |
| 17 | + expect(rendered).to have_css(".govuk-panel--confirmation h1", text: /Your form is live/) |
| 18 | + end |
| 19 | + |
| 20 | + it "contains the URL of the live form" do |
| 21 | + expect(rendered).to have_text("runner-host/form/1/form-1") |
| 22 | + end |
| 23 | + |
| 24 | + it "contains a link to the live form details" do |
| 25 | + expect(rendered).to have_link("Continue to the live form’s details", href: live_form_path(1)) |
| 26 | + end |
| 27 | + |
| 28 | + it "displays form name as plain text" do |
| 29 | + expect(rendered).to have_css("h2", text: "English form name") |
| 30 | + expect(rendered).to have_css("p", text: "Form 1") |
| 31 | + expect(rendered).not_to have_css(".govuk-summary-list") |
| 32 | + end |
| 33 | + |
| 34 | + it "displays the Form URL heading and button text" do |
| 35 | + expect(rendered).to have_css("h2", text: t("make_live.confirmation.english_form_url")) |
| 36 | + expect(rendered).to have_css("[data-copy-button-text='#{t('make_live.confirmation.copy_english_url_to_clipboard')}']") |
| 37 | + end |
| 38 | + |
| 39 | + context "when the form has a completed Welsh version" do |
| 40 | + let(:has_welsh_translation) { true } |
| 41 | + let(:welsh_completed) { true } |
| 42 | + |
| 43 | + it "renders radio buttons for making the draft changes live" do |
| 44 | + expect(rendered).to have_css("legend", text: I18n.t("helpers.legend.forms_go_to_make_welsh_live_input.confirm")) |
| 45 | + expect(rendered).to have_field(t("helpers.label.forms_go_to_make_welsh_live_input.confirm_options.yes"), type: "radio") |
| 46 | + expect(rendered).to have_field(t("helpers.label.forms_go_to_make_welsh_live_input.confirm_options.no"), type: "radio") |
| 47 | + end |
| 48 | + end |
| 49 | + end |
| 50 | + |
| 51 | + context "when the language made live was Welsh" do |
| 52 | + let(:language) { "cy" } |
| 53 | + |
| 54 | + it "contains a confirmation panel with a title" do |
| 55 | + expect(rendered).to have_css(".govuk-panel--confirmation h1", text: /Your form is live/) |
| 56 | + end |
| 57 | + |
| 58 | + it "contains the URL of the live form" do |
| 59 | + expect(rendered).to have_text("runner-host/form/1/form-1.cy") |
| 60 | + end |
| 61 | + |
| 62 | + it "contains a link to the live form details" do |
| 63 | + expect(rendered).to have_link("Continue to the live form’s details", href: live_form_path(1)) |
| 64 | + end |
| 65 | + |
| 66 | + it "displays form name as plain text" do |
| 67 | + expect(rendered).to have_css("h2", text: "Welsh form name") |
| 68 | + expect(rendered).to have_css("p", text: "Ffurflen 1") |
| 69 | + expect(rendered).not_to have_css(".govuk-summary-list") |
| 70 | + end |
| 71 | + |
| 72 | + it "displays the Form URL heading and button text" do |
| 73 | + expect(rendered).to have_css("h2", text: t("make_live.confirmation.welsh_form_url")) |
| 74 | + expect(rendered).to have_css("[data-copy-button-text='#{t('make_live.confirmation.copy_welsh_url_to_clipboard')}']") |
| 75 | + end |
| 76 | + end |
| 77 | +end |
0 commit comments