package org.terst.feedreader.readability import org.junit.Assert.assertFalse import org.junit.Assert.assertTrue import org.junit.Test /** * Reported live: reader mode on a New Republic feature article showed nothing but * the site's cookie disclaimer, and cached it. * * Reproduced outside the app by running the extractor's own injected script * (ReaderExtractor's `script`, Readability.js and all) against the real page: when * the article body is present, extraction is perfect. When the body is NOT in the * DOM at the moment Readability runs, Readability's own fallback pass kicks in -- * its first pass strips "unlikely candidates" (which the consent banner is, its * class says `didomi-notice-banner`), comes back under its 500-character * threshold, and so it retries with that stripping disabled. The Didomi notice's * single paragraph is 510 characters, i.e. just over that threshold, so it is * accepted as the article. * * [EXTRACTED_COOKIE_NOTICE] below is not a hand-written approximation of that -- * it is the verbatim `content` string that reproduction produced. * * Nothing on the Kotlin side looked at that: any non-blank `content` counted as a * successful extraction, got written to `articles.extractedContent`, and was never * re-checked. Hence a permanently cached cookie disclaimer. */ class ConsentNoticeTest { @Test fun `the reported New Republic extraction is recognised as a consent notice`() { assertTrue(ConsentNotice.looksLikeConsentNotice(EXTRACTED_COOKIE_NOTICE)) } // Readability strips class attributes but keeps ids, so the CMP container's id // survives into the extracted HTML and is the most precise signal available. @Test fun `other consent-management platforms are recognised by their container id`() { val cmpIds = listOf( "didomi-host", "onetrust-banner-sdk", "onetrust-consent-sdk", "CybotCookiebotDialog", "qc-cmp2-container", "sp_message_container_1234", "truste-consent-track", "usercentrics-root", "osano-cm-dialog", "iubenda-cs-banner", "optanon-alert-box-wrapper", "cookie-law-info-bar", ) for (id in cmpIds) { val html = """
Please review your choices.
We use cookies and similar tracking technologies to personalise content and ads. By continuing to use this site you consent to our use of cookies. You can manage your preferences at any time.
The recipe calls for cookies. We use cookies in the frosting too.
We use cookies and other tracking technologies, and by continuing " + "to use this website you consent to our use of cookies -- that is the boilerplate " + "the GDPR produced, and this article is about where it came from. You can manage " + "your preferences, in theory.
" val html = "A lovely short note about a bridge in Lisbon, with one link and nothing else. This is the entire post.
This website uses cookies and " + "other tracking technologies (“Cookies”) to enhance user experience, to display " + "targeted ads, and to analyze performance and user activity on our website. We also may " + "share information about your activity on our website with our advertising and analytics " + "providers. For more information about our use of Cookies and our privacy practices, see " + "our Privacy Policy. " + "By continuing to use this website, you agree to our " + "Terms and " + "Conditions, including our dispute resolution provisions.