variable header size
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
import { describe, it, expect, vi, beforeEach } from 'vitest'
|
||||
import { flushPromises } from '@vue/test-utils'
|
||||
import axios from 'axios'
|
||||
import { useFeeds } from '../useFeeds'
|
||||
|
||||
@@ -12,7 +13,7 @@ class FakeIntersectionObserver {
|
||||
vi.stubGlobal('IntersectionObserver', FakeIntersectionObserver)
|
||||
|
||||
describe('useFeeds', () => {
|
||||
const { feeds, showMessage, message, showModal, fetchData, sync, getReadable, setInitialLoad, handleIntersection } = useFeeds()
|
||||
const { feeds, showMessage, message, showModal, fetchData, sync, getReadable, setInitialLoad, handleIntersection, consumeScrollCorrection } = useFeeds()
|
||||
|
||||
beforeEach(() => {
|
||||
localStorage.setItem('user-token', 'test-token')
|
||||
@@ -116,6 +117,36 @@ describe('useFeeds', () => {
|
||||
setInitialLoad(false)
|
||||
})
|
||||
|
||||
it('flags a scroll correction when marking an article read repositions the list', async () => {
|
||||
// Regression coverage for the header-compacting glitch: AppNav's scroll
|
||||
// handler needs a way to tell "the page moved because content was
|
||||
// removed" apart from a real user scroll. jsdom's getBoundingClientRect()
|
||||
// defaults every element's top to 0, so any topbarHeight > 0 exercises
|
||||
// the same "first article now sits above the header" branch that fires
|
||||
// in a real browser.
|
||||
feeds.value = [{ id: 101, title: 'First' }, { id: 102, title: 'Second' }]
|
||||
setInitialLoad(true)
|
||||
axios.put.mockResolvedValue({ status: 200 })
|
||||
|
||||
const observeDiv = document.createElement('div')
|
||||
observeDiv.className = 'observe'
|
||||
document.body.appendChild(observeDiv)
|
||||
|
||||
expect(consumeScrollCorrection()).toBe(false)
|
||||
|
||||
await handleIntersection([
|
||||
{ isIntersecting: false, boundingClientRect: { y: -10 }, target: { id: '0' } },
|
||||
], 60)
|
||||
await flushPromises()
|
||||
|
||||
expect(consumeScrollCorrection()).toBe(true)
|
||||
// Consume-once: asking again without another correction reports false.
|
||||
expect(consumeScrollCorrection()).toBe(false)
|
||||
|
||||
document.body.removeChild(observeDiv)
|
||||
setInitialLoad(false)
|
||||
})
|
||||
|
||||
it('strips leftover embedded-video placeholder headings', async () => {
|
||||
feeds.value = [{
|
||||
id: 1,
|
||||
|
||||
Reference in New Issue
Block a user