Skip to content

Commit 584e72d

Browse files
authored
Merge pull request #5474 from woocommerce/feat/5360-login-with-site-address-jcp
Jetpack CP: enable logging in with site address
2 parents 779d3a7 + 7f36f5c commit 584e72d

File tree

3 files changed

+51
-6
lines changed

3 files changed

+51
-6
lines changed

WooCommerce/Classes/Extensions/WordPressComSiteInfo+Woo.swift

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,12 @@ extension WordPressComSiteInfo {
55
/// Encapsulates the rules that declare a WordPress site as having a valid
66
/// Jetpack installation
77
var hasValidJetpack: Bool {
8-
return hasJetpack &&
9-
isJetpackConnected &&
10-
isJetpackActive
8+
if ServiceLocator.featureFlagService.isFeatureFlagEnabled(.jetpackConnectionPackageSupport) {
9+
return isJetpackConnected
10+
} else {
11+
return hasJetpack &&
12+
isJetpackConnected &&
13+
isJetpackActive
14+
}
1115
}
1216
}

WooCommerce/WooCommerceTests/Extensions/WordPressComSiteInfoWooTests.swift

Lines changed: 38 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,18 +9,54 @@ final class WordPressComSiteInfoWooTests: XCTestCase {
99
XCTAssertTrue(infoSite.hasValidJetpack)
1010
}
1111

12-
func test_is_not_valid_when_site_does_not_have_jetpack() {
12+
func test_is_not_valid_when_site_does_not_have_jetpack_with_jcp_feature_off() {
13+
// Given
14+
let featureFlagService = MockFeatureFlagService(isJetpackConnectionPackageSupportOn: false)
15+
ServiceLocator.setFeatureFlagService(featureFlagService)
16+
17+
// When
1318
let infoSite = WordPressComSiteInfo(remote: doesNotHaveJetpack())
1419

20+
// Then
1521
XCTAssertFalse(infoSite.hasValidJetpack)
1622
}
1723

18-
func test_is_not_valid_when_site_has_jetpack_installed_but_not_active() {
24+
func test_is_valid_when_site_does_not_have_jetpack_with_jcp_feature_on() {
25+
// Given
26+
let featureFlagService = MockFeatureFlagService(isJetpackConnectionPackageSupportOn: true)
27+
ServiceLocator.setFeatureFlagService(featureFlagService)
28+
29+
// When
30+
let infoSite = WordPressComSiteInfo(remote: doesNotHaveJetpack())
31+
32+
// Then
33+
XCTAssertTrue(infoSite.hasValidJetpack)
34+
}
35+
36+
func test_is_not_valid_when_site_has_jetpack_installed_but_not_active_with_jcp_feature_off() {
37+
// Given
38+
let featureFlagService = MockFeatureFlagService(isJetpackConnectionPackageSupportOn: false)
39+
ServiceLocator.setFeatureFlagService(featureFlagService)
40+
41+
// When
1942
let infoSite = WordPressComSiteInfo(remote: hasJetpackInactive())
2043

44+
// Then
2145
XCTAssertFalse(infoSite.hasValidJetpack)
2246
}
2347

48+
func test_is_not_valid_when_site_has_jetpack_installed_but_not_active_with_jcp_feature_on() {
49+
// Given
50+
let featureFlagService = MockFeatureFlagService(isJetpackConnectionPackageSupportOn: true)
51+
ServiceLocator.setFeatureFlagService(featureFlagService)
52+
53+
// When
54+
let infoSite = WordPressComSiteInfo(remote: hasJetpackInactive())
55+
56+
// Then
57+
XCTAssertTrue(infoSite.hasValidJetpack)
58+
}
59+
2460
func test_is_not_valid_when_site_has_jetpack_installed_but_not_connected() {
2561
let infoSite = WordPressComSiteInfo(remote: hasJetpackNotConnected())
2662

WooCommerce/WooCommerceTests/Mocks/MockFeatureFlagService.swift

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,19 +8,22 @@ struct MockFeatureFlagService: FeatureFlagService {
88
private let isShippingLabelsPackageCreationOn: Bool
99
private let isShippingLabelsMultiPackageOn: Bool
1010
private let isPushNotificationsForAllStoresOn: Bool
11+
private let isJetpackConnectionPackageSupportOn: Bool
1112

1213
init(isShippingLabelsM2M3On: Bool = false,
1314
isInternationalShippingLabelsOn: Bool = false,
1415
isShippingLabelsPaymentMethodCreationOn: Bool = false,
1516
isShippingLabelsPackageCreationOn: Bool = false,
1617
isShippingLabelsMultiPackageOn: Bool = false,
17-
isPushNotificationsForAllStoresOn: Bool = false) {
18+
isPushNotificationsForAllStoresOn: Bool = false,
19+
isJetpackConnectionPackageSupportOn: Bool = false) {
1820
self.isShippingLabelsM2M3On = isShippingLabelsM2M3On
1921
self.isInternationalShippingLabelsOn = isInternationalShippingLabelsOn
2022
self.isShippingLabelsPaymentMethodCreationOn = isShippingLabelsPaymentMethodCreationOn
2123
self.isShippingLabelsPackageCreationOn = isShippingLabelsPackageCreationOn
2224
self.isShippingLabelsMultiPackageOn = isShippingLabelsMultiPackageOn
2325
self.isPushNotificationsForAllStoresOn = isPushNotificationsForAllStoresOn
26+
self.isJetpackConnectionPackageSupportOn = isJetpackConnectionPackageSupportOn
2427
}
2528

2629
func isFeatureFlagEnabled(_ featureFlag: FeatureFlag) -> Bool {
@@ -37,6 +40,8 @@ struct MockFeatureFlagService: FeatureFlagService {
3740
return isShippingLabelsMultiPackageOn
3841
case .pushNotificationsForAllStores:
3942
return isPushNotificationsForAllStoresOn
43+
case .jetpackConnectionPackageSupport:
44+
return isJetpackConnectionPackageSupportOn
4045
default:
4146
return false
4247
}

0 commit comments

Comments
 (0)