fix: keep bookmark timestamps in wall-clock time

This commit is contained in:
Jonathan Baldie 2026-05-02 01:53:45 +01:00
parent 97c5d6341e
commit bc0e4d59c0
2 changed files with 45 additions and 1 deletions

View file

@ -2,7 +2,7 @@
<div class="flex items-center px-4 py-4 justify-start relative hover:bg-primary/10" :class="wrapperClass" @click.stop="click" @mouseover="mouseover" @mouseleave="mouseleave">
<div class="w-16 max-w-16 text-center">
<p class="text-sm font-mono text-gray-400">
{{ this.$secondsToTimestamp(bookmark.time / playbackRate) }}
{{ this.$secondsToTimestamp(bookmark.time) }}
</p>
</div>
<div class="grow overflow-hidden px-2">

View file

@ -0,0 +1,44 @@
import BookmarkItem from '@/components/modals/bookmarks/BookmarkItem.vue'
describe('BookmarkItem', () => {
const propsData = {
bookmark: {
libraryItemId: 'library-item-1',
time: 3661,
title: 'Chapter note'
},
highlight: false,
playbackRate: 2
}
const stubs = {
'ui-text-input': true,
'ui-btn': true
}
it('renders bookmark timestamps from stored wall-clock time', () => {
const mocks = {
$secondsToTimestamp: (seconds) => {
const totalSeconds = Math.floor(seconds)
const hours = Math.floor(totalSeconds / 3600)
const minutes = Math.floor((totalSeconds % 3600) / 60)
const secs = totalSeconds % 60
return [hours, minutes, secs].map((value) => String(value).padStart(2, '0')).join(':')
},
$axios: {
$patch: cy.stub().resolves({})
},
$toast: {
error: cy.stub()
},
$strings: {
ToastFailedToUpdate: 'Failed to update'
}
}
cy.mount(BookmarkItem, { propsData, mocks, stubs })
cy.contains('01:01:01').should('be.visible')
cy.contains('00:30:30').should('not.exist')
})
})