summaryrefslogtreecommitdiff
path: root/app/src/test/java/org/terst/feedreader/data/CachedExtractionTest.kt
diff options
context:
space:
mode:
Diffstat (limited to 'app/src/test/java/org/terst/feedreader/data/CachedExtractionTest.kt')
-rw-r--r--app/src/test/java/org/terst/feedreader/data/CachedExtractionTest.kt19
1 files changed, 19 insertions, 0 deletions
diff --git a/app/src/test/java/org/terst/feedreader/data/CachedExtractionTest.kt b/app/src/test/java/org/terst/feedreader/data/CachedExtractionTest.kt
index fc9c32e..442663f 100644
--- a/app/src/test/java/org/terst/feedreader/data/CachedExtractionTest.kt
+++ b/app/src/test/java/org/terst/feedreader/data/CachedExtractionTest.kt
@@ -96,4 +96,23 @@ class CachedExtractionTest {
assertFalse(result.discardedConsentNotice)
assertFalse(cleared)
}
+
+ /**
+ * A cached article carrying the publisher's "Trending" promo widgets. Unlike a cookie
+ * notice, the article itself is fine -- only the widgets have to go, and re-extracting
+ * would be a pointless round trip that produced the same body again.
+ */
+ @Test
+ fun `a cached article has its recirculation widgets stripped without being re-extracted`() = runTest {
+ var cleared = false
+ val body = "<p>" + "The actual article body. ".repeat(60) + "</p>"
+ val widget = "<div data-mrf-recirculation=\"IL_x\"><p><h3><span>Trending</span></h3></p></div>"
+
+ val result = loadCachedExtraction(body + widget + body) { cleared = true }
+
+ assertFalse("the stray header survived: ${result.content}", result.content!!.contains("Trending"))
+ assertTrue(result.content!!.contains("The actual article body."))
+ assertFalse("the article was fine; nothing should be thrown away", result.discarded)
+ assertFalse("re-extracting would fetch the same body again", cleared)
+ }
}