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
Closed
Closed
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
eb73392
The autocomplete fires, but I have trouble finding the text
zz9pzza c1685c4
This fails with the scenario rather than a step
zz9pzza bbe2d48
Fix typo
zz9pzza 2b8702b
Merge branch 'master' of https://github.com/otwcode/otwarchive into A…
zz9pzza 7365d89
Remove last check as it should not be in the auto complete list
zz9pzza 930c626
Fix merge conflict
zz9pzza 56309e8
Listen to the hound
zz9pzza File filter
Filter by extension
Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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| | ||
Rails.cache.delete('/v1/autocomplete_hack/last_result') | ||
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. |
||
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 /^visiting "([^"]*)" should fail with "([^"]*)"$/ do |path, flash_error| | ||
visit path | ||
step %{I should see "#{flash_error}" within ".flash"} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Use Integer#times for a simple loop which iterates a fixed number of times.