This functionality does not seem to work in Obsidian’s Markdown Preview, instead the whole text is simply visible at once if rendered on multiple lines like this:
<details>
<summary>title</summary>
some text
</details>
Instead, the text collapses as intended only if the tags are written on one line along with the text like this:
<details><summary> collapsible headings</summary> under click to reveal text</details>