(
}
override suspend fun listProjectStructureTree(): PyResult
").text("world")
+
+ val html = buffer.toString()
+
+ assertEquals("hello
world", html)
+ // Guard against the regression itself — the identity string looks like `HtmlBuffer@57f54152`.
+ assertFalse(
+ html.startsWith("com.jetbrains.python.requirements.HtmlBuffer@")
+ || html.startsWith("HtmlBuffer@"),
+ "toString must not return the default Object identity string; got `$html`",
+ )
+ }
+
+ @Test
+ fun `toString on an empty buffer returns an empty string`() {
+ assertEquals("", HtmlBuffer().toString())
+ }
+
+ @Test
+ fun `text escapes XML special characters`() {
+ val html = HtmlBuffer()
+ .text("")
+ .toString()
+
+ assertEquals("<script>alert('x')</script>", html)
+ }
+
+ @Test
+ fun `text escapes an ampersand exactly once`() {
+ val html = HtmlBuffer().text("Rock & Roll").toString()
+
+ assertEquals("Rock & Roll", html)
+ assertFalse(html.contains("&"), "double-escape regression check")
+ }
+
+ @Test
+ fun `raw preserves markup verbatim`() {
+ val html = HtmlBuffer().raw("bold").toString()
+
+ assertEquals("bold", html)
+ }
+
+ @Test
+ fun `text and raw compose in call order`() {
+ val name = ">)?.result ?: emptyList()
+ }
+}
+
+/**
+ * Test-only [PythonRepositoryManager] that returns its constructor argument verbatim as
+ * [allRepositories]. Everything else is left to the interface defaults — that is the whole
+ * point of the test: the default `repositories` / `searchPackages` / `hasPackageSnapshot`
+ * paths must apply the `enabled` filter without any help from the implementation.
+ */
+private class FilteringFakeRepositoryManager(
+ override val allRepositories: List
, PythonPackageSearchPage.DataInvalidatedError> =
+ Result.Success(matches)
+ }),
+ maxPageSize = pageSize,
+ )
+ }
+
+ override fun hasPackage(name: String): Boolean = packages.contains(name)
+}
diff --git a/python/testSrc/com/jetbrains/python/packaging/management/TestPythonRepositoryManager.kt b/python/testSrc/com/jetbrains/python/packaging/management/TestPythonRepositoryManager.kt
index dece09cc2119..eb002acda8cf 100644
--- a/python/testSrc/com/jetbrains/python/packaging/management/TestPythonRepositoryManager.kt
+++ b/python/testSrc/com/jetbrains/python/packaging/management/TestPythonRepositoryManager.kt
@@ -45,7 +45,7 @@ internal class TestPythonRepositoryManager(
return this
}
- override val repositories: List