The default `date_select` used in fields presents an accessibility issue, because in generates three select controls but only one label. That means that there are two controls without a label. So we're using a date field instead. This type is field is supported by about 99% of the browsers, and we've already got JavaScript code converting this field to a jQuery UI datepicker in case the browser doesn't support date fields. Note that, since we no longer need to parse the three date fields into one, we can simplify the code in both the models and the tests. Another slight improvement is that, previously, we couldn't restrict the month and day controls in order to set the minimum date, so the maximum selectable date was always the 31st of December of the year set by the minimum age setting. As seen in the component test, now that we use only one field, we can set a specific date as the maximum one.
59 lines
1.6 KiB
Ruby
59 lines
1.6 KiB
Ruby
module Verifications
|
|
def verify_residence
|
|
select "DNI", from: "residence_document_type"
|
|
fill_in "residence_document_number", with: "12345678Z"
|
|
fill_in "residence_date_of_birth", with: Date.new(1980, 12, 31)
|
|
|
|
fill_in "residence_postal_code", with: "28013"
|
|
check "residence_terms_of_service"
|
|
|
|
click_button "new_residence_submit"
|
|
expect(page).to have_content I18n.t("verification.residence.create.flash.success")
|
|
end
|
|
|
|
def officing_verify_residence
|
|
select "DNI", from: "residence_document_type"
|
|
fill_in "residence_document_number", with: "12345678Z"
|
|
fill_in "residence_year_of_birth", with: "1980"
|
|
|
|
click_button "Validate document"
|
|
|
|
expect(page).to have_content "Document verified with Census"
|
|
end
|
|
|
|
def expect_badge_for(resource_name, resource)
|
|
within("##{resource_name}_#{resource.id}") do
|
|
expect(page).to have_css ".label.round"
|
|
expect(page).to have_content "Employee"
|
|
end
|
|
end
|
|
|
|
def expect_no_badge_for(resource_name, resource)
|
|
within("##{resource_name}_#{resource.id}") do
|
|
expect(page).not_to have_css ".label.round"
|
|
expect(page).not_to have_content "Employee"
|
|
end
|
|
end
|
|
|
|
def fill_in_ckeditor(label, with:)
|
|
locator = find("label", text: label)[:for]
|
|
|
|
until page.execute_script("return CKEDITOR.instances.#{locator}.status === 'ready';") do
|
|
sleep 0.01
|
|
end
|
|
|
|
within("#cke_#{locator}") do
|
|
within_frame(0) { find("body").set(with) }
|
|
end
|
|
end
|
|
|
|
def fill_in_markdown_editor(label, with:)
|
|
click_link "Launch text editor"
|
|
fill_in label, with: with
|
|
|
|
within(".fullscreen") do
|
|
click_link "Close text editor"
|
|
end
|
|
end
|
|
end
|