A small module assembles preview text for a notification. For each message, it must return normalized text, and if there is no useful text, use a fallback template. After a recent PR, the behavior started diverging from what is expected: the fallback template is triggered in the wrong cases, and some side effects happen even when they are not needed.
buildPreview method must return:
body if it is not empty after trim;fallback.fallback is a lazy argument. It must not be evaluated if the main body is suitable.auditPreview method must:
fallback was actually used;buildPreview.body count as missing useful content.Message(" Done ") with a fallback value that increments an external counter;Message(" ") with a non-empty fallback value;auditPreview for a message with a normal body.Message(" Done "), the text "Done" should be returned, and fallback must not be evaluated.Message(" "), fallback should be used.auditPreview must not change auditCount if the fallback path was not needed.3.3.121PreviewService methods directly, without I/O and without multithreadingUse line comments to explain the problem, its impact, the fix and how to test it.