-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Move post publish notice interaction to BlockEditorScreen #21414
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
b5e5103
8983993
f5e4ec4
fda6a2b
0af55e8
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 |
|---|---|---|
|
|
@@ -84,6 +84,14 @@ public class BlockEditorScreen: ScreenObject { | |
| $0.staticTexts["You have unsaved changes."] | ||
| } | ||
|
|
||
| private let noticeViewTitleGetter: (XCUIApplication) -> XCUIElement = { | ||
| $0.otherElements["notice_title_and_message"] | ||
| } | ||
|
|
||
| private let noticeViewButtonGetter: (XCUIApplication) -> XCUIElement = { | ||
| $0.buttons["View"] | ||
| } | ||
|
|
||
| var addBlockButton: XCUIElement { addBlockButtonGetter(app) } | ||
| var applyButton: XCUIElement { applyButtonGetter(app) } | ||
| var chooseFromDeviceButton: XCUIElement { chooseFromDeviceButtonGetter(app) } | ||
|
|
@@ -104,6 +112,8 @@ public class BlockEditorScreen: ScreenObject { | |
| var setRemindersButton: XCUIElement { setRemindersButtonGetter(app) } | ||
| var undoButton: XCUIElement { undoButtonGetter(app) } | ||
| var unsavedChangesLabel: XCUIElement { unsavedChangesLabelGetter(app) } | ||
| var noticeViewButton: XCUIElement { noticeViewButtonGetter(app) } | ||
| var noticeViewTitle: XCUIElement { noticeViewTitleGetter(app) } | ||
|
|
||
| public init(app: XCUIApplication = XCUIApplication()) throws { | ||
| // The block editor has _many_ elements but most are loaded on-demand. To verify the screen | ||
|
|
@@ -234,37 +244,43 @@ public class BlockEditorScreen: ScreenObject { | |
| } | ||
| } | ||
|
|
||
| public func publish() throws -> EditorNoticeComponent { | ||
| return try post(action: "Publish") | ||
| private enum postAction: String { | ||
| case publish = "Publish" | ||
| case schedule = "Schedule" | ||
| } | ||
|
|
||
| public func publish() throws { | ||
| return try post(action: .publish) | ||
| } | ||
|
|
||
| public func publishAndViewEpilogue() throws -> EditorPublishEpilogueScreen { | ||
| try publish() | ||
| waitAndTap(noticeViewButton) | ||
| return try EditorPublishEpilogueScreen() | ||
| } | ||
|
|
||
| public func schedulePost() throws -> EditorNoticeComponent { | ||
| return try post(action: "Schedule") | ||
| public func schedulePost() throws { | ||
| try post(action: .schedule) | ||
| } | ||
|
|
||
| private func post(action: String) throws -> EditorNoticeComponent { | ||
| let postButton = app.buttons[action] | ||
| let postNowButton = app.buttons["\(action) Now"] | ||
| public func schedulePostAndViewEpilogue() throws -> EditorPublishEpilogueScreen { | ||
| try schedulePost() | ||
| waitAndTap(noticeViewButton) | ||
| return try EditorPublishEpilogueScreen() | ||
| } | ||
|
||
|
|
||
| private func post(action: postAction) throws { | ||
| let postButton = app.buttons[action.rawValue] | ||
| let postNowButton = app.buttons["\(action.rawValue) Now"] | ||
| var tries = 0 | ||
| // This loop to check for Publish/Schedule Now Button is an attempt to confirm that the postButton.tap() call took effect. | ||
| // The tests would fail sometimes in the pipeline with no apparent reason. | ||
| repeat { | ||
| postButton.tap() | ||
| tries += 1 | ||
| } while !postNowButton.waitForIsHittable(timeout: 3) && tries <= 3 | ||
| try confirmPost(button: postNowButton) | ||
|
|
||
| let actionInNotice: String | ||
|
|
||
| if action == "Schedule" { | ||
| actionInNotice = "scheduled" | ||
| } else if action == "Publish" { | ||
| actionInNotice = "published" | ||
| } else { | ||
| throw NSError(domain: "InvalidAction", code: 0, userInfo: [NSLocalizedDescriptionKey: "Invalid action: \(action)"]) | ||
| } | ||
|
|
||
| return try EditorNoticeComponent(withNotice: "Post \(actionInNotice)") | ||
| try confirmPost(button: postNowButton, action: action) | ||
| } | ||
|
|
||
| @discardableResult | ||
|
|
@@ -402,13 +418,10 @@ public class BlockEditorScreen: ScreenObject { | |
| .selectAlbum(atIndex: 0) | ||
| } | ||
|
|
||
| private func confirmPost(button: XCUIElement) throws { | ||
| if FancyAlertComponent.isLoaded() { | ||
| try FancyAlertComponent().acceptAlert() | ||
|
Comment on lines
-402
to
-403
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 don't know which FancyAlert we could expect here. I've run all the editor tests several times and haven't seen it. We are saving some time here but it doesn't impact the target issue as it comes before tapping the |
||
| } else { | ||
| button.tap() | ||
| dismissBloggingRemindersAlertIfNeeded() | ||
| } | ||
| private func confirmPost(button: XCUIElement, action: postAction) throws { | ||
| button.tap() | ||
| guard action == .publish else { return } | ||
| dismissBloggingRemindersAlertIfNeeded() | ||
|
Comment on lines
+405
to
+406
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. Blogging Reminder is only displayed when a post is published, so we can save the 3 seconds timeout from |
||
| } | ||
|
|
||
| public func dismissBloggingRemindersAlertIfNeeded() { | ||
|
|
||
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.
super nitpick - one of the things i'm trying to do is to sort the vars here alphabetically so it's easier to scan through the list of available elements, do you mind moving this alphabetically too? 🙏
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.
Nice! Moved these and a few others, as well as the getters, in f5e4ec4.