diff --git a/features/step_definitions/context.rb b/features/step_definitions/context.rb index 2ab48061..52adc0f3 100644 --- a/features/step_definitions/context.rb +++ b/features/step_definitions/context.rb @@ -131,3 +131,19 @@ Soit("un document que l'on consulte") do visit '/146e6e8442f0405b721b79357d00d0a1' end + +Soit("{string} la langue préférée configurée dans le navigateur") do |language| + page.driver.add_headers("Accept-Language" => language) +end + +Soit('un texte flottant avec la balise title {string} est présent') do |text| + expect(page).to have_selector("title", text: /#{text}/i, visible: false) +end + +Soit('un texte flottant avec l’attribut title {string} est présent') do |text| + expect(page).to have_selector("[title='#{text}']") +end + +Soit('un placeholder contenant {string} est présent') do |text| + expect(page).to have_selector("input[placeholder='#{text}']") +end \ No newline at end of file diff --git a/features/step_definitions/event.rb b/features/step_definitions/event.rb index 958907f7..aa606f5f 100644 --- a/features/step_definitions/event.rb +++ b/features/step_definitions/event.rb @@ -56,3 +56,15 @@ click_on_icon('sources .create-document') end +Quand("je choisis {string} comme langue préférée configurée dans le navigateur et que je rafraichisse la page") do |language| + page.driver.add_headers("Accept-Language" => language) + visit current_path + sleep 2 +end + +Quand("je choisis {string} comme langue préférée configurée dans le navigateur, que je rafraichisse la page et que {string} une des gloses ouverte") do |language, title| + page.driver.add_headers("Accept-Language" => language) + visit current_path + sleep 2 + click_on_icon_next_to('open', title) +end diff --git a/features/step_definitions/outcome.rb b/features/step_definitions/outcome.rb index f9c945cc..14a69dbd 100644 --- a/features/step_definitions/outcome.rb +++ b/features/step_definitions/outcome.rb @@ -85,4 +85,10 @@ Alors("je ne vois pas le document intitulé {string}") do |title| expect(page).not_to have_content(title) +end + +Soit('la page contient') do |table| + table.raw.flatten.each do |localization| + expect(page).to have_content localization + end end \ No newline at end of file diff --git a/features/support/env.rb b/features/support/env.rb index e25f6f62..07f20a6b 100644 --- a/features/support/env.rb +++ b/features/support/env.rb @@ -2,7 +2,7 @@ require 'capybara/cuprite' Before do - Capybara.current_session.driver.add_headers("Accept-Language" => "fr") + Capybara.current_session.driver.add_headers("Accept-Language" => "en") end Capybara.run_server = false Capybara.default_driver = :cuprite @@ -36,10 +36,17 @@ def have_image(alternative_text) end def sign_in(username, password) - fill_in placeholder: "Username", with: username - fill_in placeholder: 'Password', with: password - click_on 'Sign in' - expect(page).to have_content username + if page.has_content?('Sign in') + fill_in placeholder: "Username", with: username + fill_in placeholder: 'Password', with: password + click_on 'Sign in' + expect(page).to have_content username + else + fill_in placeholder: "Nom d’utilisateur", with: username + fill_in placeholder: 'Mot de passe', with: password + click_on 'Se connecter' + expect(page).to have_content username + end end def sign_out