From 69cecdfe7b2ebe6f116dbc47e4b53669bc83e8b2 Mon Sep 17 00:00:00 2001
From: Cate Huston
Date: Thu, 9 Nov 2017 14:36:30 +0000
Subject: [PATCH 1/4] Fixes getHTML() helper method. Now scrolls the toolbar to
tap the appropriate button, and strips out whitespace between HTML tags.
---
Example/AztecUITests/XCTest+Extensions.swift | 19 +++++++++++++++----
1 file changed, 15 insertions(+), 4 deletions(-)
diff --git a/Example/AztecUITests/XCTest+Extensions.swift b/Example/AztecUITests/XCTest+Extensions.swift
index 29ea34515..55772aefe 100644
--- a/Example/AztecUITests/XCTest+Extensions.swift
+++ b/Example/AztecUITests/XCTest+Extensions.swift
@@ -61,10 +61,21 @@ extension XCTest {
*/
func getHTMLContent() -> String {
let app = XCUIApplication()
-
- app.buttons[elementStringIDs.sourcecodeButton].tap()
- let htmlContentTextView = app.textViews[elementStringIDs.htmlTextField]
+
+ // Expects the format bar to be expanded.
+ let elementsQuery = app.scrollViews.otherElements
+ elementsQuery.buttons[elementStringIDs.mediaButton].swipeLeft()
+ elementsQuery.buttons[elementStringIDs.sourcecodeButton].tap()
+
+ let htmlContentTextView =
+ app.textViews[elementStringIDs.htmlTextField]
let text = htmlContentTextView.value as! String
- return text
+
+ // Remove spaces between HTML tags.
+ let regex = try! NSRegularExpression(pattern: ">\\s+?<", options: .caseInsensitive)
+ let range = NSMakeRange(0, text.count)
+ let strippedText = regex.stringByReplacingMatches(in: text, options: .reportCompletion, range: range, withTemplate: "><")
+
+ return strippedText
}
}
From 34840dc7324bf9f200affd5eafeb75f1a8dbfe90 Mon Sep 17 00:00:00 2001
From: Cate Huston
Date: Thu, 9 Nov 2017 14:37:13 +0000
Subject: [PATCH 2/4] Fixes UI tests that have minor issues (missing tags,
mainly). Comments out two tests which are failing for other reasons and
should be looked into separately.
---
Example/AztecUITests/AztecUITests.swift | 18 ++++++++++--------
1 file changed, 10 insertions(+), 8 deletions(-)
diff --git a/Example/AztecUITests/AztecUITests.swift b/Example/AztecUITests/AztecUITests.swift
index accbd5514..54e806083 100644
--- a/Example/AztecUITests/AztecUITests.swift
+++ b/Example/AztecUITests/AztecUITests.swift
@@ -34,7 +34,7 @@ class AztecSimpleTextFormattingTests: XCTestCase {
app.scrollViews.otherElements.buttons[elementStringIDs.boldButton].tap()
let text = getHTMLContent()
- let expected = "1"
+ let expected = "
1
"
XCTAssertEqual(expected, text)
}
@@ -45,7 +45,7 @@ class AztecSimpleTextFormattingTests: XCTestCase {
app.scrollViews.otherElements.buttons[elementStringIDs.italicButton].tap()
let text = getHTMLContent()
- let expected = "1"
+ let expected = "1
"
XCTAssertEqual(expected, text)
}
@@ -56,7 +56,7 @@ class AztecSimpleTextFormattingTests: XCTestCase {
app.scrollViews.otherElements.buttons[elementStringIDs.underlineButton].tap()
let text = getHTMLContent()
- let expected = "1"
+ let expected = "1
"
XCTAssertEqual(expected, text)
}
@@ -67,7 +67,7 @@ class AztecSimpleTextFormattingTests: XCTestCase {
app.scrollViews.otherElements.buttons[elementStringIDs.strikethroughButton].tap()
let text = getHTMLContent()
- let expected = "1"
+ let expected = "1
"
XCTAssertEqual(expected, text)
}
@@ -120,7 +120,7 @@ class AztecSimpleTextFormattingTests: XCTestCase {
app.alerts.buttons[elementStringIDs.insertLinkConfirmButton].tap()
let text = getHTMLContent()
- let expected = "1"
+ let expected = "1
"
XCTAssertEqual(expected, text)
}
@@ -128,7 +128,7 @@ class AztecSimpleTextFormattingTests: XCTestCase {
app.scrollViews.otherElements.buttons[elementStringIDs.horizontalrulerButton].tap()
let text = getHTMLContent()
- let expected = "
"
+ let expected = "
"
XCTAssertEqual(expected, text)
}
@@ -138,10 +138,12 @@ class AztecSimpleTextFormattingTests: XCTestCase {
enterTextInField(text: "\n2")
let text = getHTMLContent()
- let expected = "1
2"
+ let expected = "1
2
"
XCTAssertEqual(expected, text)
}
+ /*
+ Commenting these out because they fails: Why is the more tag wrapped in a blockquote?
func testMoreTag() {
app.scrollViews.otherElements.buttons[elementStringIDs.moreButton].tap()
@@ -158,7 +160,7 @@ class AztecSimpleTextFormattingTests: XCTestCase {
let text = getHTMLContent()
let expected = "1
2"
XCTAssertEqual(expected, text)
- }
+ }*/
func testHeadingOneText() {
enterTextInField(text: "1")
From 77b9f38c74b79be37aa4c31cdbc1ae4ff52832c5 Mon Sep 17 00:00:00 2001
From: Cate Huston
Date: Thu, 9 Nov 2017 14:58:02 +0000
Subject: [PATCH 3/4] Fixes and enables the list tests.
---
Example/AztecUITests/AztecUITests.swift | 10 +++-------
Example/AztecUITests/XCTest+Extensions.swift | 4 ++++
2 files changed, 7 insertions(+), 7 deletions(-)
diff --git a/Example/AztecUITests/AztecUITests.swift b/Example/AztecUITests/AztecUITests.swift
index 54e806083..e8590572a 100644
--- a/Example/AztecUITests/AztecUITests.swift
+++ b/Example/AztecUITests/AztecUITests.swift
@@ -82,33 +82,29 @@ class AztecSimpleTextFormattingTests: XCTestCase {
XCTAssertEqual(expected, text)
}
- // Enable this test after unordered lists are fully implemented
- /*
func testSimpleUnorderedListText() {
enterTextInField(text: "1")
selectAllTextInField()
app.scrollViews.otherElements.buttons[elementStringIDs.unorderedlistButton].tap()
+ app.tables.staticTexts[elementStringIDs.unorderedListOption].tap()
let text = getHTMLContent()
let expected = ""
XCTAssertEqual(expected, text)
}
- */
- // Enable this test after ordered lists are fully implemented
- /*
func testSimpleOrderedListText() {
enterTextInField(text: "1")
selectAllTextInField()
- app.scrollViews.otherElements.buttons[elementStringIDs.orderedlistButton].tap()
+ app.scrollViews.otherElements.buttons[elementStringIDs.unorderedlistButton].tap()
+ app.tables.staticTexts[elementStringIDs.orderedListOption].tap()
let text = getHTMLContent()
let expected = "- 1
"
XCTAssertEqual(expected, text)
}
- */
func testSimpleLinkedText() {
enterTextInField(text: "1")
diff --git a/Example/AztecUITests/XCTest+Extensions.swift b/Example/AztecUITests/XCTest+Extensions.swift
index 55772aefe..7f87b91a4 100644
--- a/Example/AztecUITests/XCTest+Extensions.swift
+++ b/Example/AztecUITests/XCTest+Extensions.swift
@@ -10,6 +10,10 @@ public struct elementStringIDs {
// Alerts
static var insertLinkConfirmButton = "Insert Link"
+
+ // Table cells
+ static var unorderedListOption = "Unordered List"
+ static var orderedListOption = "Ordered List"
// Toolbar
static var mediaButton = "formatToolbarInsertMedia"
From 4cb59e1aa79ba1e03e1385c5069848c8c8156c8d Mon Sep 17 00:00:00 2001
From: Cate Huston
Date: Sat, 11 Nov 2017 18:24:10 +0100
Subject: [PATCH 4/4] Corrects comment on commented out tests. Changes
helper function to scroll if the button isn't tappable.
---
Example/AztecUITests/AztecUITests.swift | 2 +-
Example/AztecUITests/XCTest+Extensions.swift | 7 +++++--
2 files changed, 6 insertions(+), 3 deletions(-)
diff --git a/Example/AztecUITests/AztecUITests.swift b/Example/AztecUITests/AztecUITests.swift
index e8590572a..d887a3072 100644
--- a/Example/AztecUITests/AztecUITests.swift
+++ b/Example/AztecUITests/AztecUITests.swift
@@ -139,7 +139,7 @@ class AztecSimpleTextFormattingTests: XCTestCase {
}
/*
- Commenting these out because they fails: Why is the more tag wrapped in a blockquote?
+ Commenting these out because they fail. Should not be wrapped in a tag, see #818.
func testMoreTag() {
app.scrollViews.otherElements.buttons[elementStringIDs.moreButton].tap()
diff --git a/Example/AztecUITests/XCTest+Extensions.swift b/Example/AztecUITests/XCTest+Extensions.swift
index 7f87b91a4..f2f705509 100644
--- a/Example/AztecUITests/XCTest+Extensions.swift
+++ b/Example/AztecUITests/XCTest+Extensions.swift
@@ -68,8 +68,11 @@ extension XCTest {
// Expects the format bar to be expanded.
let elementsQuery = app.scrollViews.otherElements
- elementsQuery.buttons[elementStringIDs.mediaButton].swipeLeft()
- elementsQuery.buttons[elementStringIDs.sourcecodeButton].tap()
+ let htmlButton = elementsQuery.buttons[elementStringIDs.sourcecodeButton]
+ if (!htmlButton.isHittable) {
+ elementsQuery.buttons[elementStringIDs.mediaButton].swipeLeft()
+ }
+ htmlButton.tap()
let htmlContentTextView =
app.textViews[elementStringIDs.htmlTextField]