fixed rest detail showing zeros without rest data

This commit is contained in:
Flaminel committed 2026-10-28 22:27:49 +02:00
1 parent ba77792b59
commit 3df02257e2
2 files changed
+15 -2

No files matched your search

@@ -138,6 +138,16 @@ describe('SeekerPreviewDrawerComponent', () => {
]);
});
it('renders no detail line for a resting exclusion without rest fields', () => {
const { fixture, host } = setup(of(preview({
excluded: [{ name: 'Iota', reason: SeekerExclusionReason.Resting }],
})));
open(fixture, host);
expect(texts('.preview__detail')).toEqual([]);
});
it('requests the preview for the instance when opened', () => {
const { fixture, host, getPreview } = setup();
@@ -116,9 +116,12 @@ export class SeekerPreviewDrawerComponent {
if (item.reason !== SeekerExclusionReason.Resting) {
return '';
}
const cycles = item.restCyclesLeft ?? 0;
if (item.restCyclesLeft == null || item.consecutiveMisses == null) {
return '';
}
const cycles = item.restCyclesLeft;
const until = item.restUntil ? ` or on ${formatDate(item.restUntil, 'MM/dd', this.locale)}` : '';
return `${item.consecutiveMisses ?? 0} misses in a row · back after ${cycles} ${cycles === 1 ? 'cycle' : 'cycles'} end${until}`;
return `${item.consecutiveMisses} misses in a row · back after ${cycles} ${cycles === 1 ? 'cycle' : 'cycles'} end${until}`;
}
refresh(): void {