Skip to content

Commit

Permalink
UI test for Translation Function (#9856)
Browse files Browse the repository at this point in the history
* Tests not working

* Changing integration test to system test

* Yaay it works

Co-authored-by: imajit <[email protected]>
  • Loading branch information
imajit and imajit authored Aug 3, 2021
1 parent a54bf46 commit a578843
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 2 deletions.
2 changes: 1 addition & 1 deletion app/views/layouts/_header.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
<div class="collapse navbar-collapse" id="header-navbar-collapse">
<form class="form-inline mr-3" id="searchform" autocomplete="off">
<div class="input-group">
<input aria-label="Enter Search Query" type="text" id="searchform_input" class="form-control search-query typeahead" role="search" qryType="tags" placeholder="<%= translation('layout._header.search',{},false) %>" value="<%= params[:query] %>" required>
<input aria-label="Enter Search Query" type="text" id="searchform_input" class="form-control search-query typeahead" role="search" qryType="tags" placeholder="<%= translation('layout._header.search', {}, false) %>" value="<%= params[:query] %>" required>
<div class="input-group-append">
<button class="btn btn-light" type="submit" title="Search button" aria-label="Search Button"><i class="fa fa-search"></i></button>
</div>
Expand Down
2 changes: 1 addition & 1 deletion test/integration/I18n_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
require 'sanitize'

class I18nTest < ActionDispatch::IntegrationTest

test 'should choose i18n-locale for header partial' do
available_testing_locales.each do |lang|
# This test could use a rewrite. Two `get`s in succession?
Expand Down
17 changes: 17 additions & 0 deletions test/system/dashboard_test.rb
Original file line number Diff line number Diff line change
@@ -1,8 +1,25 @@
require "application_system_test_case"
require "i18n"

class DashboardTest < ApplicationSystemTestCase
Capybara.default_max_wait_time = 60

test 'should translate search input bar' do
available_testing_locales.each do |lang|
visit '/'
visit '/change_locale/'+lang.to_s
click_on I18n.t('layout._header.login.login_title', locale: lang)
fill_in("username-login", with: "Bob")
fill_in("password-signup", with: "secretive")
click_on I18n.t('user_sessions.new.log_in', locale: lang)
visit '/dashboard'
uid = users(:bob).id
visit '/profile/tags/create/'+uid.to_s+'?translationswitch=yes&name=translation-helper'
assert_selector(:xpath, './/input[@id="searchform_input"][contains(@placeholder,"Search")]')
visit '/logout'
end
end

test 'viewing the dashboard' do
visit '/'

Expand Down

0 comments on commit a578843

Please sign in to comment.