Skip to content
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

Refactored all unit tests that were failing due to language localizati… #4543

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
276 changes: 276 additions & 0 deletions Wikipedia.xcodeproj/project.pbxproj

Large diffs are not rendered by default.

10 changes: 5 additions & 5 deletions WikipediaUnitTests/Code/Date+ExtensionTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -56,11 +56,11 @@ class Date_ExtensionTests: XCTestCase {
let oneMonthAgoDate = Calendar.current.date(byAdding: DateComponents(month: -1), to: testDate)! as NSDate
let futureDate = Calendar.current.date(byAdding: DateComponents(month: 1), to: testDate)! as NSDate

XCTAssertEqual((testDate as NSDate).wmf_localizedShortDateStringRelative(to: testDate), "Now")
XCTAssertEqual(oneMinuteAgoDate.wmf_localizedShortDateStringRelative(to: testDate), "1 min ago")
XCTAssertEqual(thirtyMinutesAgoDate.wmf_localizedShortDateStringRelative(to: testDate), "30 mins ago")
XCTAssertEqual(oneHourAgoDate.wmf_localizedShortDateStringRelative(to: testDate), "1 hr ago")
XCTAssertEqual(tenHoursAgoDate.wmf_localizedShortDateStringRelative(to: testDate), "10 hrs ago")
XCTAssertEqual((testDate as NSDate).wmf_localizedShortDateStringRelative(to: testDate), "Now".localized)
XCTAssertEqual(oneMinuteAgoDate.wmf_localizedShortDateStringRelative(to: testDate), "1 min ago".localized)
XCTAssertEqual(thirtyMinutesAgoDate.wmf_localizedShortDateStringRelative(to: testDate), "30 mins ago".localized)
XCTAssertEqual(oneHourAgoDate.wmf_localizedShortDateStringRelative(to: testDate), "1 hr ago".localized)
XCTAssertEqual(tenHoursAgoDate.wmf_localizedShortDateStringRelative(to: testDate), "10 hrs ago".localized)
XCTAssertEqual(twentyFourHoursAgoDate.wmf_localizedShortDateStringRelative(to: testDate), "10/19/21")
XCTAssertEqual(oneDayAgoDate.wmf_localizedShortDateStringRelative(to: testDate), "10/19/21")
XCTAssertEqual(oneMonthAgoDate.wmf_localizedShortDateStringRelative(to: testDate), "9/20/21")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ class NotificationsCenterCellViewModelEditMilestoneTests: NotificationsCenterVie

private func testEditMilestoneOneOnUserPageText(cellViewModel: NotificationsCenterCellViewModel) throws {
XCTAssertEqual(cellViewModel.headerText, "Editing milestone", "Invalid headerText")
XCTAssertEqual(cellViewModel.subheaderText, "English Wikipedia", "Invalid subheaderText")
XCTAssertEqual(cellViewModel.subheaderText, "English Wikipedia".localized, "Invalid subheaderText")
XCTAssertEqual(cellViewModel.bodyText, "You just made your first edit; thank you, and welcome!")
XCTAssertEqual(cellViewModel.footerText, "User:Fred The Bird", "Invalid footerText")
XCTAssertEqual(cellViewModel.dateText, "4/2/19", "Invalid dateText")
Expand All @@ -62,14 +62,14 @@ class NotificationsCenterCellViewModelEditMilestoneTests: NotificationsCenterVie

XCTAssertEqual(cellViewModel.sheetActions.count, 2, "Invalid sheetActionsCount")

let expectedText0 = "Mark as unread"
let expectedText0 = "Mark as unread".localized
let expectedURL0: URL? = nil
let expectedIcon0: NotificationsCenterIconType? = nil
let expectedDestinationText0: String? = nil
let expectedAction0: NotificationsCenterActionData.LoggingLabel = .markUnread
try testActions(expectedText: expectedText0, expectedURL: expectedURL0, expectedIcon: expectedIcon0, expectedDestinationText: expectedDestinationText0, actionToTest: cellViewModel.sheetActions[0], isMarkAsRead: true, actionType: expectedAction0)

let expectedText1 = "Notification settings"
let expectedText1 = "Notification settings".localized
let expectedURL1: URL? = nil
let expectedIcon1: NotificationsCenterIconType? = nil
let expectedDestinationText1: String? = nil
Expand All @@ -80,7 +80,7 @@ class NotificationsCenterCellViewModelEditMilestoneTests: NotificationsCenterVie

private func testEditMilestoneTenOnArticleText(cellViewModel: NotificationsCenterCellViewModel) throws {
XCTAssertEqual(cellViewModel.headerText, "Editing milestone", "Invalid headerText")
XCTAssertEqual(cellViewModel.subheaderText, "English Wikipedia", "Invalid subheaderText")
XCTAssertEqual(cellViewModel.subheaderText, "English Wikipedia".localized, "Invalid subheaderText")
XCTAssertEqual(cellViewModel.bodyText, "You just made your tenth edit; thank you, and please keep going!")
XCTAssertEqual(cellViewModel.footerText, "Blue Bird", "Invalid footerText")
XCTAssertEqual(cellViewModel.dateText, "4/16/19", "Invalid dateText")
Expand All @@ -96,14 +96,14 @@ class NotificationsCenterCellViewModelEditMilestoneTests: NotificationsCenterVie

XCTAssertEqual(cellViewModel.sheetActions.count, 2, "Invalid sheetActionsCount")

let expectedText0 = "Mark as unread"
let expectedText0 = "Mark as unread".localized
let expectedURL0: URL? = nil
let expectedIcon0: NotificationsCenterIconType? = nil
let expectedDestinationText0: String? = nil
let expectedAction0: NotificationsCenterActionData.LoggingLabel = .markUnread
try testActions(expectedText: expectedText0, expectedURL: expectedURL0, expectedIcon: expectedIcon0, expectedDestinationText: expectedDestinationText0, actionToTest: cellViewModel.sheetActions[0], isMarkAsRead: true, actionType: expectedAction0)

let expectedText1 = "Notification settings"
let expectedText1 = "Notification settings".localized
let expectedURL1: URL? = nil
let expectedIcon1: NotificationsCenterIconType? = nil
let expectedDestinationText1: String? = nil
Expand All @@ -114,10 +114,10 @@ class NotificationsCenterCellViewModelEditMilestoneTests: NotificationsCenterVie

private func testEditMilestoneHundredOnUserTalkPageText(cellViewModel: NotificationsCenterCellViewModel) throws {
XCTAssertEqual(cellViewModel.headerText, "Editing milestone", "Invalid headerText")
XCTAssertEqual(cellViewModel.subheaderText, "English Wikipedia", "Invalid subheaderText")
XCTAssertEqual(cellViewModel.subheaderText, "English Wikipedia".localized, "Invalid subheaderText")
XCTAssertEqual(cellViewModel.bodyText, "You just made your hundredth edit; thank you very much!")
XCTAssertEqual(cellViewModel.footerText, "User talk:Fred The Bird", "Invalid footerText")
XCTAssertEqual(cellViewModel.dateText, "7/16/21", "Invalid dateText")
XCTAssertEqual(cellViewModel.dateText, "7/17/21", "Invalid dateText")
XCTAssertEqual(cellViewModel.projectText, "EN", "Invalid projectText")
}

Expand All @@ -130,14 +130,14 @@ class NotificationsCenterCellViewModelEditMilestoneTests: NotificationsCenterVie

XCTAssertEqual(cellViewModel.sheetActions.count, 2, "Invalid sheetActionsCount")

let expectedText0 = "Mark as unread"
let expectedText0 = "Mark as unread".localized
let expectedURL0: URL? = nil
let expectedIcon0: NotificationsCenterIconType? = nil
let expectedDestinationText0: String? = nil
let expectedAction0: NotificationsCenterActionData.LoggingLabel = .markUnread
try testActions(expectedText: expectedText0, expectedURL: expectedURL0, expectedIcon: expectedIcon0, expectedDestinationText: expectedDestinationText0, actionToTest: cellViewModel.sheetActions[0], isMarkAsRead: true, actionType: expectedAction0)

let expectedText1 = "Notification settings"
let expectedText1 = "Notification settings".localized
let expectedURL1: URL? = nil
let expectedIcon1: NotificationsCenterIconType? = nil
let expectedDestinationText1: String? = nil
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ class NotificationsCenterCellViewModelEditRevertedTests: NotificationsCenterView

private func testEditRevertedOnUserTalkEditText(cellViewModel: NotificationsCenterCellViewModel) throws {
XCTAssertEqual(cellViewModel.headerText, "Your edit was reverted", "Invalid headerText")
XCTAssertEqual(cellViewModel.subheaderText, "From Fred The Bird", "Invalid subheaderText")
XCTAssertEqual(cellViewModel.subheaderText, "From Fred The Bird".localized, "Invalid subheaderText")
XCTAssertEqual(cellViewModel.bodyText, nil)
XCTAssertEqual(cellViewModel.footerText, "User talk:Fred The Bird", "Invalid footerText")
XCTAssertEqual(cellViewModel.dateText, "7/19/21", "Invalid dateText")
Expand All @@ -49,7 +49,7 @@ class NotificationsCenterCellViewModelEditRevertedTests: NotificationsCenterView

XCTAssertEqual(cellViewModel.sheetActions.count, 5, "Invalid sheetActionsCount")

let expectedText0 = "Mark as unread"
let expectedText0 = "Mark as unread".localized
let expectedURL0: URL? = nil
let expectedIcon0: NotificationsCenterIconType? = nil
let expectedDestinationText0: String? = nil
Expand All @@ -63,21 +63,21 @@ class NotificationsCenterCellViewModelEditRevertedTests: NotificationsCenterView
let expectedAction1: NotificationsCenterActionData.LoggingLabel = .diff
try testActions(expectedText: expectedText1, expectedURL: expectedURL1, expectedIcon: expectedIcon1, expectedDestinationText: expectedDestinationText1, actionToTest: cellViewModel.sheetActions[1], actionType: expectedAction1)

let expectedText2 = "Fred The Bird\'s user page"
let expectedText2 = "Fred The Bird\'s user page".localized
let expectedURL2: URL? = URL(string: "https://en.wikipedia.org/wiki/User:Fred_The_Bird")!
let expectedIcon2: NotificationsCenterIconType = .person
let expectedDestinationText2 = "On web"
let expectedAction2: NotificationsCenterActionData.LoggingLabel = .senderPage
try testActions(expectedText: expectedText2, expectedURL: expectedURL2, expectedIcon: expectedIcon2, expectedDestinationText: expectedDestinationText2, actionToTest: cellViewModel.sheetActions[2], actionType: expectedAction2)

let expectedText3 = "Talk page"
let expectedText3 = "Talk page".localized
let expectedURL3: URL? = URL(string: "https://en.wikipedia.org/wiki/User_talk:Fred_The_Bird")!
let expectedIcon3: NotificationsCenterIconType = .document
let expectedDestinationText3 = "In app"
let expectedAction3: NotificationsCenterActionData.LoggingLabel = .userTalk
try testActions(expectedText: expectedText3, expectedURL: expectedURL3, expectedIcon: expectedIcon3, expectedDestinationText: expectedDestinationText3, actionToTest: cellViewModel.sheetActions[3], actionType: expectedAction3)

let expectedText4 = "Notification settings"
let expectedText4 = "Notification settings".localized
let expectedURL4: URL? = nil
let expectedIcon4: NotificationsCenterIconType? = nil
let expectedDestinationText4: String? = nil
Expand All @@ -87,7 +87,7 @@ class NotificationsCenterCellViewModelEditRevertedTests: NotificationsCenterView

private func testEditRevertedOnArticleEditText(cellViewModel: NotificationsCenterCellViewModel) throws {
XCTAssertEqual(cellViewModel.headerText, "Your edit was reverted", "Invalid headerText")
XCTAssertEqual(cellViewModel.subheaderText, "From Fred The Bird", "Invalid subheaderText")
XCTAssertEqual(cellViewModel.subheaderText, "From Fred The Bird".localized, "Invalid subheaderText")
XCTAssertEqual(cellViewModel.bodyText, nil)
XCTAssertEqual(cellViewModel.footerText, "Blue Bird", "Invalid footerText")
XCTAssertEqual(cellViewModel.dateText, "9/2/21", "Invalid dateText")
Expand All @@ -103,42 +103,42 @@ class NotificationsCenterCellViewModelEditRevertedTests: NotificationsCenterView

XCTAssertEqual(cellViewModel.sheetActions.count, 6, "Invalid sheetActionsCount")

let expectedText0 = "Mark as unread"
let expectedText0 = "Mark as unread".localized
let expectedURL0: URL? = nil
let expectedIcon0: NotificationsCenterIconType? = nil
let expectedDestinationText0: String? = nil
let expectedAction0: NotificationsCenterActionData.LoggingLabel = .markUnread
try testActions(expectedText: expectedText0, expectedURL: expectedURL0, expectedIcon: expectedIcon0, expectedDestinationText: expectedDestinationText0, actionToTest: cellViewModel.sheetActions[0], isMarkAsRead: true, actionType: expectedAction0)

let expectedText1 = "Diff"
let expectedText1 = "Diff".localized
let expectedURL1: URL? = URL(string: "https://test.wikipedia.org/w/index.php?oldid=480410&title=Blue_Bird")!
let expectedIcon1: NotificationsCenterIconType = .diff
let expectedDestinationText1 = "In app"
let expectedAction1: NotificationsCenterActionData.LoggingLabel = .diff
try testActions(expectedText: expectedText1, expectedURL: expectedURL1, expectedIcon: expectedIcon1, expectedDestinationText: expectedDestinationText1, actionToTest: cellViewModel.sheetActions[1], actionType: expectedAction1)

let expectedText2 = "Fred The Bird\'s user page"
let expectedText2 = "Fred The Bird\'s user page".localized
let expectedURL2: URL? = URL(string: "https://test.wikipedia.org/wiki/User:Fred_The_Bird")!
let expectedIcon2: NotificationsCenterIconType = .person
let expectedDestinationText2 = "On web"
let expectedAction2: NotificationsCenterActionData.LoggingLabel = .senderPage
try testActions(expectedText: expectedText2, expectedURL: expectedURL2, expectedIcon: expectedIcon2, expectedDestinationText: expectedDestinationText2, actionToTest: cellViewModel.sheetActions[2], actionType: expectedAction2)

let expectedText3 = "Blue Bird talk page"
let expectedText3 = "Blue Bird talk page".localized
let expectedURL3: URL? = URL(string: "https://test.wikipedia.org/wiki/Talk:Blue_Bird")!
let expectedIcon3: NotificationsCenterIconType = .document
let expectedDestinationText3 = "In app"
let expectedAction3: NotificationsCenterActionData.LoggingLabel = .articleTalk
try testActions(expectedText: expectedText3, expectedURL: expectedURL3, expectedIcon: expectedIcon3, expectedDestinationText: expectedDestinationText3, actionToTest: cellViewModel.sheetActions[3], actionType: expectedAction3)

let expectedText4 = "Blue Bird"
let expectedText4 = "Blue Bird".localized
let expectedURL4: URL? = URL(string: "https://test.wikipedia.org/wiki/Blue_Bird")!
let expectedIcon4: NotificationsCenterIconType = .document
let expectedDestinationText4 = "In app"
let expectedAction4: NotificationsCenterActionData.LoggingLabel = .article
try testActions(expectedText: expectedText4, expectedURL: expectedURL4, expectedIcon: expectedIcon4, expectedDestinationText: expectedDestinationText4, actionToTest: cellViewModel.sheetActions[4], actionType: expectedAction4)

let expectedText5 = "Notification settings"
let expectedText5 = "Notification settings".localized
let expectedURL5: URL? = nil
let expectedIcon5: NotificationsCenterIconType? = nil
let expectedDestinationText5: String? = nil
Expand Down