From f304e0807cf6b82f9c38b0166344652bee5c80eb Mon Sep 17 00:00:00 2001 From: kean Date: Wed, 14 Feb 2024 15:20:33 -0500 Subject: [PATCH] Update UI tests --- .../Post/PostEditor+MoreOptions.swift | 4 +++- .../PrepublishingViewController.swift | 2 +- .../SchedulingDatePickerViewController.swift | 2 ++ .../Screens/Editor/BlockEditorScreen.swift | 2 +- .../Screens/Editor/EditorPostSettings.swift | 17 +++++++++-------- 5 files changed, 16 insertions(+), 11 deletions(-) diff --git a/WordPress/Classes/ViewRelated/Post/PostEditor+MoreOptions.swift b/WordPress/Classes/ViewRelated/Post/PostEditor+MoreOptions.swift index add7d24a1869..1aaf85940132 100644 --- a/WordPress/Classes/ViewRelated/Post/PostEditor+MoreOptions.swift +++ b/WordPress/Classes/ViewRelated/Post/PostEditor+MoreOptions.swift @@ -11,9 +11,11 @@ extension PostEditor { settingsViewController = PostSettingsViewController(post: post) } settingsViewController.featuredImageDelegate = self as? FeaturedImageDelegate - settingsViewController.navigationItem.leftBarButtonItem = UIBarButtonItem(systemItem: .close, primaryAction: .init(handler: { [weak self] _ in + let closeButton = UIBarButtonItem(systemItem: .close, primaryAction: .init(handler: { [weak self] _ in self?.navigationController?.dismiss(animated: true) })) + closeButton.accessibilityIdentifier = "close" + settingsViewController.navigationItem.leftBarButtonItem = closeButton let navigation = UINavigationController(rootViewController: settingsViewController) self.navigationController?.present(navigation, animated: true) diff --git a/WordPress/Classes/ViewRelated/Post/Prepublishing/PrepublishingViewController.swift b/WordPress/Classes/ViewRelated/Post/Prepublishing/PrepublishingViewController.swift index 3acedaf86e26..7d7637cc2ce1 100644 --- a/WordPress/Classes/ViewRelated/Post/Prepublishing/PrepublishingViewController.swift +++ b/WordPress/Classes/ViewRelated/Post/Prepublishing/PrepublishingViewController.swift @@ -60,7 +60,7 @@ final class PrepublishingViewController: UIViewController, UITableViewDataSource let publishButton: NUXButton = { let nuxButton = NUXButton() nuxButton.isPrimary = true - + nuxButton.accessibilityIdentifier = "publish" return nuxButton }() diff --git a/WordPress/Classes/ViewRelated/Post/Scheduling/SchedulingDatePickerViewController.swift b/WordPress/Classes/ViewRelated/Post/Scheduling/SchedulingDatePickerViewController.swift index bf9f581d037b..faa95794cbea 100644 --- a/WordPress/Classes/ViewRelated/Post/Scheduling/SchedulingDatePickerViewController.swift +++ b/WordPress/Classes/ViewRelated/Post/Scheduling/SchedulingDatePickerViewController.swift @@ -41,6 +41,8 @@ final class SchedulingDatePickerViewController: UIViewController { ]) view.backgroundColor = .systemBackground + navigationItem.backBarButtonItem?.accessibilityIdentifier = "back" + updateNavigationItems() } diff --git a/WordPress/UITestsFoundation/Screens/Editor/BlockEditorScreen.swift b/WordPress/UITestsFoundation/Screens/Editor/BlockEditorScreen.swift index 538bab40667b..b32c39651f3b 100644 --- a/WordPress/UITestsFoundation/Screens/Editor/BlockEditorScreen.swift +++ b/WordPress/UITestsFoundation/Screens/Editor/BlockEditorScreen.swift @@ -290,7 +290,7 @@ public class BlockEditorScreen: ScreenObject { } else if postType == .page && XCUIDevice.isPhone { postNowButton = app.scrollViews.buttons[action.rawValue] } else { - postNowButton = app.buttons["\(action.rawValue) Now"] + postNowButton = app.buttons["publish"] } waitForExistenceAndTap(postButton) diff --git a/WordPress/UITestsFoundation/Screens/Editor/EditorPostSettings.swift b/WordPress/UITestsFoundation/Screens/Editor/EditorPostSettings.swift index 0b5c7eb3b684..0dc242d5837a 100644 --- a/WordPress/UITestsFoundation/Screens/Editor/EditorPostSettings.swift +++ b/WordPress/UITestsFoundation/Screens/Editor/EditorPostSettings.swift @@ -47,20 +47,20 @@ public class EditorPostSettings: ScreenObject { $0.buttons.containing(.staticText, identifier: "1").element } - private let doneButtonGetter: (XCUIApplication) -> XCUIElement = { - $0.buttons["Done"] + private let closeButtonGetter: (XCUIApplication) -> XCUIElement = { + $0.navigationBars.buttons["close"] } - private let backButtonGetter: (XCUIApplication) -> XCUIElement = { - $0.navigationBars.buttons.element(boundBy: 0) + private let backButtonGetter: (XCUIApplication) -> XCUIElement? = { + $0.navigationBars.lastMatch?.buttons.element(boundBy: 0) } var categoriesSection: XCUIElement { categoriesSectionGetter(app) } var chooseFromMediaButton: XCUIElement { chooseFromMediaButtonGetter(app) } var currentFeaturedImage: XCUIElement { currentFeaturedImageGetter(app) } var dateSelector: XCUIElement { dateSelectorGetter(app) } - var doneButton: XCUIElement { doneButtonGetter(app) } - var backButton: XCUIElement { backButtonGetter(app) } + var closeButton: XCUIElement { closeButtonGetter(app) } + var backButton: XCUIElement? { backButtonGetter(app) } var featuredImageButton: XCUIElement { featuredImageButtonGetter(app) } var firstCalendarDayButton: XCUIElement { firstCalendarDayButtonGetter(app) } var monthLabel: XCUIElement { monthLabelGetter(app) } @@ -136,7 +136,7 @@ public class EditorPostSettings: ScreenObject { @discardableResult public func closePostSettings() throws -> BlockEditorScreen { - navigateBack() + closeButton.tap() return try BlockEditorScreen() } @@ -160,7 +160,8 @@ public class EditorPostSettings: ScreenObject { firstCalendarDayButton.tapUntil(.selected, failureMessage: "First Day button not selected!") } - backButton.tap() + // Grab the top-most navigation bar + backButton?.tap() return self }