New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
AO3-4702 Test autocomplete #2601
Changes from 5 commits
eb73392
c1685c4
bbe2d48
2b8702b
7365d89
930c626
56309e8
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -36,7 +36,9 @@ def pseud | |
private | ||
def tag_output(search_param, tag_type) | ||
tags = Tag.autocomplete_lookup(:search_param => search_param, :autocomplete_prefix => "autocomplete_tag_#{tag_type}") | ||
render_output tags.map {|r| Tag.name_from_autocomplete(r)} | ||
output = tags.map {|r| Tag.name_from_autocomplete(r)} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Space between { and | missing. |
||
Rails.cache.write('/v1/autocomplete_hack/last_result', output ) if ENV["RAILS_ENV"] == "test" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Space inside parentheses detected. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Space inside parentheses detected. |
||
render_output output | ||
end | ||
public | ||
# these are all basically duplicates but make our calls to autocomplete more readable | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -33,6 +33,11 @@ def with_scope(locator) | |
page.driver.browser.url_whitelist = ['http://127.0.0.1'] | ||
end | ||
|
||
When /^I type in "([^"]*)" with "([^"]*)"$/ do |selector,contents| | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Space missing after comma. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Space missing after comma. |
||
Rails.cache.delete('/v1/autocomplete_hack/last_result') | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Use 2 (not 1) spaces for indentation. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Use 2 (not 1) spaces for indentation. |
||
find(selector).native.send_keys(contents) | ||
end | ||
|
||
When /^I clear the network traffic$/ do | ||
page.driver.clear_network_traffic | ||
end | ||
|
@@ -120,6 +125,23 @@ def with_scope(locator) | |
}.to raise_error | ||
end | ||
|
||
Then(/^I should see "([^"]*)" in autocomplete hack$/) do |answer| | ||
# This breaks the rule https://github.com/cucumber/cucumber/wiki/Given-When-Then | ||
# While it might be tempting to implement Then steps to just look in the database | ||
# resist the temptation. You should only verify outcome that is observable for | ||
# the user (or external system) and databases usually are not. | ||
result = false | ||
(1..20).each do | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Use Integer#times for a simple loop which iterates a fixed number of times. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Use Integer#times for a simple loop which iterates a fixed number of times. |
||
next unless Rails.cache.read('/v1/autocomplete_hack/last_result').nil? | ||
sleep 1 | ||
end | ||
assert !Rails.cache.read('/v1/autocomplete_hack/last_result').nil? | ||
Rails.cache.read('/v1/autocomplete_hack/last_result').each do |autocomplete| | ||
result = true if autocomplete == answer | ||
end | ||
assert result | ||
end | ||
|
||
Then /^(?:|I )should see JSON:$/ do |expected_json| | ||
require 'json' | ||
expected = JSON.pretty_generate(JSON.parse(expected_json)) | ||
|
@@ -298,6 +320,7 @@ def with_scope(locator) | |
sleep 120 | ||
end | ||
|
||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Extra blank line detected. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Extra blank line detected. |
||
Then /^show me the network traffic$/ do | ||
puts page.driver.network_traffic.to_yaml | ||
end |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Space between { and | missing.
Space missing inside }.