-
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
Conversation
| guard action == .publish else { return } | ||
| 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.
Blogging Reminder is only displayed when a post is published, so we can save the 3 seconds timeout from dismissBloggingRemindersAlertIfNeeded() when scheduling a post. ⏱️
| if FancyAlertComponent.isLoaded() { | ||
| try FancyAlertComponent().acceptAlert() |
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 Now button.
|
| App Name | WordPress Alpha |
|
| Configuration | Release-Alpha | |
| Build Number | pr21414-0af55e8 | |
| Version | 23.1 | |
| Bundle ID | org.wordpress.alpha | |
| Commit | 0af55e8 | |
| App Center Build | WPiOS - One-Offs #6887 |
|
| App Name | Jetpack Alpha |
|
| Configuration | Release-Alpha | |
| Build Number | pr21414-0af55e8 | |
| Version | 23.1 | |
| Bundle ID | com.jetpack.alpha | |
| Commit | 0af55e8 | |
| App Center Build | jetpack-installable-builds #5927 |
|
Thanks for following up on the review comment @tiagomar! The changes look fine, but I noticed that the execution time for iPad has increased quite a bit: I'm not sure if it was just a coincidence (random slowness does happen in CI), but to be sure, I'm pushing an empty commit to this PR to make it run the tests again on iPad. |
jostnes
left a comment
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.
left a suggestion to DRY the code and one really nitpicky one, other than that I think the code looks good!
| var noticeViewButton: XCUIElement { noticeViewButtonGetter(app) } | ||
| var noticeViewTitle: XCUIElement { noticeViewTitleGetter(app) } |
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? 🙏
var addBlockButton: XCUIElement { addBlockButtonGetter(app) }
var applyButton: XCUIElement { applyButtonGetter(app) }
var chooseFromDeviceButton: XCUIElement { chooseFromDeviceButtonGetter(app) }
var closeButton: XCUIElement { closeButtonGetter(app) }
var discardButton: XCUIElement { discardButtonGetter(app) }
var dismissPopoverRegion: XCUIElement { dismissPopoverRegionGetter(app) }
var editorCloseButton: XCUIElement { editorCloseButtonGetter(app) }
var editorNavigationBar: XCUIElement { editorNavigationBarGetter(app) }
var firstParagraphBlock: XCUIElement { firstParagraphBlockGetter(app) }
var fullScreenImage: XCUIElement { fullScreenImageGetter(app) }
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 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) }
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.
| 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() | ||
| } |
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 think we can DRY this further, possibly by moving the ViewEpilogue part of the method into the post(action: postAction)? this way we won't need to create publishAndViewEpilogue() and schedulePostAndViewEpilogue(). wdyt?
something like:
public func publish() throws -> EditorPublishEpilogueScreen {
return try postAndViewEpilogue(action: .publish)
}
public func schedulePost() throws -> EditorPublishEpilogueScreen {
return try postAndViewEpilogue(action: .schedule)
}
private func postAndViewEpilogue(action: postAction) throws -> EditorPublishEpilogueScreen {
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, action: action)
waitAndTap(noticeViewButton)
return try EditorPublishEpilogueScreen()
}
or if we want to keep post and view epilogue separate, we can DRY it by calling post(action: postAction) directly in publishAndViewEpilogue():
public func publishAndViewEpilogue() throws -> EditorPublishEpilogueScreen {
try post(action: .publish)
waitAndTap(noticeViewButton)
return try EditorPublishEpilogueScreen()
}
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.
Good point, @jostnes! While working on it I decided to keep publish() in order make it possible to publish without viewing the Epilogue and maybe go to Posts or somewhere else right away? Not deeply attached to it though. WDYT?
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.
yeah think that makes sense and very possible that we'd want to use it without viewing Epilogue so I think that's fine to keep it that way.
my second suggestion above is about publishAndViewEpilogue(), where instead of calling publish() or schedulePost, we call try post(action: PostAction) directly to remove that one extra level. not sure if it'll make a big difference in terms of timing but i think keeping the calls as direct as possible (when/if possible) usually helps with timing issues in UI tests. wdyt?
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.
Totally! Addressed in 0af55e8.
|
And the long execution you mentioned previously #21414 (comment) cause the While the current improvements benefit other tests, I start to think that, for |
i think the same, the |
jostnes
left a comment
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.
Thank you for considering the changes, CI is 🟢 , it's good to ![]()




Description
This PR moves the interaction with the post publish notice from its dedicated Screen Object into BlockEditorScreen to mitigate the risk of the notice being gone by the time the script tries to tap the
Viewbutton, as discussed in #21402 (review). The notice doesn't last long in the screen and the Screen Object init takes up to a couple seconds, which is quite relevant especially running in CI. 12 out of 17 failures have the same error caused by this timing issue. The changes in this PR saves up to 3-4 seconds for thetestCreateScheduledPost()between tapping theSchedule Nowbutton and tapping the notice'sViewbutton.Testing
CI should be 🟢