Skip to content

Commit

Permalink
TEST: The user interface should be localized in French (see #146)
Browse files Browse the repository at this point in the history
Co-authored-by: vernet-william <[email protected]>
  • Loading branch information
ToGoSleep and vernet-william committed Jun 18, 2024
1 parent ada9db1 commit 1172028
Show file tree
Hide file tree
Showing 4 changed files with 45 additions and 4 deletions.
16 changes: 16 additions & 0 deletions features/step_definitions/context.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
12 changes: 12 additions & 0 deletions features/step_definitions/event.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
6 changes: 6 additions & 0 deletions features/step_definitions/outcome.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
15 changes: 11 additions & 4 deletions features/support/env.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 1172028

Please sign in to comment.