Skip to content

Instantly share code, notes, and snippets.

@akasper
Forked from ChillPenguinX/device_info.feature
Last active December 11, 2015 23:28
Show Gist options
  • Save akasper/4676736 to your computer and use it in GitHub Desktop.
Save akasper/4676736 to your computer and use it in GitHub Desktop.
@javascript
Feature: Device Info
As a Tapjoy employee
I want to search devices
So that I can efficiently manage their clicks, apps and rewards
Scenario: Visiting the "device info" page without a search
When I visit the device info "show" page
Then I should see the "search bar"
And I should not see the "Apps Section"
And I should not see the "Clicks Section"
And I should not see the "Devices Section"
Scenario: Visiting the "device info" page with a search
When I visit the device info "index" page
Then I should see the "search bar"
And I should see one device
And I should see the "Apps Section"
And I should see the "Clicks Section"
Scenario Outline: Searching for a device on the "Device Info Page"
Given I have selected <search> in the dropdown and put a <query> in the search bar
When I hit the search button
Then Any devices, apps, and clicks on the page should be removed
And I should receive back <count> devices
Examples:
| search | count | query |
| Smart Search | 1 | b0b942d6f63d8f86a1bccafc1f1be72aa7f04744 |
| Search by Device ID | 1 | b0b942d6f63d8f86a1bccafc1f1be72aa7f04744 |
| Smart Search | 1 | b0b942d6f63d8f86a1bccafc1f1be72aa7f04744.01416cf9-45a5-4fc0-a860-e003a27d8714 |
| Search by Click Key | 1 | b0b942d6f63d8f86a1bccafc1f1be72aa7f04744.01416cf9-45a5-4fc0-a860-e003a27d8714 |
| Smart Search | 1 or more | MAC Address |
| Search by MAC Address | 1 or more | MAC Address |
| Smart Search | 1 or more | Email Address |
| Search by Email Address | 1 or more | Email Address |
Scenario: Having a single device selected
Given I have completed a device info search with at least one result
When I select a device
Then I should see the "Devices Section"
And it should start loading the "Apps Section"
And it should start loading the "Clicks Section"
Scenario: Having multiple devices returned
Given multiple devices
Given no device has been selected
When I do a device info search by email address with that address
Then I should not see the "Apps Section"
And I should not see the "Clicks Section"
When I click one of the devices
Then I should have a single device selected
And the others should form a scrollable list on the left side
Scenario: Loading more apps
Given I have a single device selected and have gotten an apps page back and there are multiple pages
When I click for a new page
Then the a new page page of apps should load in
Scenario: Loading all Apps
Given there are multiple app pages
Given not all have been loaded in
Then I should should see the "Load All Apps" button
When I click the "Load All Apps" button
Then the app controls should be disabled while the load happens
And I should not see the "Load All Apps" button anymore
And when the load completes the app controls should be reenabled
Scenario: Getting more clicks
Given I have a single device selected
Given have gotten a page of clicks back
Given the "all clicks loaded" message has not appeared
When I scroll to the bottom
Then I should see the "Load more clicks" button
When I click the "Load more clicks" button
Then I should not see the "Load more clicks" button
And The page should start loading clicks
When The clicks have loaded
Then I should see either the "Load more clicks" button or the "all clicks loaded" message
Scenario: Filtering by app
Given I have a single device selected
Given I have at least one apps page laoded in for the selected device
Given I have at least one clicks page loaded in for the selected device
Given I have not filtered by a reward status
Given the page is not currently loading apps
When I click the filter button on an app
Then I should not see any apps other than that one
And the filter icon should be replaced by an eject icon
And I should not see any clicks that aren't related to that app
And I should see every click related to that app
And I should not see the app page controls
And I should see a filter bar for the selected app
Scenario: Filtering by reward status
Given I have a single device selected
Given I have at least one clicks page loaded in for the selected device
Given I have not filtered by app
When I click on a reward type
Then I should not see any clicks that do not have that reward type
And I should see every click that has that reward type
And I should see a filter bar for the selected reward type
Scenario Outline: Multiple filters
Given I have already filtered by <filter>
When I click the <button>
Then I should only see clicks that apply to both filters
And I should see two filter bars
| filter | button |
| app | reward type |
| reward type | app filter |
Scenario Outline: Removing a filter
Given I have filtered clicks by <filter>
When I click <button>
Then I should see clicks that do not apply to that <filter>
And I should not see the filter bar for that <filter>
| filter | button |
| app | app eject |
| app | filter bar close |
| reward type | click total |
| reward type | filter bar close |
Scenario: Searching Apps
Given I have a single device selected
Given I have one or more app pages loaded
Given the page is not currently loading apps
When I click the search bar
Then the search string should be blank
And I should see every app for the selected device
And I should not see the page controls
When I type in the search bar
Then I should see the apps whose name or ID match the search string
And I should not see the app whose name and ID do not match the search string
Scenario: Updating device
Given I have a single device selected
When I click the <button> button
Then All the devices on the page should be disabled
When the device gets uploaded
Then I should see a notification at the top of the page
And the devices should be enabled
| button |
| Update Device |
| Recreate Identifiers |
Scenario: Switching device
Given I have multiple devices on the page
Given I have a single device selected
When I click on a different device
Then that should become the selected device
And apps for the previous device should be hidden
And clicks for the previous device should be hidden
# Is it technically important that it starts loading? Or is it just important
# that the user should eventually be able to see it, and that is should
# eventually have content? I think the latter... which, by the way, is
# a bit easier to test.
And apps for the new device should start loading
And clicks for the new device should start loading
# My implementation, assuming you use the suggestion below about merging the #get_selector
# into the existing #selector_for method in selectors.rb
def check_visibility_by_id(name)
page.should have_selector selector_for(name)
end
# I recommend merging this into the 'selectors.rb' file.
def get_selector(name)
case name.downcase!
when 'search bar'
'#search_string'
when 'apps section'
'#app_container_wrapper'
when 'clicks section'
'#click_container_wrapper'
when 'devices section'
'#device_container_wrapper'
when 'load all apps'
'#load_all_apps_button'
when 'load more clicks'
"#clicks_#{@device.id} .load-more-clicks"
when 'all clicks loaded'
"#clicks_#{@device.id} .all-clicks-loaded"
else
"no selector for #{name}"
end
end
# There's already a 'common_steps.rb' file that has a step like this.
#When \^I visit the device info "(.*?)"$ page\ do |page|
# visit page == 'index' ? tools_device_info_index_path : tools_device_info_path('b0b942d6f63d8f86a1bccafc1f1be72aa7f04742')
#end
Then \^I should see the "(.*?)"$\ do |section|
check_visibility_by_id(section)
end
Then \^I should not see the "(.*?)"$\ do |section|
check_visibility_by_id(section)
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment