Add mandate text to payment option#2035
Conversation
| putString("image", imageBase64) | ||
| } | ||
|
|
||
| fun AnnotatedString.toHtmlString(): String { |
There was a problem hiding this comment.
Is it possible to add unit tests for something like this?
There was a problem hiding this comment.
I think it may be possible! However I'm on the fence as we'd be unit testing two system APIs (toSpannable and toHtml). I suppose we could test that toSpannable and toHtml preserve the attributes we care about. If we think there's value (maybe some Android quirk I'm overlooking) I'm happy to add some unit tests as I think it's feasible.
There was a problem hiding this comment.
I think it's probably a good idea to write a unit test that ensures we're preserving links from the original, as well as a simple text based example.
| ) | ||
| Assert.assertTrue( | ||
| "Result should contain link text", | ||
| result.contains("Terms of Service"), |
There was a problem hiding this comment.
I'd expect this to assert there's an a href in here.
There was a problem hiding this comment.
Thanks for probing, during my tests manually I can see the links being preserved but during tests there are some cases not handled. Going to beef up the implementation of toHtml.
There was a problem hiding this comment.
After testing more and throwing more test cases at the spannable API, it turns out it drops some stuff like links. So I think the best path forward is to recreate a basic HTML string based on the attributes in the string, took some inspiration from here and help from Claude 🙈 Added more tests this time around.
jaynewstrom-stripe
left a comment
There was a problem hiding this comment.
Thanks for digging in! The tests make me feel better!
Summary
Motivation
https://docs.google.com/document/d/1OaY8oTGsO2dPS7HhZTCKB-tLoCN2m_S1ag0kJ83eD_E/edit?tab=t.0#heading=h.570u4leviueu
Documentation