Skip to content

Commit 1d367f0

Browse files
authored
REFACTOR MTE-4987 Refactor CreditCard Tests with POM (#30439)
1 parent 14716ea commit 1d367f0

19 files changed

+1037
-24
lines changed

firefox-ios/firefox-ios-tests/Tests/ExperimentIntegrationTests.xctestplan

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,10 @@
108108
"CookiePersistenceTests\/testCookiePersistenceBasic()",
109109
"CookiePersistenceTests\/testCookiePersistenceOpenNewTab()",
110110
"CreditCardsTests\/testAccessingTheCreditCardsSection()",
111+
"CreditCardsTests\/testAccessingTheCreditCardsSection_TAE()",
112+
"CreditCardsTests\/testAutofillCreditCardsToggleOnOff_TAE()",
113+
"CreditCardsTests\/testDeleteButtonFromEditCard_TAE()",
114+
"CreditCardsTests\/testEditSavedCardsUI_TAE()",
111115
"DataManagementTests",
112116
"DatabaseFixtureTest",
113117
"DesktopModeTestsIpad",

firefox-ios/firefox-ios-tests/Tests/FullFunctionalTestPlan.xctestplan

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,10 +118,14 @@
118118
"BrowsingPDFTests\/testPinPDFtoTopSites_TAE()",
119119
"ClipBoardTests\/testClipboardPasteAndGo()",
120120
"CreditCardsTests\/testAccessingTheCreditCardsSection()",
121+
"CreditCardsTests\/testAccessingTheCreditCardsSection_TAE()",
121122
"CreditCardsTests\/testAutofillCreditCardsToggleOnOff()",
123+
"CreditCardsTests\/testAutofillCreditCardsToggleOnOff_TAE()",
122124
"CreditCardsTests\/testAutofillCreditCardsToggleOnOoff()",
123125
"CreditCardsTests\/testDeleteButtonFromEditCard()",
126+
"CreditCardsTests\/testDeleteButtonFromEditCard_TAE()",
124127
"CreditCardsTests\/testEditSavedCardsUI()",
128+
"CreditCardsTests\/testEditSavedCardsUI_TAE()",
125129
"CronTabsPerformanceTest",
126130
"DataManagementTests\/testWebSiteDataEnterFirstTime()",
127131
"DataManagementTests\/testWebSiteDataEnterFirstTime_TAE()",

firefox-ios/firefox-ios-tests/Tests/Smoketest.xctestplan

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,11 @@
184184
"CookiePersistenceTests",
185185
"CookiePersistenceTests\/testCookiePersistenceBasic()",
186186
"CookiePersistenceTests\/testCookiePersistenceOpenNewTab()",
187+
"CreditCardsTests\/testAccessingTheCreditCardsSection_TAE()",
188+
"CreditCardsTests\/testAutofillCreditCardsToggleOnOff_TAE()",
187189
"CreditCardsTests\/testCreditCardsAutofill()",
190+
"CreditCardsTests\/testDeleteButtonFromEditCard_TAE()",
191+
"CreditCardsTests\/testEditSavedCardsUI_TAE()",
188192
"CreditCardsTests\/testErrorStatesCreditCards()",
189193
"CreditCardsTests\/testManageCreditCardsOption()",
190194
"CreditCardsTests\/testRedirectionToCreditCardsSection()",

firefox-ios/firefox-ios-tests/Tests/TAESmokeTestPlan.xctestplan

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,6 @@
102102
"CookiePersistenceTests\/testCookiePersistenceBasic()",
103103
"CookiePersistenceTests\/testCookiePersistenceOpenNewTab()",
104104
"CookiePersistenceTests\/testCookiePersistenceOpenRegularTabAfterPrivateTab()",
105-
"CreditCardsTests",
106105
"CreditCardsTests\/testAccessingTheCreditCardsSection()",
107106
"CreditCardsTests\/testAutofillCreditCardsToggleOnOff()",
108107
"CreditCardsTests\/testCreditCardsAutofill()",
@@ -350,6 +349,7 @@
350349
"NavigationTest\/testPopUpBlocker_tabTrayExperimentOff()",
351350
"NavigationTest\/testPopUpBlocker_tabTrayExperimentOn()",
352351
"NavigationTest\/testSSL()",
352+
"NavigationTest\/testScrollingBehaviorInAWebPage()",
353353
"NavigationTest\/testScrollsToTopWithMultipleTabs()",
354354
"NavigationTest\/testShareLink()",
355355
"NavigationTest\/testShareLinkPrivateMode()",
@@ -360,6 +360,7 @@
360360
"NavigationTest\/testTapSignInShowsFxAFromTour()",
361361
"NavigationTest\/testTapSigninShowsFxAFromSettings()",
362362
"NavigationTest\/testURLBar()",
363+
"NavigationTest\/testValidatePopUpWindows()",
363364
"NavigationTest\/testVerifyBrowserTabMenu()",
364365
"NavigationTest\/testWriteToChildPopupTab()",
365366
"NewTabSettingsTest\/testChangeNewTabSettingsLabel()",

firefox-ios/firefox-ios-tests/Tests/XCUITests/CreditCardsTests.swift

Lines changed: 172 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,14 @@ class CreditCardsTests: BaseTestCase {
1212
var nameOnCard: XCUIElement!
1313
var cardNr: XCUIElement!
1414
var expiration: XCUIElement!
15+
let url_fill_form = "https://mozilla.github.io/form-fill-examples/basic_cc.html"
16+
17+
var toolbarScreen: ToolbarScreen!
18+
var creditCardScreen: CreditCardsScreen!
19+
var addCreditCardScreen: AddCreditCardScreen!
20+
var loginSettingsScreen: LoginSettingsScreen!
21+
var editCardScreen: EditCreditCardScreen!
22+
var viewCardScreen: ViewCreditCardScreen!
1523

1624
func initCardFields() {
1725
nameOnCard = app.buttons["name"]
@@ -64,6 +72,28 @@ class CreditCardsTests: BaseTestCase {
6472
}
6573
}
6674

75+
// https://mozilla.testrail.io/index.php?/cases/view/2306967
76+
// SmokeTest TAE
77+
func testAccessingTheCreditCardsSection_TAE() {
78+
let toolbarScreen = ToolbarScreen(app: app)
79+
let creditCardScreen = CreditCardsScreen(app: app)
80+
let addCreditCardScreen = AddCreditCardScreen(app: app)
81+
82+
navigator.nowAt(NewTabScreen)
83+
toolbarScreen.assertTabsButtonExists()
84+
navigator.goto(CreditCardsSettings)
85+
creditCardScreen.unlockIfNeeded()
86+
// Autofill Credit cards section displays
87+
creditCardScreen.waitForSectionVisible()
88+
creditCardScreen.openAddCreditCardForm()
89+
// Add Credit Card page is displayed
90+
creditCardScreen.waitForSectionVisible()
91+
// Add and save a valid credit card
92+
addCreditCardScreen.addCreditCard(name: "Test", cardNumber: cards[0], expirationDate: "0540")
93+
94+
creditCardScreen.assertCardSaved(containing: "1252", details: ["Test", "Expires", "5/40"])
95+
}
96+
6797
// https://mozilla.testrail.io/index.php?/cases/view/2306978
6898
// SmokeTest
6999
func testDeleteButtonFromEditCard() {
@@ -102,6 +132,27 @@ class CreditCardsTests: BaseTestCase {
102132
mozWaitForElementToNotExist(app.tables.cells.element(boundBy: 1))
103133
}
104134

135+
// https://mozilla.testrail.io/index.php?/cases/view/2306978
136+
// SmokeTest TAE
137+
func testDeleteButtonFromEditCard_TAE() {
138+
addCardAndReachViewCardPage_TAE()
139+
// Tap on the "Remove card" button
140+
let editCreditCardScreen = EditCreditCardScreen(app: app)
141+
142+
editCreditCardScreen.openEditMode()
143+
144+
editCreditCardScreen.tapRemoveCard()
145+
146+
editCreditCardScreen.waitForRemoveCardAlert()
147+
148+
editCreditCardScreen.cancelRemoval()
149+
150+
editCreditCardScreen.tapRemoveCard()
151+
editCreditCardScreen.confirmRemoval()
152+
153+
editCreditCardScreen.assertCardDeleted()
154+
}
155+
105156
// https://mozilla.testrail.io/index.php?/cases/view/2306975
106157
// SmokeTest
107158
func testEditSavedCardsUI() {
@@ -118,6 +169,16 @@ class CreditCardsTests: BaseTestCase {
118169
)
119170
}
120171

172+
// https://mozilla.testrail.io/index.php?/cases/view/2306975
173+
// SmokeTest TAE
174+
func testEditSavedCardsUI_TAE() {
175+
let viewCardScreen = ViewCreditCardScreen(app: app)
176+
addCardAndReachViewCardPage_TAE()
177+
178+
// Go back to saved cards section
179+
viewCardScreen.goBackToSavedCardsSection()
180+
}
181+
121182
// https://mozilla.testrail.io/index.php?/cases/view/2306972
122183
func testManageCreditCardsOption() throws {
123184
if #unavailable(iOS 16) {
@@ -165,7 +226,7 @@ class CreditCardsTests: BaseTestCase {
165226
let futureExpiryMonthYear = formatter.string(from: dateFiveYearsFromNow!)
166227
addCreditCard(name: "Test", cardNumber: cards[0], expirationDate: futureExpiryMonthYear)
167228
navigator.goto(NewTabScreen)
168-
navigator.openURL("https://mozilla.github.io/form-fill-examples/basic_cc.html")
229+
navigator.openURL(url_fill_form)
169230
waitUntilPageLoad()
170231
// The autofill option (Use saved card prompt) is not displayed
171232
var cardNumber = app.webViews["Web content"].textFields["Card Number:"]
@@ -201,6 +262,44 @@ class CreditCardsTests: BaseTestCase {
201262
mozWaitForElementToExist(app.buttons[useSavedCard])
202263
}
203264

265+
// https://mozilla.testrail.io/index.php?/cases/view/2306969
266+
// Smoketest TAE
267+
func testAutofillCreditCardsToggleOnOff_TAE() {
268+
let toolbarScreen = ToolbarScreen(app: app)
269+
let creditCardScreen = CreditCardsScreen(app: app)
270+
271+
navigator.nowAt(NewTabScreen)
272+
toolbarScreen.assertTabsButtonExists()
273+
navigator.goto(CreditCardsSettings)
274+
creditCardScreen.unlockIfNeeded()
275+
276+
creditCardScreen.disableSaveAndFillAndOpenAddCardForm()
277+
278+
let futureExpiryMonthYear = creditCardScreen.expirationDateFiveYearsFromNow()
279+
creditCardScreen.addNewCreditCard(name: "Test", cardNumber: cards[0], expirationDate: futureExpiryMonthYear)
280+
navigator.goto(NewTabScreen)
281+
navigator.openURL(url_fill_form)
282+
waitUntilPageLoad()
283+
// The autofill option (Use saved card prompt) is not displayed
284+
let cardNumber = creditCardScreen.getCardNumberField()
285+
creditCardScreen.assertNoAutofillPromptWhenEnteringCard()
286+
// issue 28625: iOS 15 may not open the menu fully.
287+
if #unavailable(iOS 16) {
288+
navigator.goto(BrowserTabMenu)
289+
app.swipeUp()
290+
}
291+
navigator.goto(CreditCardsSettings)
292+
creditCardScreen.unlockIfNeeded()
293+
creditCardScreen.assertAutofillCreditCardExists()
294+
// Enable the "Save and Fill Payment Methods" toggle
295+
app.switches.element(boundBy: 1).waitAndTap()
296+
XCTAssertEqual(creditCardScreen.getSaveAndFillSwitchValue(), "1")
297+
navigator.goto(NewTabScreen)
298+
cardNumber.waitAndTap()
299+
// The autofill option (Use saved card prompt) is displayed
300+
creditCardScreen.prepareForSavedCardPrompt()
301+
}
302+
204303
// https://mozilla.testrail.io/index.php?/cases/view/2306971
205304
func testCreditCardsAutofill() throws {
206305
if #unavailable(iOS 16) {
@@ -410,7 +509,7 @@ class CreditCardsTests: BaseTestCase {
410509
throw XCTSkip("testSaveThisCardPrompt() does not work on iOS 15 and 16")
411510
}
412511
navigator.goto(NewTabScreen)
413-
navigator.openURL("https://mozilla.github.io/form-fill-examples/basic_cc.html")
512+
navigator.openURL(url_fill_form)
414513
waitUntilPageLoad()
415514
// Fill in the form with the card details of a new (unsaved) credit card.
416515
fillCardDetailsOnWebsite(fillNewInfo: true)
@@ -438,7 +537,7 @@ class CreditCardsTests: BaseTestCase {
438537
navigator.goto(NewTabScreen)
439538
navigator.performAction(Action.OpenNewTabFromTabTray)
440539
navigator.goto(NewTabScreen)
441-
navigator.openURL("https://mozilla.github.io/form-fill-examples/basic_cc.html")
540+
navigator.openURL(url_fill_form)
442541
waitUntilPageLoad()
443542
// Fill in the form with the card details of a new (unsaved) credit card.
444543
fillCardDetailsOnWebsite(fillNewInfo: true)
@@ -508,7 +607,7 @@ class CreditCardsTests: BaseTestCase {
508607
navigator.goto(NewTabScreen)
509608
navigator.performAction(Action.OpenNewTabFromTabTray)
510609
navigator.goto(NewTabScreen)
511-
navigator.openURL("https://mozilla.github.io/form-fill-examples/basic_cc.html")
610+
navigator.openURL(url_fill_form)
512611
waitUntilPageLoad()
513612
if iPad() {
514613
app.webViews["Web content"].textFields["Card Number:"].waitAndTap()
@@ -653,7 +752,7 @@ class CreditCardsTests: BaseTestCase {
653752
private func reachAutofillWebsite() {
654753
// Reach autofill website
655754
navigator.goto(NewTabScreen)
656-
navigator.openURL("https://mozilla.github.io/form-fill-examples/basic_cc.html")
755+
navigator.openURL(url_fill_form)
657756
waitUntilPageLoad()
658757
app.textFields.element(boundBy: 1).waitAndTap()
659758
if iPad() {
@@ -679,7 +778,7 @@ class CreditCardsTests: BaseTestCase {
679778
app.buttons[creditCardsStaticTexts.AutoFillCreditCard.addCard].waitAndTap()
680779
addCreditCard(name: "Test", cardNumber: cards[0], expirationDate: "0540")
681780
navigator.goto(NewTabScreen)
682-
navigator.openURL("https://mozilla.github.io/form-fill-examples/basic_cc.html")
781+
navigator.openURL(url_fill_form)
683782
waitUntilPageLoad()
684783
var cardNumber = app.webViews["Web content"].textFields["Card Number:"]
685784
if #unavailable(iOS 17) {
@@ -702,6 +801,29 @@ class CreditCardsTests: BaseTestCase {
702801
)
703802
}
704803

804+
private func addCreditCardAndReachAutofillWebsite_TAE() {
805+
let creditCards = CreditCardsScreen(app: app)
806+
let addCreditCardScreen = AddCreditCardScreen(app: app)
807+
let toolbarScreen = ToolbarScreen(app: app)
808+
809+
navigator.nowAt(NewTabScreen)
810+
toolbarScreen.assertTabsButtonExists()
811+
navigator.goto(CreditCardsSettings)
812+
creditCards.unlockIfNeeded()
813+
814+
creditCards.enableSaveAndFillIfDisabled()
815+
816+
creditCards.addNewCreditCard(name: "Test", cardNumber: cards[0], expirationDate: "0540")
817+
818+
navigator.goto(NewTabScreen)
819+
navigator.openURL(url_fill_form)
820+
waitUntilPageLoad()
821+
822+
addCreditCardScreen.interactWithCreditCardForm()
823+
824+
addCreditCardScreen.useSavedCardPrompt()
825+
}
826+
705827
private func addCardAndReachViewCardPage() {
706828
navigator.nowAt(NewTabScreen)
707829
waitForTabsButton()
@@ -735,6 +857,24 @@ class CreditCardsTests: BaseTestCase {
735857
}
736858
}
737859

860+
private func addCardAndReachViewCardPage_TAE() {
861+
let toolbarScreen = ToolbarScreen(app: app)
862+
let loginSettingsScreen = LoginSettingsScreen(app: app)
863+
let creditCardsScreen = CreditCardsScreen(app: app)
864+
let addCardScreen = AddCreditCardScreen(app: app)
865+
let viewCardScreen = ViewCreditCardScreen(app: app)
866+
867+
navigator.nowAt(NewTabScreen)
868+
toolbarScreen.assertTabsButtonExists()
869+
navigator.goto(CreditCardsSettings)
870+
loginSettingsScreen.unlockLoginsView()
871+
creditCardsScreen.openAddCreditCardForm()
872+
addCardScreen.addCreditCard(name: "Test", cardNumber: cards[0], expirationDate: "0540")
873+
creditCardsScreen.openSavedCard(at: 1)
874+
viewCardScreen.waitForViewCardScreen(containing: "1252")
875+
viewCardScreen.assertCardDetails(["Test", "05 / 40"])
876+
}
877+
738878
private func addCreditCard(name: String, cardNumber: String, expirationDate: String) {
739879
tapCardName()
740880
typeCardName(name: name)
@@ -761,6 +901,32 @@ class CreditCardsTests: BaseTestCase {
761901
saveButton.waitAndTap()
762902
}
763903

904+
private func addCreditCard_TAE(name: String, cardNumber: String, expirationDate: String) {
905+
tapCardName()
906+
typeCardName(name: name)
907+
tapCardNr()
908+
typeCardNr(cardNo: cardNumber)
909+
tapExpiration()
910+
// Retry adding card number if first attempt failed
911+
if app.staticTexts["Enter a valid card number"].exists {
912+
retryOnCardNumber(cardNumber: cardNumber)
913+
}
914+
typeExpirationDate(exprDate: expirationDate)
915+
// Retry adding expiration date if first attempt failed
916+
if app.staticTexts["Enter a valid expiration date"].exists {
917+
retryExpirationNumber(expirationDate: expirationDate)
918+
}
919+
let saveButton = app.buttons[creditCardsStaticTexts.AddCreditCard.save]
920+
if !saveButton.isEnabled {
921+
retryOnCardNumber(cardNumber: cardNumber)
922+
mozWaitForElementToExist(expiration)
923+
expiration.typeText(expirationDate)
924+
retryExpirationNumber(expirationDate: expirationDate)
925+
mozWaitForElementToExist(saveButton)
926+
}
927+
saveButton.waitAndTap()
928+
}
929+
764930
private func retryOnCardNumber(cardNumber: String) {
765931
tapCardNr()
766932
pressDelete()

firefox-ios/firefox-ios-tests/Tests/XCUITests/HistoryTests.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -505,7 +505,7 @@ class HistoryTests: BaseTestCase {
505505
navigator.toggleOn(userState.isPrivate, withAction: Action.ToggleExperimentPrivateMode)
506506
navigator.performAction(Action.OpenNewTabFromTabTray)
507507
openBookOfMozilla()
508-
toolbarScreen.assertBackButtonExist()
508+
toolbarScreen.assertBackButtonExists()
509509
toolbarScreen.pressBackButton(duration: 1)
510510
browserScreen.tapOnBookOfMozilla()
511511
toolbarScreen.tapBackButton()

firefox-ios/firefox-ios-tests/Tests/XCUITests/LoginsTests.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ class LoginTest: BaseTestCase {
108108
}
109109

110110
private func openLoginsSettingsFromBrowserTab_TAE() {
111-
toolBarScreen.assertTabToolbarMenuExist()
111+
toolBarScreen.assertTabToolbarMenuExists()
112112
navigator.goto(BrowserTabMenu)
113113
mainMenuScreen.assertMainMenuSettingsExist()
114114
navigator.goto(LoginsSettings)

0 commit comments

Comments
 (0)