aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAllan Wang <me@allanwang.ca>2019-09-28 23:39:43 -0700
committerAllan Wang <me@allanwang.ca>2019-09-28 23:39:43 -0700
commitb67c1c8e0d06fc9ae57335fab88180cebfc20414 (patch)
treeb49903a467b15889e981f45747021ea7e5e1c882
parent96908453abbd7e40e13af4359d1bce4524b979a6 (diff)
downloadfrost-b67c1c8e0d06fc9ae57335fab88180cebfc20414.tar.gz
frost-b67c1c8e0d06fc9ae57335fab88180cebfc20414.tar.bz2
frost-b67c1c8e0d06fc9ae57335fab88180cebfc20414.zip
Remove accessibility text in parser
-rw-r--r--app/src/main/kotlin/com/pitchedapps/frost/facebook/parsers/NotifParser.kt1
-rw-r--r--app/src/test/kotlin/com/pitchedapps/frost/facebook/parsers/FbParseTest.kt19
2 files changed, 18 insertions, 2 deletions
diff --git a/app/src/main/kotlin/com/pitchedapps/frost/facebook/parsers/NotifParser.kt b/app/src/main/kotlin/com/pitchedapps/frost/facebook/parsers/NotifParser.kt
index f9db0a8f..d53b1e07 100644
--- a/app/src/main/kotlin/com/pitchedapps/frost/facebook/parsers/NotifParser.kt
+++ b/app/src/main/kotlin/com/pitchedapps/frost/facebook/parsers/NotifParser.kt
@@ -103,6 +103,7 @@ private class NotifParserImpl : FrostParserBase<FrostNotifs>(false) {
private fun parseNotif(element: Element): FrostNotif? {
val a = element.getElementsByTag("a").first() ?: return null
+ a.selectFirst("span.accessible_elem")?.remove()
val abbr = element.getElementsByTag("abbr")
val epoch = FB_EPOCH_MATCHER.find(abbr.attr("data-store"))[1]?.toLongOrNull() ?: -1L
//fetch id
diff --git a/app/src/test/kotlin/com/pitchedapps/frost/facebook/parsers/FbParseTest.kt b/app/src/test/kotlin/com/pitchedapps/frost/facebook/parsers/FbParseTest.kt
index 11e2502b..0be29c2b 100644
--- a/app/src/test/kotlin/com/pitchedapps/frost/facebook/parsers/FbParseTest.kt
+++ b/app/src/test/kotlin/com/pitchedapps/frost/facebook/parsers/FbParseTest.kt
@@ -44,11 +44,17 @@ class FbParseTest {
private inline fun <reified T : ParseData> FrostParser<T>.test(action: T.() -> Unit = {}) =
parse(COOKIE).test(url, action)
- private inline fun <reified T : ParseData> ParseResponse<T>?.test(url: String, action: T.() -> Unit = {}) {
+ private inline fun <reified T : ParseData> ParseResponse<T>?.test(
+ url: String,
+ action: T.() -> Unit = {}
+ ) {
val response = this
?: fail("${T::class.simpleName} parser returned null for $url")
println(response)
- assertFalse(response.data.isEmpty, "${T::class.simpleName} parser returned empty data for $url")
+ assertFalse(
+ response.data.isEmpty,
+ "${T::class.simpleName} parser returned empty data for $url"
+ )
response.data.action()
}
@@ -77,5 +83,14 @@ class FbParseTest {
assertNotNull(it.img, "img may not be properly matched")
}
notifs.map(FrostNotif::time).assertDescending("notif time values")
+ if (notifs.none { it.unread }) {
+ println("No messages unread.")
+ }
+ notifs.forEach {
+ assertFalse(
+ it.content.startsWith("unread", ignoreCase = true),
+ "Parse error; notif starts with 'Unread'"
+ )
+ }
}
}