-
Notifications
You must be signed in to change notification settings - Fork 121
[UI Tests] - Add load stats UI test #8310
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
Changes from 1 commit
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 | ||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -27,4 +27,46 @@ public final class MyStoreScreen: ScreenObject { | |||||||||||||||||||||||||||
| topBannerCloseButton.tap() | ||||||||||||||||||||||||||||
| return self | ||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
| func tapTimeframeTab(timeframe: String) -> MyStoreScreen { | ||||||||||||||||||||||||||||
| app.cells.staticTexts[timeframe].tap() | ||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
| return self | ||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
| public func goToThisWeekTab() -> MyStoreScreen { | ||||||||||||||||||||||||||||
| return tapTimeframeTab(timeframe: "This Week") | ||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
| public func goToThisMonthTab() -> MyStoreScreen { | ||||||||||||||||||||||||||||
| return tapTimeframeTab(timeframe: "This Month") | ||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
| public func goToThisYearTab() -> MyStoreScreen { | ||||||||||||||||||||||||||||
| return tapTimeframeTab(timeframe: "This Year") | ||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
| func verifyStatsForTimeframeLoaded(timeframe: String) -> MyStoreScreen { | ||||||||||||||||||||||||||||
| let textPredicate = NSPredicate(format: "label MATCHES %@", "Store revenue chart \(timeframe)") | ||||||||||||||||||||||||||||
| XCTAssertTrue(app.images.containing(textPredicate).element.exists, "\(timeframe) chart not displayed") | ||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
| return self | ||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||
|
Comment on lines
+49
to
+54
Contributor
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. WDYT of extending this asserting function with one more check: making sure that the tab of interest is selected? Example of (For this you'll also need to provide the second argument with cell ID):
Suggested change
Contributor
Author
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. i'm leaving this as is, for now. thinking of a scenario where the tab is not selected (e.g. if tap didn't work), the image wouldn't change too so i think that extra check isn't necessary for this test to work
Contributor
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. Totally 👍 to leave it with no changes, just wanted to extend my thoughts about the reason for proposal: as you say, the test will still fail if tab selection did not work, because of incorrect chart name. My proposal was more about increasing the test coverage (e.g. checking for one field in the person details page VS checking for all fields). Also, it would cover a totally made up scenario, when tab switch animation did not work, but the screen itself is updated with correct chart and data. (just my thoughts behind it, let's leave it as it is now). |
||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
| public func verifyTodayStatsLoaded() -> MyStoreScreen { | ||||||||||||||||||||||||||||
| return verifyStatsForTimeframeLoaded(timeframe: "Today") | ||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
| public func verifyThisWeekStatsLoaded() -> MyStoreScreen { | ||||||||||||||||||||||||||||
| return verifyStatsForTimeframeLoaded(timeframe: "This Week") | ||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
| public func verifyThisMonthStatsLoaded() -> MyStoreScreen { | ||||||||||||||||||||||||||||
| return verifyStatsForTimeframeLoaded(timeframe: "This Month") | ||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
| @discardableResult | ||||||||||||||||||||||||||||
| public func verifyThisYearStatsLoaded() -> MyStoreScreen { | ||||||||||||||||||||||||||||
| return verifyStatsForTimeframeLoaded(timeframe: "This Year") | ||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -4,7 +4,6 @@ import XCTest | |
| final class StatsTests: XCTestCase { | ||
|
|
||
| override func setUpWithError() throws { | ||
| try skipTillImplemented() | ||
| continueAfterFailure = false | ||
|
|
||
| // UI tests must launch the application that they test. | ||
|
|
@@ -15,12 +14,14 @@ final class StatsTests: XCTestCase { | |
| try LoginFlow.logInWithWPcom() | ||
| } | ||
|
|
||
| func skipped_test_load_stats_screen() throws { | ||
| func test_load_stats_screen() throws { | ||
| try TabNavComponent().goToMyStoreScreen() | ||
| } | ||
|
|
||
| func skipTillImplemented(file: StaticString = #file, line: UInt = #line) throws { | ||
| try XCTSkipIf(true, | ||
| "Skipping until test is properly implemented", file: file, line: line) | ||
| .verifyTodayStatsLoaded() | ||
|
Contributor
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. This might look redundant (and it most probably is), but I had an idea of also adding a function that selects the
Contributor
Author
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. i'm leaving this as is too, i think not adding that extra tap ensures that upon signing in the merchant would land on the expected tab (Today) instead of other tabs |
||
| .goToThisWeekTab() | ||
| .verifyThisWeekStatsLoaded() | ||
| .goToThisMonthTab() | ||
| .verifyThisMonthStatsLoaded() | ||
| .goToThisYearTab() | ||
| .verifyThisYearStatsLoaded() | ||
| } | ||
| } | ||

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.
WDYT of using the parent cell identifier instead? Example for
This Month:This will make the test less dependent on the localization during tab selection (you will still have a human-readable interval mentioned in the assertion of the chart hint text).
The respective values for IDs to use in calling functions would be:
period-data-today-tabperiod-data-thisWeek-tabperiod-data-thisMonth-tabperiod-data-thisYear-tabThere 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.
ah yup i agree with your point, this is updated in 27a1d7c
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.
Thanks for addressing this @jostnes!