Change-tracking remains a minor footgun in our team’s codebase, where we sometimes to have to catch it ourselves. Liveview only emits a warning under certain circumstances.
E.g. if we update a map wrong, the entire map will end up being re-rendered
# Tweets is a list of 5 tweets, stored as a map for _reasons_
updated_sections = sections
|> Map.put(5, Tweet.new(some_params))
socket
|> assign(sections: updated_sections)
|> noreply()
This will cause all the previously rendered tweets to re-render, even though they have no changes.
My question is: how to catch this in tests? We have a few places where breaking change-tracking is expensive, and I want to add exunit tests to confirm the changes are tracked correctly. But I’m struggling with the internals on how to do that.
Any tips or ideas?