-
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
Merged
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
b5e5103
Move post publish notice interaction to BlockEditorScreen
tiagomar 8983993
empty commit to trigger tests
jostnes f5e4ec4
Sort variables alphabetically
tiagomar fda6a2b
Merge branch 'trunk' into ui-tests-improve-scheduled-post-test
tiagomar 0af55e8
Verify scheduled post in post list.
tiagomar File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -4,80 +4,88 @@ import XCUITestHelpers | |
|
|
||
| public class BlockEditorScreen: ScreenObject { | ||
|
|
||
| private let editorCloseButtonGetter: (XCUIApplication) -> XCUIElement = { | ||
| $0.navigationBars["Gutenberg Editor Navigation Bar"].buttons["Close"] | ||
| } | ||
|
|
||
| private let undoButtonGetter: (XCUIApplication) -> XCUIElement = { | ||
| $0.navigationBars["Gutenberg Editor Navigation Bar"].buttons["Undo"] | ||
| } | ||
|
|
||
| private let redoButtonGetter: (XCUIApplication) -> XCUIElement = { | ||
| $0.navigationBars["Gutenberg Editor Navigation Bar"].buttons["Redo"] | ||
| } | ||
|
|
||
| private let addBlockButtonGetter: (XCUIApplication) -> XCUIElement = { | ||
| $0.buttons["add-block-button"] | ||
| } | ||
|
|
||
| private let moreButtonGetter: (XCUIApplication) -> XCUIElement = { | ||
| $0.buttons["more_post_options"] | ||
| private let applyButtonGetter: (XCUIApplication) -> XCUIElement = { | ||
| $0.buttons["Apply"] | ||
| } | ||
|
|
||
| private let insertFromUrlButtonGetter: (XCUIApplication) -> XCUIElement = { | ||
| $0.buttons["Insert from URL"] | ||
| private let chooseFromDeviceButtonGetter: (XCUIApplication) -> XCUIElement = { | ||
| $0.buttons["Choose from device"] | ||
| } | ||
|
|
||
| private let applyButtonGetter: (XCUIApplication) -> XCUIElement = { | ||
| $0.buttons["Apply"] | ||
| private let closeButtonGetter: (XCUIApplication) -> XCUIElement = { | ||
| $0.buttons["Close"] | ||
| } | ||
|
|
||
| private let discardButtonGetter: (XCUIApplication) -> XCUIElement = { | ||
| $0.buttons["Discard"] | ||
| } | ||
|
|
||
| private let firstParagraphBlockGetter: (XCUIApplication) -> XCUIElement = { | ||
| $0.otherElements["Paragraph Block. Row 1. Empty"] | ||
| private let dismissPopoverRegionGetter: (XCUIApplication) -> XCUIElement = { | ||
| $0.otherElements["PopoverDismissRegion"] | ||
| } | ||
|
|
||
| private let postTitleViewGetter: (XCUIApplication) -> XCUIElement = { | ||
| $0.otherElements["Post title. Empty"] | ||
| private let editorCloseButtonGetter: (XCUIApplication) -> XCUIElement = { | ||
| $0.navigationBars["Gutenberg Editor Navigation Bar"].buttons["Close"] | ||
| } | ||
|
|
||
| private let editorNavigationBarGetter: (XCUIApplication) -> XCUIElement = { | ||
| $0.navigationBars["Gutenberg Editor Navigation Bar"] | ||
| } | ||
|
|
||
| private let closeButtonGetter: (XCUIApplication) -> XCUIElement = { | ||
| $0.buttons["Close"] | ||
| private let firstParagraphBlockGetter: (XCUIApplication) -> XCUIElement = { | ||
| $0.otherElements["Paragraph Block. Row 1. Empty"] | ||
| } | ||
|
|
||
| private let dismissPopoverRegionGetter: (XCUIApplication) -> XCUIElement = { | ||
| $0.otherElements["PopoverDismissRegion"] | ||
| private let fullScreenImageGetter: (XCUIApplication) -> XCUIElement = { | ||
| $0.images["Fullscreen view of image. Double tap to dismiss"] | ||
| } | ||
|
|
||
| private let insertFromUrlButtonGetter: (XCUIApplication) -> XCUIElement = { | ||
| $0.buttons["Insert from URL"] | ||
| } | ||
|
|
||
| private let keepEditingButtonGetter: (XCUIApplication) -> XCUIElement = { | ||
| $0.buttons["Keep Editing"] | ||
| } | ||
|
|
||
| private let moreButtonGetter: (XCUIApplication) -> XCUIElement = { | ||
| $0.buttons["more_post_options"] | ||
| } | ||
|
|
||
| private let noticeViewButtonGetter: (XCUIApplication) -> XCUIElement = { | ||
| $0.buttons["View"] | ||
| } | ||
|
|
||
| private let noticeViewTitleGetter: (XCUIApplication) -> XCUIElement = { | ||
| $0.otherElements["notice_title_and_message"] | ||
| } | ||
|
|
||
| private let postSettingsButtonGetter: (XCUIApplication) -> XCUIElement = { | ||
| $0.buttons["Post Settings"] | ||
| } | ||
|
|
||
| private let switchToHTMLModeButtonGetter: (XCUIApplication) -> XCUIElement = { | ||
| $0.buttons["Switch to HTML Mode"] | ||
| private let postTitleViewGetter: (XCUIApplication) -> XCUIElement = { | ||
| $0.otherElements["Post title. Empty"] | ||
| } | ||
|
|
||
| private let chooseFromDeviceButtonGetter: (XCUIApplication) -> XCUIElement = { | ||
| $0.buttons["Choose from device"] | ||
| private let redoButtonGetter: (XCUIApplication) -> XCUIElement = { | ||
| $0.navigationBars["Gutenberg Editor Navigation Bar"].buttons["Redo"] | ||
| } | ||
|
|
||
| private let setRemindersButtonGetter: (XCUIApplication) -> XCUIElement = { | ||
| $0.buttons["Set reminders"] | ||
| } | ||
|
|
||
| private let fullScreenImageGetter: (XCUIApplication) -> XCUIElement = { | ||
| $0.images["Fullscreen view of image. Double tap to dismiss"] | ||
| private let switchToHTMLModeButtonGetter: (XCUIApplication) -> XCUIElement = { | ||
| $0.buttons["Switch to HTML Mode"] | ||
| } | ||
|
|
||
| private let undoButtonGetter: (XCUIApplication) -> XCUIElement = { | ||
| $0.navigationBars["Gutenberg Editor Navigation Bar"].buttons["Undo"] | ||
| } | ||
|
|
||
| private let unsavedChangesLabelGetter: (XCUIApplication) -> XCUIElement = { | ||
|
|
@@ -97,11 +105,13 @@ public class BlockEditorScreen: ScreenObject { | |
| var insertFromUrlButton: XCUIElement { insertFromUrlButtonGetter(app) } | ||
| var keepEditingButton: XCUIElement { keepEditingButtonGetter(app) } | ||
| var moreButton: XCUIElement { moreButtonGetter(app) } | ||
| var noticeViewButton: XCUIElement { noticeViewButtonGetter(app) } | ||
| var noticeViewTitle: XCUIElement { noticeViewTitleGetter(app) } | ||
| var postSettingsButton: XCUIElement { postSettingsButtonGetter(app) } | ||
| var switchToHTMLModeButton: XCUIElement { switchToHTMLModeButtonGetter(app) } | ||
| var postTitleView: XCUIElement { postTitleViewGetter(app) } | ||
| var redoButton: XCUIElement { redoButtonGetter(app) } | ||
| var setRemindersButton: XCUIElement { setRemindersButtonGetter(app) } | ||
| var switchToHTMLModeButton: XCUIElement { switchToHTMLModeButtonGetter(app) } | ||
| var undoButton: XCUIElement { undoButtonGetter(app) } | ||
| var unsavedChangesLabel: XCUIElement { unsavedChangesLabelGetter(app) } | ||
|
|
||
|
|
@@ -234,37 +244,29 @@ public class BlockEditorScreen: ScreenObject { | |
| } | ||
| } | ||
|
|
||
| public func publish() throws -> EditorNoticeComponent { | ||
| return try post(action: "Publish") | ||
| public enum postAction: String { | ||
| case publish = "Publish" | ||
| case schedule = "Schedule" | ||
| } | ||
|
|
||
| public func schedulePost() throws -> EditorNoticeComponent { | ||
| return try post(action: "Schedule") | ||
| public func postAndViewEpilogue(action: postAction) throws -> EditorPublishEpilogueScreen { | ||
| try post(action: action) | ||
| waitAndTap(noticeViewButton) | ||
| return try EditorPublishEpilogueScreen() | ||
| } | ||
|
|
||
| private func post(action: String) throws -> EditorNoticeComponent { | ||
| let postButton = app.buttons[action] | ||
| let postNowButton = app.buttons["\(action) Now"] | ||
| public 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 | ||
|
|
@@ -398,13 +400,10 @@ public class BlockEditorScreen: ScreenObject { | |
| return try PHPickerScreen() | ||
| } | ||
|
|
||
| private func confirmPost(button: XCUIElement) throws { | ||
| if FancyAlertComponent.isLoaded() { | ||
| try FancyAlertComponent().acceptAlert() | ||
| } 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() { | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
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
Schedule Nowbutton.