@@ -4,80 +4,88 @@ import XCUITestHelpers
44
55public class BlockEditorScreen : ScreenObject {
66
7- private let editorCloseButtonGetter : ( XCUIApplication ) -> XCUIElement = {
8- $0. navigationBars [ " Gutenberg Editor Navigation Bar " ] . buttons [ " Close " ]
9- }
10-
11- private let undoButtonGetter : ( XCUIApplication ) -> XCUIElement = {
12- $0. navigationBars [ " Gutenberg Editor Navigation Bar " ] . buttons [ " Undo " ]
13- }
14-
15- private let redoButtonGetter : ( XCUIApplication ) -> XCUIElement = {
16- $0. navigationBars [ " Gutenberg Editor Navigation Bar " ] . buttons [ " Redo " ]
17- }
18-
197 private let addBlockButtonGetter : ( XCUIApplication ) -> XCUIElement = {
208 $0. buttons [ " add-block-button " ]
219 }
2210
23- private let moreButtonGetter : ( XCUIApplication ) -> XCUIElement = {
24- $0. buttons [ " more_post_options " ]
11+ private let applyButtonGetter : ( XCUIApplication ) -> XCUIElement = {
12+ $0. buttons [ " Apply " ]
2513 }
2614
27- private let insertFromUrlButtonGetter : ( XCUIApplication ) -> XCUIElement = {
28- $0. buttons [ " Insert from URL " ]
15+ private let chooseFromDeviceButtonGetter : ( XCUIApplication ) -> XCUIElement = {
16+ $0. buttons [ " Choose from device " ]
2917 }
3018
31- private let applyButtonGetter : ( XCUIApplication ) -> XCUIElement = {
32- $0. buttons [ " Apply " ]
19+ private let closeButtonGetter : ( XCUIApplication ) -> XCUIElement = {
20+ $0. buttons [ " Close " ]
3321 }
3422
3523 private let discardButtonGetter : ( XCUIApplication ) -> XCUIElement = {
3624 $0. buttons [ " Discard " ]
3725 }
3826
39- private let firstParagraphBlockGetter : ( XCUIApplication ) -> XCUIElement = {
40- $0. otherElements [ " Paragraph Block. Row 1. Empty " ]
27+ private let dismissPopoverRegionGetter : ( XCUIApplication ) -> XCUIElement = {
28+ $0. otherElements [ " PopoverDismissRegion " ]
4129 }
4230
43- private let postTitleViewGetter : ( XCUIApplication ) -> XCUIElement = {
44- $0. otherElements [ " Post title. Empty " ]
31+ private let editorCloseButtonGetter : ( XCUIApplication ) -> XCUIElement = {
32+ $0. navigationBars [ " Gutenberg Editor Navigation Bar " ] . buttons [ " Close " ]
4533 }
4634
4735 private let editorNavigationBarGetter : ( XCUIApplication ) -> XCUIElement = {
4836 $0. navigationBars [ " Gutenberg Editor Navigation Bar " ]
4937 }
5038
51- private let closeButtonGetter : ( XCUIApplication ) -> XCUIElement = {
52- $0. buttons [ " Close " ]
39+ private let firstParagraphBlockGetter : ( XCUIApplication ) -> XCUIElement = {
40+ $0. otherElements [ " Paragraph Block. Row 1. Empty " ]
5341 }
5442
55- private let dismissPopoverRegionGetter : ( XCUIApplication ) -> XCUIElement = {
56- $0. otherElements [ " PopoverDismissRegion " ]
43+ private let fullScreenImageGetter : ( XCUIApplication ) -> XCUIElement = {
44+ $0. images [ " Fullscreen view of image. Double tap to dismiss " ]
45+ }
46+
47+ private let insertFromUrlButtonGetter : ( XCUIApplication ) -> XCUIElement = {
48+ $0. buttons [ " Insert from URL " ]
5749 }
5850
5951 private let keepEditingButtonGetter : ( XCUIApplication ) -> XCUIElement = {
6052 $0. buttons [ " Keep Editing " ]
6153 }
6254
55+ private let moreButtonGetter : ( XCUIApplication ) -> XCUIElement = {
56+ $0. buttons [ " more_post_options " ]
57+ }
58+
59+ private let noticeViewButtonGetter : ( XCUIApplication ) -> XCUIElement = {
60+ $0. buttons [ " View " ]
61+ }
62+
63+ private let noticeViewTitleGetter : ( XCUIApplication ) -> XCUIElement = {
64+ $0. otherElements [ " notice_title_and_message " ]
65+ }
66+
6367 private let postSettingsButtonGetter : ( XCUIApplication ) -> XCUIElement = {
6468 $0. buttons [ " Post Settings " ]
6569 }
6670
67- private let switchToHTMLModeButtonGetter : ( XCUIApplication ) -> XCUIElement = {
68- $0. buttons [ " Switch to HTML Mode " ]
71+ private let postTitleViewGetter : ( XCUIApplication ) -> XCUIElement = {
72+ $0. otherElements [ " Post title. Empty " ]
6973 }
7074
71- private let chooseFromDeviceButtonGetter : ( XCUIApplication ) -> XCUIElement = {
72- $0. buttons [ " Choose from device " ]
75+ private let redoButtonGetter : ( XCUIApplication ) -> XCUIElement = {
76+ $0. navigationBars [ " Gutenberg Editor Navigation Bar " ] . buttons [ " Redo " ]
7377 }
7478
7579 private let setRemindersButtonGetter : ( XCUIApplication ) -> XCUIElement = {
7680 $0. buttons [ " Set reminders " ]
7781 }
7882
79- private let fullScreenImageGetter : ( XCUIApplication ) -> XCUIElement = {
80- $0. images [ " Fullscreen view of image. Double tap to dismiss " ]
83+ private let switchToHTMLModeButtonGetter : ( XCUIApplication ) -> XCUIElement = {
84+ $0. buttons [ " Switch to HTML Mode " ]
85+ }
86+
87+ private let undoButtonGetter : ( XCUIApplication ) -> XCUIElement = {
88+ $0. navigationBars [ " Gutenberg Editor Navigation Bar " ] . buttons [ " Undo " ]
8189 }
8290
8391 private let unsavedChangesLabelGetter : ( XCUIApplication ) -> XCUIElement = {
@@ -97,11 +105,13 @@ public class BlockEditorScreen: ScreenObject {
97105 var insertFromUrlButton : XCUIElement { insertFromUrlButtonGetter ( app) }
98106 var keepEditingButton : XCUIElement { keepEditingButtonGetter ( app) }
99107 var moreButton : XCUIElement { moreButtonGetter ( app) }
108+ var noticeViewButton : XCUIElement { noticeViewButtonGetter ( app) }
109+ var noticeViewTitle : XCUIElement { noticeViewTitleGetter ( app) }
100110 var postSettingsButton : XCUIElement { postSettingsButtonGetter ( app) }
101- var switchToHTMLModeButton : XCUIElement { switchToHTMLModeButtonGetter ( app) }
102111 var postTitleView : XCUIElement { postTitleViewGetter ( app) }
103112 var redoButton : XCUIElement { redoButtonGetter ( app) }
104113 var setRemindersButton : XCUIElement { setRemindersButtonGetter ( app) }
114+ var switchToHTMLModeButton : XCUIElement { switchToHTMLModeButtonGetter ( app) }
105115 var undoButton : XCUIElement { undoButtonGetter ( app) }
106116 var unsavedChangesLabel : XCUIElement { unsavedChangesLabelGetter ( app) }
107117
@@ -234,37 +244,29 @@ public class BlockEditorScreen: ScreenObject {
234244 }
235245 }
236246
237- public func publish( ) throws -> EditorNoticeComponent {
238- return try post ( action: " Publish " )
247+ public enum postAction : String {
248+ case publish = " Publish "
249+ case schedule = " Schedule "
239250 }
240251
241- public func schedulePost( ) throws -> EditorNoticeComponent {
242- return try post ( action: " Schedule " )
252+ public func postAndViewEpilogue( action: postAction ) throws -> EditorPublishEpilogueScreen {
253+ try post ( action: action)
254+ waitAndTap ( noticeViewButton)
255+ return try EditorPublishEpilogueScreen ( )
243256 }
244257
245- private func post( action: String ) throws -> EditorNoticeComponent {
246- let postButton = app. buttons [ action]
247- let postNowButton = app. buttons [ " \( action) Now " ]
258+ public func post( action: postAction ) throws {
259+ let postButton = app. buttons [ action. rawValue ]
260+ let postNowButton = app. buttons [ " \( action. rawValue ) Now " ]
248261 var tries = 0
249262 // This loop to check for Publish/Schedule Now Button is an attempt to confirm that the postButton.tap() call took effect.
250263 // The tests would fail sometimes in the pipeline with no apparent reason.
251264 repeat {
252265 postButton. tap ( )
253266 tries += 1
254267 } while !postNowButton. waitForIsHittable ( timeout: 3 ) && tries <= 3
255- try confirmPost ( button: postNowButton)
256268
257- let actionInNotice : String
258-
259- if action == " Schedule " {
260- actionInNotice = " scheduled "
261- } else if action == " Publish " {
262- actionInNotice = " published "
263- } else {
264- throw NSError ( domain: " InvalidAction " , code: 0 , userInfo: [ NSLocalizedDescriptionKey: " Invalid action: \( action) " ] )
265- }
266-
267- return try EditorNoticeComponent ( withNotice: " Post \( actionInNotice) " )
269+ try confirmPost ( button: postNowButton, action: action)
268270 }
269271
270272 @discardableResult
@@ -398,13 +400,10 @@ public class BlockEditorScreen: ScreenObject {
398400 return try PHPickerScreen ( )
399401 }
400402
401- private func confirmPost( button: XCUIElement ) throws {
402- if FancyAlertComponent . isLoaded ( ) {
403- try FancyAlertComponent ( ) . acceptAlert ( )
404- } else {
405- button. tap ( )
406- dismissBloggingRemindersAlertIfNeeded ( )
407- }
403+ private func confirmPost( button: XCUIElement , action: postAction ) throws {
404+ button. tap ( )
405+ guard action == . publish else { return }
406+ dismissBloggingRemindersAlertIfNeeded ( )
408407 }
409408
410409 public func dismissBloggingRemindersAlertIfNeeded( ) {
0 commit comments