Skip to content

Commit

Permalink
Merge branch 'trunk' into task/20635-update-fse-check
Browse files Browse the repository at this point in the history
  • Loading branch information
dvdchr committed May 9, 2023
2 parents 84e8706 + dfaa43c commit ee0cd5f
Show file tree
Hide file tree
Showing 12 changed files with 126 additions and 37 deletions.
3 changes: 3 additions & 0 deletions RELEASE-NOTES.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
22.4
-----

* [*] [internal] [Jetpack-only] Domains Dashboard Card: Immediately opening domains search after tapping the card. [#20638]
* [**] [Jetpack-only] Adds a dashboard card for viewing activity log. [#20569]
* [**] [Jetpack-only] Adds a dashboard card for viewing pages. [#20524]

22.3
-----
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@ class DashboardDomainsCardCell: DashboardCollectionViewCell {
return
}

DomainsDashboardCoordinator.presentDomainsDashboard(in: presentingViewController,
source: Strings.source,
blog: blog)
DomainsDashboardCoordinator.presentDomainsSuggestions(in: presentingViewController,
source: Strings.source,
blog: blog)
DomainsDashboardCardTracker.trackDirectDomainsPurchaseDashboardCardTapped(in: self.row)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,33 +15,13 @@ struct DomainSuggestionViewControllerWrapper: UIViewControllerRepresentable {
self.blog = blog
self.domainType = domainType
self.onDismiss = onDismiss
self.domainSuggestionViewController = RegisterDomainSuggestionsViewController.instance(site: blog,
domainType: domainType,
includeSupportButton: false)
self.domainSuggestionViewController = DomainsDashboardFactory.makeDomainsSuggestionViewController(blog: blog, domainType: domainType, onDismiss: onDismiss)
}

func makeUIViewController(context: Context) -> LightNavigationController {
let blogService = BlogService(coreDataStack: ContextManager.shared)

self.domainSuggestionViewController.domainPurchasedCallback = { domain in
blogService.syncBlogAndAllMetadata(self.blog) { }
WPAnalytics.track(.domainCreditRedemptionSuccess)
self.presentDomainCreditRedemptionSuccess(domain: domain)
}

let navigationController = LightNavigationController(rootViewController: domainSuggestionViewController)
return navigationController
}

func updateUIViewController(_ uiViewController: LightNavigationController, context: Context) { }

private func presentDomainCreditRedemptionSuccess(domain: String) {

let controller = DomainCreditRedemptionSuccessViewController(domain: domain) { _ in
self.domainSuggestionViewController.dismiss(animated: true) {
self.onDismiss()
}
}
domainSuggestionViewController.present(controller, animated: true)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -77,10 +77,13 @@ class RegisterDomainSuggestionsViewController: UIViewController {
title = TextContent.title
WPStyleGuide.configureColors(view: view, tableView: nil)

let cancelButton = UIBarButtonItem(barButtonSystemItem: .cancel,
target: self,
action: #selector(handleCancelButtonTapped))
navigationItem.leftBarButtonItem = cancelButton
/// If this is the first view controller in the navigation controller - show the cancel button
if navigationController?.children.count == 1 {
let cancelButton = UIBarButtonItem(barButtonSystemItem: .cancel,
target: self,
action: #selector(handleCancelButtonTapped))
navigationItem.leftBarButtonItem = cancelButton
}

guard includeSupportButton else {
return
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,13 @@ import UIKit
presenter.presentBlogDetailsViewController(controller)
}

static func presentDomainsDashboard(in dashboardViewController: BlogDashboardViewController,
source: String,
blog: Blog) {
WPAnalytics.trackEvent(.domainsDashboardViewed, properties: [WPAppAnalyticsKeySource: source], blog: blog)
let controller = DomainsDashboardFactory.makeDomainsDashboardViewController(blog: blog)
static func presentDomainsSuggestions(in dashboardViewController: BlogDashboardViewController,
source: String,
blog: Blog) {
let domainType: DomainType = blog.canRegisterDomainWithPaidPlan ? .registered : .siteRedirect
let controller = DomainsDashboardFactory.makeDomainsSuggestionViewController(blog: blog, domainType: domainType) {
dashboardViewController.navigationController?.popViewController(animated: true)
}
controller.navigationItem.largeTitleDisplayMode = .never
dashboardViewController.show(controller, sender: nil)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,25 @@ struct DomainsDashboardFactory {
viewController.extendedLayoutIncludesOpaqueBars = true
return viewController
}

static func makeDomainsSuggestionViewController(blog: Blog, domainType: DomainType, onDismiss: @escaping () -> Void) -> RegisterDomainSuggestionsViewController {
let viewController = RegisterDomainSuggestionsViewController.instance(
site: blog,
domainType: domainType,
includeSupportButton: false)

viewController.domainPurchasedCallback = { domain in
let blogService = BlogService(coreDataStack: ContextManager.shared)
blogService.syncBlogAndAllMetadata(blog) { }
WPAnalytics.track(.domainCreditRedemptionSuccess)
let controller = DomainCreditRedemptionSuccessViewController(domain: domain) { _ in
viewController.dismiss(animated: true) {
onDismiss()
}
}
viewController.present(controller, animated: true)
}

return viewController
}
}
2 changes: 1 addition & 1 deletion WordPress/UITests/Tests/DashboardTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,6 @@ class DashboardTests: XCTestCase {
.scrollToDomainsCard()
.verifyDomainsCard()
.tapDomainsCard()
.verifyDomainsScreenLoaded()
.verifyDomainsSuggestionsScreenLoaded()
}
}
28 changes: 28 additions & 0 deletions WordPress/UITests/Tests/MenuNavigationTests.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import UITestsFoundation
import XCTest

final class MenuNavigationTests: XCTestCase {

override func setUpWithError() throws {
setUpTestSuite()

try LoginFlow.login(
siteUrl: WPUITestCredentials.testWPcomSiteAddress,
email: WPUITestCredentials.testWPcomUserEmail,
password: WPUITestCredentials.testWPcomPassword
)
}

override func tearDownWithError() throws {
takeScreenshotOfFailedTest()
removeApp()
}

// This test is JP only.
func testDomainsNavigation() throws {
try MySiteScreen()
.goToMenu()
.goToDomainsScreen()
.verifyDomainsScreenLoaded()
}
}
32 changes: 32 additions & 0 deletions WordPress/UITestsFoundation/Screens/DomainsSuggestionsScreen.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
import ScreenObject
import XCTest

public class DomainsSuggestionsScreen: ScreenObject {
public let tabBar: TabNavComponent

let siteDomainsNavbarHeaderGetter: (XCUIApplication) -> XCUIElement = {
$0.staticTexts["Search domains"]
}

var siteDomainsNavbarHeader: XCUIElement { siteDomainsNavbarHeaderGetter(app) }

public init(app: XCUIApplication = XCUIApplication()) throws {
tabBar = try TabNavComponent()

try super.init(
expectedElementGetters: [ siteDomainsNavbarHeaderGetter ],
app: app,
waitTimeout: 7
)
}

public static func isLoaded() -> Bool {
(try? DomainsSuggestionsScreen().isLoaded) ?? false
}

@discardableResult
public func verifyDomainsSuggestionsScreenLoaded() -> Self {
XCTAssertTrue(DomainsSuggestionsScreen.isLoaded(), "\"Domains suggestions\" screen isn't loaded.")
return self
}
}
14 changes: 12 additions & 2 deletions WordPress/UITestsFoundation/Screens/MySiteScreen.swift
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ private struct ElementStringIDs {
static let statsButton = "Stats Row"
static let peopleButton = "People Row"
static let settingsButton = "Settings Row"
static let domainsButton = "Domains Row"
static let createButton = "floatingCreateButton"
static let ReaderButton = "Reader"
static let switchSiteButton = "SwitchSiteButton"
Expand Down Expand Up @@ -64,6 +65,10 @@ public class MySiteScreen: ScreenObject {
$0.buttons[ElementStringIDs.domainsCardHeaderButton]
}

let domainsButtonGetter: (XCUIApplication) -> XCUIElement = {
$0.cells[ElementStringIDs.domainsButton]
}

var domainsCardButton: XCUIElement { domainsCardButtonGetter(app) }

static var isVisible: Bool {
Expand Down Expand Up @@ -158,6 +163,11 @@ public class MySiteScreen: ScreenObject {
return self
}

public func goToDomainsScreen() throws -> DomainsScreen {
app.cells[ElementStringIDs.domainsButton].tap()
return try DomainsScreen()
}

@discardableResult
public func goToMenu() -> Self {
// On iPad, the menu items are already listed on screen, so we don't need to tap the menu button
Expand Down Expand Up @@ -188,9 +198,9 @@ public class MySiteScreen: ScreenObject {
}

@discardableResult
public func tapDomainsCard() throws -> DomainsScreen {
public func tapDomainsCard() throws -> DomainsSuggestionsScreen {
domainsCardButton.tap()
return try DomainsScreen()
return try DomainsSuggestionsScreen()
}

@discardableResult
Expand Down
10 changes: 10 additions & 0 deletions WordPress/WordPress.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,9 @@
011896A629D5B72500D34BA9 /* DomainsDashboardCoordinator.swift in Sources */ = {isa = PBXBuildFile; fileRef = 011896A429D5B72500D34BA9 /* DomainsDashboardCoordinator.swift */; };
011896A829D5BBB400D34BA9 /* DomainsDashboardFactory.swift in Sources */ = {isa = PBXBuildFile; fileRef = 011896A729D5BBB400D34BA9 /* DomainsDashboardFactory.swift */; };
011896A929D5BBB400D34BA9 /* DomainsDashboardFactory.swift in Sources */ = {isa = PBXBuildFile; fileRef = 011896A729D5BBB400D34BA9 /* DomainsDashboardFactory.swift */; };
01281E9A2A0456CB00464F8F /* DomainsSuggestionsScreen.swift in Sources */ = {isa = PBXBuildFile; fileRef = 01281E992A0456CB00464F8F /* DomainsSuggestionsScreen.swift */; };
01281E9C2A051EEA00464F8F /* MenuNavigationTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 01281E9B2A051EEA00464F8F /* MenuNavigationTests.swift */; };
01281E9D2A051EEA00464F8F /* MenuNavigationTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 01281E9B2A051EEA00464F8F /* MenuNavigationTests.swift */; };
0141929C2983F0A300CAEDB0 /* SupportConfiguration.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0141929B2983F0A300CAEDB0 /* SupportConfiguration.swift */; };
0141929D2983F0A300CAEDB0 /* SupportConfiguration.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0141929B2983F0A300CAEDB0 /* SupportConfiguration.swift */; };
014192A02983F5E800CAEDB0 /* SupportConfigurationTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0141929F2983F5E800CAEDB0 /* SupportConfigurationTests.swift */; };
Expand Down Expand Up @@ -5767,6 +5770,8 @@
011896A429D5B72500D34BA9 /* DomainsDashboardCoordinator.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DomainsDashboardCoordinator.swift; sourceTree = "<group>"; };
011896A729D5BBB400D34BA9 /* DomainsDashboardFactory.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DomainsDashboardFactory.swift; sourceTree = "<group>"; };
011A2815DB0DE7E3973CBC0E /* Pods-Apps-Jetpack.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Apps-Jetpack.release.xcconfig"; path = "../Pods/Target Support Files/Pods-Apps-Jetpack/Pods-Apps-Jetpack.release.xcconfig"; sourceTree = "<group>"; };
01281E992A0456CB00464F8F /* DomainsSuggestionsScreen.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DomainsSuggestionsScreen.swift; sourceTree = "<group>"; };
01281E9B2A051EEA00464F8F /* MenuNavigationTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MenuNavigationTests.swift; sourceTree = "<group>"; };
0141929B2983F0A300CAEDB0 /* SupportConfiguration.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SupportConfiguration.swift; sourceTree = "<group>"; };
0141929F2983F5E800CAEDB0 /* SupportConfigurationTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SupportConfigurationTests.swift; sourceTree = "<group>"; };
0147D64D294B1E1600AA6410 /* StatsRevampStore.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = StatsRevampStore.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -11485,6 +11490,7 @@
BE6DD32F1FD67F3B00E55192 /* TabNavComponent.swift */,
EAD08D0D29D45E23001A72F9 /* CommentsScreen.swift */,
D82E087729EEB7AF0098F500 /* DomainsScreen.swift */,
01281E992A0456CB00464F8F /* DomainsSuggestionsScreen.swift */,
);
path = Screens;
sourceTree = "<group>";
Expand Down Expand Up @@ -15515,6 +15521,7 @@
CC2BB0CF228ACF710034F9AB /* EditorGutenbergTests.swift */,
EAD2BF4127594DAB00A847BB /* StatsTests.swift */,
D82E087429EEB0B00098F500 /* DashboardTests.swift */,
01281E9B2A051EEA00464F8F /* MenuNavigationTests.swift */,
);
path = Tests;
sourceTree = "<group>";
Expand Down Expand Up @@ -22599,6 +22606,7 @@
3F762E9726784BED0088CD45 /* FancyAlertComponent.swift in Sources */,
3F2F854226FAEA50000FCDA5 /* JetpackScanScreen.swift in Sources */,
3F2F855A26FAF227000FCDA5 /* EditorNoticeComponent.swift in Sources */,
01281E9A2A0456CB00464F8F /* DomainsSuggestionsScreen.swift in Sources */,
3F2F855D26FAF227000FCDA5 /* LoginCheckMagicLinkScreen.swift in Sources */,
EA78189427596B2F00554DFA /* ContactUsScreen.swift in Sources */,
D82E087829EEB7AF0098F500 /* DomainsScreen.swift in Sources */,
Expand Down Expand Up @@ -23500,6 +23508,7 @@
EA14533129AD874C001F3143 /* WPUITestCredentials.swift in Sources */,
EA14533229AD874C001F3143 /* SignupTests.swift in Sources */,
EA14533329AD874C001F3143 /* EditorFlow.swift in Sources */,
01281E9D2A051EEA00464F8F /* MenuNavigationTests.swift in Sources */,
EA14533429AD874C001F3143 /* UIApplication+mainWindow.swift in Sources */,
EA14533529AD874C001F3143 /* LoginFlow.swift in Sources */,
EA14533629AD874C001F3143 /* XCTest+Extensions.swift in Sources */,
Expand Down Expand Up @@ -25423,6 +25432,7 @@
CC8A5EAB22159FA6001B7874 /* WPUITestCredentials.swift in Sources */,
CC7CB97322B1510900642EE9 /* SignupTests.swift in Sources */,
CC52188C2278C622008998CE /* EditorFlow.swift in Sources */,
01281E9C2A051EEA00464F8F /* MenuNavigationTests.swift in Sources */,
8B5FEAF125A746CB000CBFF7 /* UIApplication+mainWindow.swift in Sources */,
BED4D8331FF11E3800A11345 /* LoginFlow.swift in Sources */,
FF2716A11CABC7D40006E2D4 /* XCTest+Extensions.swift in Sources */,
Expand Down
2 changes: 1 addition & 1 deletion docs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

## Testing

- [UI Tests](../WordPress/WordPressUITests)
- [UI Tests](../WordPress/UITests)

## Others

Expand Down

0 comments on commit ee0cd5f

Please sign in to comment.