mirror of
https://github.com/bookorbit/bookorbit.git
synced 2026-11-03 00:11:37 -06:00
fix(library): display reading start threshold accurately
Render the configured threshold in percentage points so library details agree with the editor for fractional values. Fixes #1563
This commit is contained in:
@@ -524,11 +524,28 @@ describe('LibrariesSettings ledger', () => {
|
||||
expect(panel).toContain('Embedded metadata, OPF files')
|
||||
expect(panel).toContain('All supported')
|
||||
expect(panel).toContain('1 pattern')
|
||||
expect(panel).toContain('25%')
|
||||
expect(panel).toContain('0.25%')
|
||||
expect(panel).toContain('98%')
|
||||
expect(panel).toContain('2 people')
|
||||
})
|
||||
|
||||
it.each([
|
||||
{ threshold: 0.05, expected: '0.05%' },
|
||||
{ threshold: 0.25, expected: '0.25%' },
|
||||
{ threshold: 0.5, expected: '0.5%' },
|
||||
{ threshold: 1, expected: '1%' },
|
||||
{ threshold: 5, expected: '5%' },
|
||||
])('shows a $threshold% reading threshold as $expected', async ({ threshold, expected }) => {
|
||||
librariesRef.value = [makeLibrary({ id: 4, readingThreshold: threshold, markAsFinishedPercentComplete: 98 })]
|
||||
const wrapper = await mountLoaded()
|
||||
await expandFirst(wrapper)
|
||||
const panel = wrapper.get('[id="library-detail-4"]')
|
||||
const startedLabel = panel.findAll('dt').find((label) => label.text() === 'Counts as started')
|
||||
const finishedLabel = panel.findAll('dt').find((label) => label.text() === 'Counts as finished')
|
||||
expect(startedLabel?.element.nextElementSibling?.textContent?.trim()).toBe(expected)
|
||||
expect(finishedLabel?.element.nextElementSibling?.textContent?.trim()).toBe('98%')
|
||||
})
|
||||
|
||||
it('renders the scan history with trigger and deltas', async () => {
|
||||
historyRef.value = [
|
||||
{ id: 9, ...makeScan({ triggeredBy: 'watcher', addedCount: 3, updatedCount: 1 }) },
|
||||
|
||||
@@ -6,7 +6,7 @@ import type { Library, LibraryScanHistoryEntry } from '@bookorbit/types'
|
||||
import { formatKeyName } from '@/features/book/lib/book-formats'
|
||||
import { Button } from '@/components/ui/button'
|
||||
import { Skeleton } from '@/components/ui/skeleton'
|
||||
import { formatDate, formatList, formatPercent } from '@/i18n/formatters'
|
||||
import { formatDate, formatList, formatNumber, formatPercent } from '@/i18n/formatters'
|
||||
import { METADATA_LABELS } from '@/features/library/composables/useLibraryCreator'
|
||||
import LibraryScanHistory from './LibraryScanHistory.vue'
|
||||
|
||||
@@ -41,6 +41,7 @@ const formatsLabel = computed(() =>
|
||||
: formatList(props.library.allowedFormats.map((format) => formatKeyName(format))),
|
||||
)
|
||||
const accessLabel = computed(() => (props.accessCount === null ? '' : t('settings.admin.libraries.detail.peopleCount', { count: props.accessCount })))
|
||||
const readingThresholdLabel = computed(() => formatNumber(props.library.readingThreshold / 100, { style: 'percent', maximumFractionDigits: 2 }))
|
||||
|
||||
function requestEdit() {
|
||||
emit('edit', props.library)
|
||||
@@ -115,7 +116,7 @@ function requestEdit() {
|
||||
</div>
|
||||
<div class="flex items-center gap-3 border-t border-border py-1.5">
|
||||
<dt class="shrink-0 text-[12.5px] text-muted-foreground">{{ t('settings.admin.libraries.detail.countsAsStarted') }}</dt>
|
||||
<dd class="ms-auto text-[12.5px] font-medium tabular-nums text-foreground">{{ formatPercent(library.readingThreshold) }}</dd>
|
||||
<dd class="ms-auto text-[12.5px] font-medium tabular-nums text-foreground">{{ readingThresholdLabel }}</dd>
|
||||
</div>
|
||||
<div class="flex items-center gap-3 border-t border-border py-1.5">
|
||||
<dt class="shrink-0 text-[12.5px] text-muted-foreground">{{ t('settings.admin.libraries.detail.countsAsFinished') }}</dt>
|
||||
|
||||
Reference in New Issue
Block a user