Skip to content

Commit

Permalink
Fix links to home for changelog
Browse files Browse the repository at this point in the history
  • Loading branch information
ngiger committed Dec 7, 2015
1 parent 88e46a2 commit a1350c3
Show file tree
Hide file tree
Showing 6 changed files with 37 additions and 18 deletions.
5 changes: 0 additions & 5 deletions spec/admin_spec.rb
Expand Up @@ -57,8 +57,6 @@ def session_uniq_email
credit org.oddb.download
)
def create_or_update_user(email = session_uniq_email, yus_rights= ['yus_privileges[login|org.oddb.CompanyUser]'])
@browser.goto OddbUrl
login
@browser.link(:text=>'Admin').click
@browser.link(:text=>'Benutzer').click
@browser.button(:name => 'new_user').click
Expand All @@ -74,7 +72,6 @@ def create_or_update_user(email = session_uniq_email, yus_rights= ['yus_privileg
yus_rights.each {|right| @browser.checkbox(:name => right).set }
@browser.button(:name => 'update').click
@browser.goto OddbUrl
login
@browser.link(:text=>'Admin').click
@browser.link(:text=>'Benutzer').click
expect(@browser.link(:text => /#{email}/).exists?).to eq(true)
Expand Down Expand Up @@ -133,8 +130,6 @@ def check_sort(link_name)
|link_name|
it "should be possible to sort users by #{link_name.sub('th_','')}" do
pending # does not work (september 2014)
@browser.goto OddbUrl
login
@browser.link(:text=>'Admin').click
@browser.link(:text=>'Benutzer').click
check_sort(link_name)
Expand Down
2 changes: 1 addition & 1 deletion spec/evidentia_spec.rb
Expand Up @@ -49,7 +49,7 @@ def select_product_by_trademark(name)
drugs.each_with_index{ |drug, index| first_B = index if /^.*#{gal_group}.* B$/im.match(drug)}; first_B
last_SL_SG = -1
drugs.each_with_index{ |drug, index| last_SL_SG = index if /^.*#{gal_group}.* SL \/ SG/im.match(drug)}; last_SL_SG
puts "#{@browser.url} #{gal_group}: #{drugs.size} drugs first_B is #{first_B} last_SL #{last_SL} last_SL_SG #{last_SL_SG}"
# puts "#{@browser.url} #{gal_group}: #{drugs.size} drugs first_B is #{first_B} last_SL #{last_SL} last_SL_SG #{last_SL_SG}"
expect(last_SL).not_to eql -1
expect(last_SL_SG).not_to eql -1
expect(first_B).not_to eql -1
Expand Down
40 changes: 35 additions & 5 deletions spec/snapback_spec.rb
Expand Up @@ -48,7 +48,7 @@
current = current.next_step
break unless current
end
puts "We have #{nr_tests} test steps"
# puts "We have #{nr_tests} test steps"

class SnapbackTestStep
def to_s
Expand All @@ -68,20 +68,44 @@ def search_item(search_type, search_value)
@browser.text_field(:name, "search_query").send_keys :enter
end

def check_home_links
@browser.links.find_all{|x| x.text.eql? 'Home' }.each do |link|
home_pattern = /\/home|/
# puts "link #{link.text} #{link.href}"
# binding.pry unless link.exist?
# binding.pry unless home_pattern.match(link.href)
expect(link.exist?).to be true
expect(link.href).to match home_pattern
end
end

it "should always have the correct home link" do
@browser.goto(OddbUrl + '/de/gcc' + diff_url)
check_home_links
link = @browser.link(:text => /Fachinformation zu/)
expect(link.exist?).to be true
link.click
check_home_links
end

it "should have a working link to Änderungen from the diff" do
@browser.goto(OddbUrl + '/de/gcc' + diff_url)
check_home_links
link = @browser.link(:text => Date_Regexp)
expect(link.exist?).to be true
saved_url = @browser.url.to_s.clone
saved_text = @browser.text
link.click
check_home_links
link = @browser.link(:text => /Änderungen/)
expect(link.exist?).to be true
link.click
check_home_links
expect(@browser.url.to_s).to eql saved_url.to_s
expect(@browser.text[0..100]).to eql saved_text[0..100]
expect(@browser.text).to eql saved_text
end

it "should allow going back, then forward" do
current= FirstTest
nr = 1
Expand All @@ -91,12 +115,13 @@ def search_item(search_type, search_value)
current = current.next_step
while current
nr += 1
puts "\nRunning test step #{nr}\n #{current.inspect}"
# puts "\nRunning test step #{nr}\n #{current.inspect}"
link = @browser.link(:text => current.link_to_click)
puts "#{nr}: Clicking link #{current.link_to_click} exist? #{link.exist?}"
# puts "#{nr}: Clicking link #{current.link_to_click} exist? #{link.exist?}"
expect(link.exist?).to be true
link.click
puts "#{nr}: #{__LINE__}: Got URL #{@browser.url} \n expecting #{current.expect_url}"
check_home_links
# puts "#{nr}: #{__LINE__}: Got URL #{@browser.url} \n expecting #{current.expect_url}"
expect(@browser.url).to match current.expect_url
if nr > 2 # TODO: Fix failure in nr == 2!!!
saved_text = @browser.text
Expand Down Expand Up @@ -126,19 +151,22 @@ def search_item(search_type, search_value)
expect(link.exist?).to be true
@prev_url = @browser.url.clone
link.click
check_home_links
current = current.next_step
end
home_link = @browser.link(:text => 'Home')
expect(home_link.exist?).to be true
saved_text = @browser.text
saved_url = @browser.url
home_link.click
check_home_links
if @browser.url.eql?(OddbUrl)
expect(@browser.url).to eql? OddbUrl
else
expect(@browser.url).to match /\/home\/|\/home_drugs\//
end
@browser.back
check_home_links
expect(@browser.url).to eql saved_url
expect(@browser.text[0..100]).to eql saved_text[0..100] # fail with less verbose output
expect(@browser.text).to eql saved_text
Expand All @@ -149,6 +177,7 @@ def search_item(search_type, search_value)
if @browser.link(:name, 'drugs').exists?
@browser.link(:name, 'drugs').click; small_delay
end
check_home_links
nr = 0
current= FirstTest
prev_url = nil
Expand Down Expand Up @@ -177,7 +206,7 @@ def search_item(search_type, search_value)
link = @browser.link(:href => FI_Link)
iksnr = FI_Link.match(link.href)[1]
link.click

check_home_links
steps = @browser.tds.find_all{ |x| x.class_name.eql? 'th-pointersteps'}
text = steps.collect{ |y| y.text }.join('').clone
expect(text).to match /Sie befinden sich/
Expand All @@ -202,6 +231,7 @@ def search_item(search_type, search_value)
end

def check_pointer_steps(expected, line = nil)
check_home_links
steps = @browser.elements.find_all{ |x| x.class_name.eql? 'th-pointersteps'}
text = steps.collect{ |y| y.text }.join(',').clone
puts "#{__LINE__}: #{Time.now} Pointersteps are #{text}\n should #{expected} are #{expected.match(text).inspect}"
Expand Down
1 change: 0 additions & 1 deletion src/state/drugs/fachinfo.rb
Expand Up @@ -63,7 +63,6 @@ def init
VIEW = View::Drugs::FachinfoDocumentChangelogs
LIMITED = false
FILTER_THRESHOLD = 10
SNAPBACK_EVENT = :home_drugs
end
class FachinfoDocumentChangelogItem < State::Drugs::Global
class FachinfoDocumentChangelogItemWrapper < SimpleDelegator
Expand Down
1 change: 0 additions & 1 deletion src/view/drugs/fachinfo_change_logs.rb
Expand Up @@ -133,7 +133,6 @@ def initialize(model, session, container)
end
end
class FachinfoDocumentChangelogs < View::PrivateTemplate
SNAPBACK_EVENT = :result
CONTENT = View::Drugs::FachinfoDocumentChangelogsComposite
def initialize(model, session, container=nil)
# latest changes must come first!
Expand Down
6 changes: 1 addition & 5 deletions src/view/searchbar.rb
Expand Up @@ -179,11 +179,7 @@ def to_html(context, *args)
end
@session.set_persistent_user_input(:drugs, @session.choosen_drugs)
if @session.request_path and @session.request_path.match(/fachinfo_search/)
if false and @session.choosen_drugs.size > 0
target = @session.lookandfeel._event_url(:fachinfo_search, [:ean, @session.choosen_drugs.keys, :ajax_matches, args ].flatten)
else
target = @session.lookandfeel._event_url(:ajax_matches, args)
end
target = @session.lookandfeel._event_url(:ajax_matches, args)
html = context.div 'data-dojo-type' => 'dojox.data.JsonRestStore',
'jsId' => 'search_matches',
'idAttribute' => 'drug',
Expand Down

0 comments on commit a1350c3

Please sign in to comment.