Skip to content
This repository has been archived by the owner on Mar 6, 2024. It is now read-only.

Commit

Permalink
Add MTE-2019 automated test for URL validation (#3983)
Browse files Browse the repository at this point in the history
  • Loading branch information
dragosb01 authored Jan 12, 2024
1 parent 613280d commit 469e88c
Show file tree
Hide file tree
Showing 3 changed files with 48 additions and 0 deletions.
4 changes: 4 additions & 0 deletions focus-ios/Blockzilla.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@
8400575A27353B1800E48144 /* UIPasteBoardExtensions.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8400575927353B1800E48144 /* UIPasteBoardExtensions.swift */; };
846A23182668CC4500DB3C37 /* FullScreen.js in Resources */ = {isa = PBXBuildFile; fileRef = 846A23172668CC4500DB3C37 /* FullScreen.js */; };
A89766DA1F57DCA9008183C5 /* (null) in Resources */ = {isa = PBXBuildFile; };
B101243E2B4EE8C20099F3CA /* URLValidationTest.swift in Sources */ = {isa = PBXBuildFile; fileRef = B101243D2B4EE8C20099F3CA /* URLValidationTest.swift */; };
B3481A551FCF261900CA2EA6 /* AutocompleteCustomUrlViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = B3481A541FCF261900CA2EA6 /* AutocompleteCustomUrlViewController.swift */; };
B3AFC2BC1F7C0B9F001AEF38 /* WebViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = B3AFC2BB1F7C0B9F001AEF38 /* WebViewController.swift */; };
B3CD41C91FD1027000AEBD58 /* InsetTextField.swift in Sources */ = {isa = PBXBuildFile; fileRef = B3CD41C81FD1027000AEBD58 /* InsetTextField.swift */; };
Expand Down Expand Up @@ -674,6 +675,7 @@
A8EA0CE6289A4F4100B99C37 /* et */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = et; path = et.lproj/Intro.strings; sourceTree = "<group>"; };
A8EA0CE7289A4F4100B99C37 /* et */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = et; path = et.lproj/Localizable.strings; sourceTree = "<group>"; };
AAB8E622E994545108473554 /* QuartzCore.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = QuartzCore.framework; path = System/Library/Frameworks/QuartzCore.framework; sourceTree = SDKROOT; };
B101243D2B4EE8C20099F3CA /* URLValidationTest.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = URLValidationTest.swift; sourceTree = "<group>"; };
B3481A541FCF261900CA2EA6 /* AutocompleteCustomUrlViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AutocompleteCustomUrlViewController.swift; sourceTree = "<group>"; };
B3AFC2BB1F7C0B9F001AEF38 /* WebViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = WebViewController.swift; sourceTree = "<group>"; };
B3CD41C81FD1027000AEBD58 /* InsetTextField.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = InsetTextField.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -1299,6 +1301,7 @@
58408BA4265FC524003C4E4F /* BasicBrowsing.swift */,
D440BC17276B3535003FD9B1 /* ShortcutsTest.swift */,
C82F45F228193628000D7D84 /* TestHelpers.swift */,
B101243D2B4EE8C20099F3CA /* URLValidationTest.swift */,
);
path = XCUITest;
sourceTree = "<group>";
Expand Down Expand Up @@ -2481,6 +2484,7 @@
0BBBED431DD3B78300F9C565 /* SettingAppearanceTest.swift in Sources */,
1D199EF220D813D300CDF976 /* DragAndDropTest.swift in Sources */,
0BBBED411DD3823C00F9C565 /* BaseTestCase.swift in Sources */,
B101243E2B4EE8C20099F3CA /* URLValidationTest.swift in Sources */,
1D47758820C1E66000C074AE /* CopyTest.swift in Sources */,
0B37F9A61E2FCAD4002DF74B /* SearchProviderTest.swift in Sources */,
58408BA5265FC524003C4E4F /* BasicBrowsing.swift in Sources */,
Expand Down
1 change: 1 addition & 0 deletions focus-ios/focus-ios-tests/FullFunctionalTests.xctestplan
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
"ShortcutsTest",
"TrackingProtectionMenu\/testActiveProtectionSidebar()",
"TrackingProtectionMenu\/testProtectionSidebar()",
"URLValidationTest",
"WebsiteAccessTests\/testVisitWebsite()"
],
"target" : {
Expand Down
43 changes: 43 additions & 0 deletions focus-ios/focus-ios-tests/XCUITest/URLValidationTest.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
// This Source Code Form is subject to the terms of the Mozilla Public
// License, v. 2.0. If a copy of the MPL was not distributed with this
// file, You can obtain one at http://mozilla.org/MPL/2.0/

import Foundation
import XCTest

class URLValidationTest: BaseTestCase {
override func setUp() {
super.setUp()
continueAfterFailure = true
}

let urlTypes = ["mozilla.org", "mozilla.org/", "https://mozilla.org", "mozilla.org/en", "mozilla.org/en-",
"mozilla.org/en-US", "https://mozilla.org/", "https://mozilla.org/en", "https://mozilla.org/en-US"]
let urlHttpTypes=["http://example.com", "http://example.com/"]

// https://testrail.stage.mozaws.net/index.php?/cases/view/2460275
func testDifferentURLTypes() {
for i in urlTypes {
loadAndValidateURL(URL: i)
}

for i in urlHttpTypes {
loadAndValidateHttpURLs(URL: i)
}
}

private func loadAndValidateURL(URL: String) {
loadWebPage(URL)
waitForWebPageLoad()
XCTAssertTrue(app.otherElements.staticTexts["Mozilla"].exists, "The website was not loaded properly")
XCTAssertTrue(app.buttons["Menu"].exists)
XCTAssertEqual(app.textFields["URLBar.urlText"].value as? String, "www.mozilla.org")
}

private func loadAndValidateHttpURLs(URL: String) {
loadWebPage(URL)
waitForWebPageLoad()
XCTAssertTrue(app.otherElements.staticTexts["Example Domain"].exists, "The website was not loaded properly")
XCTAssertEqual(app.textFields["URLBar.urlText"].value as? String, "example.com")
}
}

0 comments on commit 469e88c

Please sign in to comment.