Skip to content

Commit 6e1b975

Browse files
authored
Merge pull request #5873 from woocommerce/remove-tabnav-condition
Remove condition on tab nav
2 parents 76a323b + 48fa4b1 commit 6e1b975

File tree

6 files changed

+92
-44
lines changed

6 files changed

+92
-44
lines changed
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
import ScreenObject
2+
import XCTest
3+
4+
public final class MenuScreen: ScreenObject {
5+
static var isVisible: Bool {
6+
(try? MenuScreen().isLoaded) ?? false
7+
}
8+
9+
public init(app: XCUIApplication = XCUIApplication()) throws {
10+
try super.init(
11+
expectedElementGetters: [
12+
// swiftlint:disable next opening_brace
13+
{ $0.staticTexts["Reviews"] },
14+
{ $0.staticTexts["View Store"] }
15+
// swiftlint:enable next opening_brace
16+
],
17+
app: app
18+
)
19+
}
20+
21+
@discardableResult
22+
public func goToReviewsScreen() throws -> ReviewsScreen {
23+
app.staticTexts["Reviews"].tap()
24+
return try ReviewsScreen()
25+
}
26+
27+
@discardableResult
28+
public func openSettingsPane() throws -> SettingsScreen {
29+
app.buttons["dashboard-settings-button"].tap()
30+
return try SettingsScreen()
31+
}
32+
}

WooCommerce/UITestsFoundation/Screens/MyStore/MyStoreScreen.swift

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -8,19 +8,13 @@ public final class MyStoreScreen: ScreenObject {
88
// TODO: Remove force `try` once `ScreenObject` migration is completed
99
public let periodStatsTable = try! PeriodStatsTable()
1010

11-
private let settingsButtonGetter: (XCUIApplication) -> XCUIElement = {
12-
$0.buttons["dashboard-settings-button"]
13-
}
14-
15-
private var settingsButton: XCUIElement { settingsButtonGetter(app) }
16-
1711
static var isVisible: Bool {
1812
(try? MyStoreScreen().isLoaded) ?? false
1913
}
2014

2115
public init(app: XCUIApplication = XCUIApplication()) throws {
2216
try super.init(
23-
expectedElementGetters: [settingsButtonGetter],
17+
expectedElementGetters: [ { $0.staticTexts["Your WooCommerce Store"] }],
2418
app: app
2519
)
2620
}
@@ -33,10 +27,4 @@ public final class MyStoreScreen: ScreenObject {
3327
topBannerCloseButton.tap()
3428
return self
3529
}
36-
37-
@discardableResult
38-
public func openSettingsPane() throws -> SettingsScreen {
39-
settingsButton.tap()
40-
return try SettingsScreen()
41-
}
4230
}

WooCommerce/UITestsFoundation/Screens/TabNavComponent.swift

Lines changed: 13 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -11,25 +11,24 @@ public final class TabNavComponent: ScreenObject {
1111
$0.tabBars.firstMatch.buttons["tab-bar-orders-item"]
1212
}
1313

14-
private let reviewsTabButtonGetter: (XCUIApplication) -> XCUIElement = {
15-
$0.tabBars.firstMatch.buttons["tab-bar-reviews-item"]
16-
}
17-
1814
private let productsTabButtonGetter: (XCUIApplication) -> XCUIElement = {
1915
$0.tabBars.firstMatch.buttons["tab-bar-products-item"]
2016
}
2117

18+
private let menuTabButtonGetter: (XCUIApplication) -> XCUIElement = {
19+
$0.tabBars.firstMatch.buttons["tab-bar-menu-item"]
20+
}
21+
2222
private var myStoreTabButton: XCUIElement { myStoreTabButtonGetter(app) }
2323
private var ordersTabButton: XCUIElement { ordersTabButtonGetter(app) }
24-
private var reviewsTabButton: XCUIElement { reviewsTabButtonGetter(app) }
25-
var productsTabButton: XCUIElement { productsTabButtonGetter(app) }
24+
private var menuTabButton: XCUIElement { menuTabButtonGetter(app) }
25+
private var productsTabButton: XCUIElement { productsTabButtonGetter(app) }
2626

2727
public init(app: XCUIApplication = XCUIApplication()) throws {
2828
try super.init(
2929
expectedElementGetters: [
3030
myStoreTabButtonGetter,
3131
ordersTabButtonGetter,
32-
reviewsTabButtonGetter,
3332
productsTabButtonGetter
3433
],
3534
app: app
@@ -38,40 +37,26 @@ public final class TabNavComponent: ScreenObject {
3837

3938
@discardableResult
4039
public func goToMyStoreScreen() throws -> MyStoreScreen {
41-
// Avoid transitioning if it is already on screen
42-
if MyStoreScreen.isVisible == false {
43-
myStoreTabButton.tap()
44-
}
40+
myStoreTabButton.tap()
4541
return try MyStoreScreen()
4642
}
4743

4844
@discardableResult
4945
public func goToOrdersScreen() throws -> OrdersScreen {
50-
// Avoid transitioning if it is already on screen
51-
guard let orderScreen = try? OrdersScreen(), orderScreen.isLoaded else {
52-
ordersTabButton.tap()
53-
return try OrdersScreen()
54-
}
55-
56-
return orderScreen
46+
ordersTabButton.tap()
47+
return try OrdersScreen()
5748
}
5849

5950
@discardableResult
6051
public func goToProductsScreen() throws -> ProductsScreen {
61-
if ProductsScreen.isVisible == false {
62-
productsTabButton.tap()
63-
}
64-
52+
productsTabButton.tap()
6553
return try ProductsScreen()
6654
}
6755

6856
@discardableResult
69-
public func goToReviewsScreen() throws -> ReviewsScreen {
70-
if ReviewsScreen.isVisible == false {
71-
reviewsTabButton.tap()
72-
}
73-
74-
return try ReviewsScreen()
57+
public func goToMenuScreen() throws -> MenuScreen {
58+
menuTabButton.tap()
59+
return try MenuScreen()
7560
}
7661

7762
static func isLoaded() -> Bool {

WooCommerce/WooCommerce.xcodeproj/project.pbxproj

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -947,6 +947,8 @@
947947
800A5BC7275889ED009DE2CD /* reports_revenue_stats_month.json in Resources */ = {isa = PBXBuildFile; fileRef = 800A5BC3275889EC009DE2CD /* reports_revenue_stats_month.json */; };
948948
800A5BC8275889ED009DE2CD /* reports_revenue_stats_year.json in Resources */ = {isa = PBXBuildFile; fileRef = 800A5BC4275889EC009DE2CD /* reports_revenue_stats_year.json */; };
949949
800A5BCB2759CE4B009DE2CD /* ProductsTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 800A5BCA2759CE4B009DE2CD /* ProductsTests.swift */; };
950+
80AD2CA22782B4EB00A63DE8 /* products_on_review.json in Resources */ = {isa = PBXBuildFile; fileRef = 80AD2CA12782B4EB00A63DE8 /* products_on_review.json */; };
951+
80B8D34C278E8A0C00FE6E6B /* MenuScreen.swift in Sources */ = {isa = PBXBuildFile; fileRef = 80B8D34B278E8A0C00FE6E6B /* MenuScreen.swift */; };
950952
80AD2CA22782B4EB00A63DE8 /* products_list_1.json in Resources */ = {isa = PBXBuildFile; fileRef = 80AD2CA12782B4EB00A63DE8 /* products_list_1.json */; };
951953
80AD2CA427858BAB00A63DE8 /* StatsTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 80AD2CA327858BAB00A63DE8 /* StatsTests.swift */; };
952954
80AD2CA627859B4400A63DE8 /* reports_leaderboards_stats_day.json in Resources */ = {isa = PBXBuildFile; fileRef = 80AD2CA527859B4400A63DE8 /* reports_leaderboards_stats_day.json */; };
@@ -2513,6 +2515,8 @@
25132515
800A5BC3275889EC009DE2CD /* reports_revenue_stats_month.json */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.json; path = reports_revenue_stats_month.json; sourceTree = "<group>"; };
25142516
800A5BC4275889EC009DE2CD /* reports_revenue_stats_year.json */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.json; path = reports_revenue_stats_year.json; sourceTree = "<group>"; };
25152517
800A5BCA2759CE4B009DE2CD /* ProductsTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ProductsTests.swift; sourceTree = "<group>"; };
2518+
80AD2CA12782B4EB00A63DE8 /* products_on_review.json */ = {isa = PBXFileReference; lastKnownFileType = text.json; path = products_on_review.json; sourceTree = "<group>"; };
2519+
80B8D34B278E8A0C00FE6E6B /* MenuScreen.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MenuScreen.swift; sourceTree = "<group>"; };
25162520
80AD2CA12782B4EB00A63DE8 /* products_list_1.json */ = {isa = PBXFileReference; lastKnownFileType = text.json; path = products_list_1.json; sourceTree = "<group>"; };
25172521
80AD2CA327858BAB00A63DE8 /* StatsTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = StatsTests.swift; sourceTree = "<group>"; };
25182522
80AD2CA527859B4400A63DE8 /* reports_leaderboards_stats_day.json */ = {isa = PBXFileReference; lastKnownFileType = text.json; path = reports_leaderboards_stats_day.json; sourceTree = "<group>"; };
@@ -5458,6 +5462,14 @@
54585462
path = Flows;
54595463
sourceTree = "<group>";
54605464
};
5465+
80B8D34A278E89F300FE6E6B /* Menu */ = {
5466+
isa = PBXGroup;
5467+
children = (
5468+
80B8D34B278E8A0C00FE6E6B /* MenuScreen.swift */,
5469+
);
5470+
path = Menu;
5471+
sourceTree = "<group>";
5472+
};
54615473
88A44ABE866401E6DB03AC60 /* Frameworks */ = {
54625474
isa = PBXGroup;
54635475
children = (
@@ -7333,6 +7345,7 @@
73337345
F997171723DBCD5100592D8E /* Screens */ = {
73347346
isa = PBXGroup;
73357347
children = (
7348+
80B8D34A278E89F300FE6E6B /* Menu */,
73367349
F997171823DBCD5700592D8E /* Login */,
73377350
CCDC49EE24000985003166BA /* MyStore */,
73387351
F997173B23DBFBB200592D8E /* Orders */,
@@ -8045,6 +8058,7 @@
80458058
3F0CF30C2704490A00EF3D71 /* LoginPasswordScreen.swift in Sources */,
80468059
3F0CF30E2704490A00EF3D71 /* PasswordScreen.swift in Sources */,
80478060
3F0CF3092704490A00EF3D71 /* BetaFeaturesScreen.swift in Sources */,
8061+
80B8D34C278E8A0C00FE6E6B /* MenuScreen.swift in Sources */,
80488062
3F0CF3022704490A00EF3D71 /* LinkOrPasswordScreen.swift in Sources */,
80498063
3F0CF2FF2704490A00EF3D71 /* SettingsScreen.swift in Sources */,
80508064
3F0CF3052704490A00EF3D71 /* LoginEpilogueScreen.swift in Sources */,

WooCommerce/WooCommerceUITests/Tests/LoginTests.swift

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,30 +14,38 @@ final class LoginTests: XCTestCase {
1414

1515
// Login with Store Address and log out.
1616
func testSiteAddressLoginLogout() throws {
17+
try skipTillSettingsFixed()
18+
1719
let prologue = try PrologueScreen().selectSiteAddress()
1820
.proceedWith(siteUrl: TestCredentials.siteUrl)
1921
.proceedWith(email: TestCredentials.emailAddress)
2022
.proceedWith(password: TestCredentials.password)
2123
.verifyEpilogueDisplays(displayName: TestCredentials.displayName, siteUrl: TestCredentials.siteUrl)
2224
.continueWithSelectedSite()
2325

24-
// Log out
26+
// Log out
27+
try TabNavComponent()
28+
.goToMenuScreen()
2529
.openSettingsPane()
2630
.verifySelectedStoreDisplays(storeName: TestCredentials.storeName, siteUrl: TestCredentials.siteUrl)
2731
.logOut()
2832

2933
XCTAssert(prologue.isLoaded)
3034
}
3135

32-
//Login with WordPress.com account and log out
36+
// Login with WordPress.com account and log out
3337
func testWordPressLoginLogout() throws {
38+
try skipTillSettingsFixed()
39+
3440
let prologue = try PrologueScreen().selectContinueWithWordPress()
3541
.proceedWith(email: TestCredentials.emailAddress)
3642
.proceedWith(password: TestCredentials.password)
3743
.verifyEpilogueDisplays(displayName: TestCredentials.displayName, siteUrl: TestCredentials.siteUrl)
3844
.continueWithSelectedSite()
3945

40-
// Log out
46+
// Log out
47+
try TabNavComponent()
48+
.goToMenuScreen()
4149
.openSettingsPane()
4250
.verifySelectedStoreDisplays(storeName: TestCredentials.storeName, siteUrl: TestCredentials.siteUrl)
4351
.logOut()
@@ -51,4 +59,13 @@ final class LoginTests: XCTestCase {
5159
.tryProceed(password: "invalidPswd")
5260
.verifyLoginError()
5361
}
62+
63+
func skipTillSettingsFixed(file: StaticString = #file, line: UInt = #line) throws {
64+
try XCTSkipIf(true,
65+
"""
66+
Skipping test because settings icon was moved from My Store to Hub Menu,
67+
the icon no longer have an accessibilityIdentifier,
68+
so test will fail during logout.
69+
""", file: file, line: line)
70+
}
5471
}

WooCommerce/WooCommerceUITests/Tests/ReviewsTests.swift

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ import XCTest
44
final class ReviewsTests: XCTestCase {
55

66
override func setUpWithError() throws {
7+
try skipTillReviewMenuFixed()
8+
79
continueAfterFailure = false
810

911
let app = XCUIApplication()
@@ -17,10 +19,13 @@ final class ReviewsTests: XCTestCase {
1719
.goToProductsScreen()
1820

1921
try TabNavComponent()
22+
.goToMenuScreen()
2023
.goToReviewsScreen()
2124
}
2225

2326
func testReviewsScreenLoad() throws {
27+
try skipTillReviewMenuFixed()
28+
2429
let reviews = try GetMocks.readReviewsData()
2530

2631
try ReviewsScreen()
@@ -32,4 +37,11 @@ final class ReviewsTests: XCTestCase {
3237
.goBackToReviewsScreen()
3338
.verifyReviewsScreenLoaded()
3439
}
40+
41+
func skipTillReviewMenuFixed(file: StaticString = #file, line: UInt = #line) throws {
42+
try XCTSkipIf(true,
43+
"""
44+
Skipping test because of the reviews menu does not appear on first load. See: https://github.com/woocommerce/woocommerce-ios/issues/5872
45+
""", file: file, line: line)
46+
}
3547
}

0 commit comments

Comments
 (0)