Skip to content

Commit

Permalink
[UI Tests] - Fix failing testCreateScheduledPost test (#22135)
Browse files Browse the repository at this point in the history
* add condition before calendar element tap

* fix Trailing Whitespace Violation
  • Loading branch information
jostnes authored and fluiddot committed Dec 5, 2023
1 parent f80734a commit 1a77b1f
Showing 1 changed file with 12 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,10 @@ public class EditorPostSettings: ScreenObject {
$0.buttons["Next Month"]
}

private let monthLabelGetter: (XCUIApplication) -> XCUIElement = {
$0.buttons["Month"]
}

private let firstCalendarDayButtonGetter: (XCUIApplication) -> XCUIElement = {
$0.buttons.containing(.staticText, identifier: "1").element
}
Expand All @@ -54,6 +58,7 @@ public class EditorPostSettings: ScreenObject {
var doneButton: XCUIElement { doneButtonGetter(app) }
var featuredImageButton: XCUIElement { featuredImageButtonGetter(app) }
var firstCalendarDayButton: XCUIElement { firstCalendarDayButtonGetter(app) }
var monthLabel: XCUIElement { monthLabelGetter(app) }
var nextMonthButton: XCUIElement { nextMonthButtonGetter(app) }
var publishDateButton: XCUIElement { publishDateButtonGetter(app) }
var settingsTable: XCUIElement { settingsTableGetter(app) }
Expand Down Expand Up @@ -139,10 +144,16 @@ public class EditorPostSettings: ScreenObject {
public func updatePublishDateToFutureDate() -> Self {
publishDateButton.tap()
dateSelector.tap()
let currentMonth = monthLabel.value as! String

// Selects the first day of the next month
nextMonthButton.tap()
tapUntilCondition(element: firstCalendarDayButton, condition: firstCalendarDayButton.isSelected, description: "First Day button selected")

// To ensure that the day tap happens on the correct month
let nextMonth = monthLabel.value as! String
if nextMonth != currentMonth {
tapUntilCondition(element: firstCalendarDayButton, condition: firstCalendarDayButton.isSelected, description: "First Day button selected")
}

doneButton.tap()
return self
Expand Down

0 comments on commit 1a77b1f

Please sign in to comment.