fix(ui): keep synthesis chat launcher above mobile navigation (#65)
This commit is contained in:
@ -1,7 +1,7 @@
|
|||||||
import { expect, test } from '@playwright/test'
|
import { expect, test } from '@playwright/test'
|
||||||
import { readStackManifest } from './stack-manifest.mjs'
|
import { readStackManifest } from './stack-manifest.mjs'
|
||||||
|
|
||||||
for (const width of [1280, 375]) test(`ticket #64: synthesis chat, attachments and web citations at ${width}px`, async ({ page }) => {
|
for (const width of [1280, 375]) test(`ticket #65: fixed chat launcher, synthesis chat and web citations at ${width}px`, async ({ page }) => {
|
||||||
const stack = readStackManifest()
|
const stack = readStackManifest()
|
||||||
await page.setViewportSize({ width, height: 850 })
|
await page.setViewportSize({ width, height: 850 })
|
||||||
await page.context().route('**/*', route => {
|
await page.context().route('**/*', route => {
|
||||||
@ -39,14 +39,70 @@ for (const width of [1280, 375]) test(`ticket #64: synthesis chat, attachments a
|
|||||||
const passage = page.getByText(excerpt, { exact: true })
|
const passage = page.getByText(excerpt, { exact: true })
|
||||||
await expect(passage).toBeVisible()
|
await expect(passage).toBeVisible()
|
||||||
const action = page.getByRole('button', { name: 'Ouvrir le chat de cette synthèse' })
|
const action = page.getByRole('button', { name: 'Ouvrir le chat de cette synthèse' })
|
||||||
const generate = page.getByRole('button', { name: 'Générer une synthèse' })
|
|
||||||
await expect(action).toBeVisible()
|
await expect(action).toBeVisible()
|
||||||
await expect(action).toHaveAttribute('title', 'Ouvrir le chat de cette synthèse')
|
await expect(action).toHaveAttribute('title', 'Ouvrir le chat de cette synthèse')
|
||||||
expect(await action.evaluate(element => element.parentElement.nextElementSibling === [...element.parentElement.parentElement.querySelectorAll('button')].find(button => button.textContent.includes('Générer')))).toBe(true)
|
const wrapper = action.locator('..')
|
||||||
const actionBox = await action.boundingBox()
|
expect(await wrapper.evaluate(element => element.parentElement === document.body)).toBe(true)
|
||||||
const generateBox = await generate.boundingBox()
|
await expect(wrapper).toHaveCSS('position', 'fixed')
|
||||||
expect(actionBox.y + actionBox.height).toBeLessThanOrEqual(generateBox.y)
|
await expect(action).toHaveCSS('width', '48px')
|
||||||
expect(await action.evaluate(element => getComputedStyle(element).position)).not.toBe('fixed')
|
await expect(action).toHaveCSS('height', '48px')
|
||||||
|
const nav = page.getByRole('navigation', { name: 'Navigation mobile' })
|
||||||
|
async function checkPosition() {
|
||||||
|
const box = await action.boundingBox()
|
||||||
|
const viewport = page.viewportSize()
|
||||||
|
if (viewport.width >= 768) {
|
||||||
|
expect(viewport.width - box.x - box.width).toBeCloseTo(24)
|
||||||
|
expect(viewport.height - box.y - box.height).toBeCloseTo(24)
|
||||||
|
await expect(nav).not.toBeVisible()
|
||||||
|
} else {
|
||||||
|
const safeRight = await page.evaluate(() => {
|
||||||
|
const probe = document.createElement('div')
|
||||||
|
probe.style.paddingRight = 'env(safe-area-inset-right, 0px)'
|
||||||
|
document.body.append(probe)
|
||||||
|
const inset = parseFloat(getComputedStyle(probe).paddingRight)
|
||||||
|
probe.remove()
|
||||||
|
return inset
|
||||||
|
})
|
||||||
|
expect(viewport.width - box.x - box.width).toBeCloseTo(16 + safeRight)
|
||||||
|
await expect.poll(async () => {
|
||||||
|
const navBox = await nav.boundingBox(), launcherBox = await action.boundingBox()
|
||||||
|
return Math.round((navBox.y - launcherBox.y - launcherBox.height) * 10) / 10
|
||||||
|
}).toBe(16)
|
||||||
|
expect(Number(await wrapper.evaluate(element => getComputedStyle(element).zIndex))).toBeGreaterThan(Number(await nav.evaluate(element => getComputedStyle(element).zIndex)))
|
||||||
|
}
|
||||||
|
expect(await action.evaluate(element => {
|
||||||
|
const rect = element.getBoundingClientRect()
|
||||||
|
return element.contains(document.elementFromPoint(rect.x + rect.width / 2, rect.y + rect.height / 2))
|
||||||
|
})).toBe(true)
|
||||||
|
}
|
||||||
|
await checkPosition()
|
||||||
|
const initialBox = await action.boundingBox()
|
||||||
|
const main = page.locator('main')
|
||||||
|
await main.evaluate(element => { element.scrollTop = element.scrollHeight })
|
||||||
|
expect(await main.evaluate(element => element.scrollTop)).toBeGreaterThan(0)
|
||||||
|
const scrolledBox = await action.boundingBox()
|
||||||
|
expect(scrolledBox.x).toBeCloseTo(initialBox.x)
|
||||||
|
expect(scrolledBox.y).toBeCloseTo(initialBox.y)
|
||||||
|
await checkPosition()
|
||||||
|
if (width < 768) {
|
||||||
|
// Exercise actual nav height changes (including extra safe-area-like padding).
|
||||||
|
await nav.evaluate(element => { element.style.paddingBottom = '23px' })
|
||||||
|
await checkPosition()
|
||||||
|
await nav.evaluate(element => { element.style.removeProperty('padding-bottom') })
|
||||||
|
await checkPosition()
|
||||||
|
await page.setViewportSize({ width, height: 650 })
|
||||||
|
await page.evaluate(() => window.dispatchEvent(new Event('orientationchange')))
|
||||||
|
await checkPosition()
|
||||||
|
await page.setViewportSize({ width, height: 850 })
|
||||||
|
await checkPosition()
|
||||||
|
// Extra main padding keeps the final history card above the launcher and nav.
|
||||||
|
await main.evaluate(element => { element.scrollTop = element.scrollHeight })
|
||||||
|
const lastCard = await page.getByRole('button', { name: 'Autre synthèse de test.…' }).boundingBox()
|
||||||
|
const launcherBox = await action.boundingBox()
|
||||||
|
expect(lastCard.y + lastCard.height).toBeLessThanOrEqual(launcherBox.y)
|
||||||
|
}
|
||||||
|
const mainScrollBeforeChat = await main.evaluate(element => element.scrollTop)
|
||||||
|
const launcherZ = Number(await wrapper.evaluate(element => getComputedStyle(element).zIndex))
|
||||||
|
|
||||||
// Global question is possible without selecting or attaching any text.
|
// Global question is possible without selecting or attaching any text.
|
||||||
await action.click()
|
await action.click()
|
||||||
@ -55,6 +111,7 @@ for (const width of [1280, 375]) test(`ticket #64: synthesis chat, attachments a
|
|||||||
const webSearch = dialog.getByRole('checkbox', { name: 'Utiliser la recherche Web si nécessaire pour répondre ; la synthèse complète, les échanges précédents, votre question et tout passage joint seront transmis au fournisseur du modèle sélectionné.' })
|
const webSearch = dialog.getByRole('checkbox', { name: 'Utiliser la recherche Web si nécessaire pour répondre ; la synthèse complète, les échanges précédents, votre question et tout passage joint seront transmis au fournisseur du modèle sélectionné.' })
|
||||||
const add = dialog.getByRole('button', { name: 'Ajouter le passage sélectionné à la question' })
|
const add = dialog.getByRole('button', { name: 'Ajouter le passage sélectionné à la question' })
|
||||||
await expect(dialog.getByRole('heading')).toBeFocused()
|
await expect(dialog.getByRole('heading')).toBeFocused()
|
||||||
|
expect(Number(await dialog.evaluate(element => getComputedStyle(element).zIndex))).toBeGreaterThan(launcherZ)
|
||||||
await expect(question).toHaveValue('')
|
await expect(question).toHaveValue('')
|
||||||
await expect(add).toHaveCount(0)
|
await expect(add).toHaveCount(0)
|
||||||
expect(questions).toHaveLength(0)
|
expect(questions).toHaveLength(0)
|
||||||
@ -69,6 +126,7 @@ for (const width of [1280, 375]) test(`ticket #64: synthesis chat, attachments a
|
|||||||
await expect(question).toHaveValue('')
|
await expect(question).toHaveValue('')
|
||||||
await page.keyboard.press('Escape')
|
await page.keyboard.press('Escape')
|
||||||
await expect(action).toBeFocused()
|
await expect(action).toBeFocused()
|
||||||
|
expect(await main.evaluate(element => element.scrollTop)).toBe(mainScrollBeforeChat)
|
||||||
|
|
||||||
async function selectText(element) {
|
async function selectText(element) {
|
||||||
await element.evaluate(element => {
|
await element.evaluate(element => {
|
||||||
|
|||||||
@ -58,14 +58,13 @@ export interface SummaryQADraft {
|
|||||||
type SummaryQAProps = {
|
type SummaryQAProps = {
|
||||||
summaryId: string
|
summaryId: string
|
||||||
content: string
|
content: string
|
||||||
launcherHost?: HTMLElement | null
|
|
||||||
initialDraft?: SummaryQADraft
|
initialDraft?: SummaryQADraft
|
||||||
onDraftChange?: (summaryId: string, draft: SummaryQADraft) => void
|
onDraftChange?: (summaryId: string, draft: SummaryQADraft) => void
|
||||||
}
|
}
|
||||||
export function SummaryQA(props: SummaryQAProps) {
|
export function SummaryQA(props: SummaryQAProps) {
|
||||||
return <Conversation key={props.summaryId} {...props} />
|
return <Conversation key={props.summaryId} {...props} />
|
||||||
}
|
}
|
||||||
function Conversation({ summaryId, content, launcherHost, initialDraft, onDraftChange }: SummaryQAProps) {
|
function Conversation({ summaryId, content, initialDraft, onDraftChange }: SummaryQAProps) {
|
||||||
const id = useId()
|
const id = useId()
|
||||||
const text = useRef<HTMLDivElement>(null)
|
const text = useRef<HTMLDivElement>(null)
|
||||||
const title = useRef<HTMLHeadingElement>(null)
|
const title = useRef<HTMLHeadingElement>(null)
|
||||||
@ -179,14 +178,14 @@ function Conversation({ summaryId, content, launcherHost, initialDraft, onDraftC
|
|||||||
}
|
}
|
||||||
const busy = conversation?.messages.some(turn => turn.status === 'pending')
|
const busy = conversation?.messages.some(turn => turn.status === 'pending')
|
||||||
const launcher = <Dialog.Trigger asChild>
|
const launcher = <Dialog.Trigger asChild>
|
||||||
<Button ref={returnButton} type="button" variant="outline" size="icon" className="min-h-11 min-w-11" aria-label="Ouvrir le chat de cette synthèse" title="Ouvrir le chat de cette synthèse">
|
<Button ref={returnButton} type="button" variant="outline" size="icon" className="h-[48px] w-[48px] shadow-lg" aria-label="Ouvrir le chat de cette synthèse" title="Ouvrir le chat de cette synthèse">
|
||||||
<MessageCircleQuestion className="h-5 w-5" aria-hidden="true" />
|
<MessageCircleQuestion className="h-5 w-5" aria-hidden="true" />
|
||||||
</Button>
|
</Button>
|
||||||
</Dialog.Trigger>
|
</Dialog.Trigger>
|
||||||
return <div className="space-y-4 min-w-0">
|
return <div className="space-y-4 min-w-0">
|
||||||
<div ref={text} className="select-text"><Markdown content={content} /></div>
|
<div ref={text} className="select-text"><Markdown content={content} /></div>
|
||||||
<Dialog.Root open={open} onOpenChange={changeOpen}>
|
<Dialog.Root open={open} onOpenChange={changeOpen}>
|
||||||
{launcherHost === undefined ? launcher : launcherHost ? createPortal(launcher, launcherHost) : null}
|
{createPortal(<div className="fixed z-[55] right-[calc(16px+env(safe-area-inset-right,0px))] bottom-[calc(var(--mobile-nav-offset,64px)+16px)] md:right-[24px] md:bottom-[24px]">{launcher}</div>, document.body)}
|
||||||
<Dialog.Portal>
|
<Dialog.Portal>
|
||||||
<Dialog.Overlay className="fixed inset-0 z-[60] bg-black/50" />
|
<Dialog.Overlay className="fixed inset-0 z-[60] bg-black/50" />
|
||||||
<Dialog.Content
|
<Dialog.Content
|
||||||
|
|||||||
@ -17,7 +17,7 @@ export function AppLayout() {
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
{/* Main content */}
|
{/* Main content */}
|
||||||
<main className="min-w-0 flex-1 overflow-y-auto pb-16 md:pb-0">
|
<main className="min-w-0 flex-1 overflow-y-auto pb-[calc(var(--mobile-nav-offset,64px)+80px)] md:pb-0">
|
||||||
{notice && <p role="status" className="m-4 rounded-md border bg-muted p-3 text-sm">{notice}</p>}
|
{notice && <p role="status" className="m-4 rounded-md border bg-muted p-3 text-sm">{notice}</p>}
|
||||||
<Outlet />
|
<Outlet />
|
||||||
</main>
|
</main>
|
||||||
|
|||||||
@ -1,3 +1,4 @@
|
|||||||
|
import { useLayoutEffect, useRef } from 'react'
|
||||||
import { NavLink } from 'react-router-dom'
|
import { NavLink } from 'react-router-dom'
|
||||||
import { LayoutDashboard, Star, Settings, FileText } from 'lucide-react'
|
import { LayoutDashboard, Star, Settings, FileText } from 'lucide-react'
|
||||||
import { useAuth } from '@/lib/auth'
|
import { useAuth } from '@/lib/auth'
|
||||||
@ -12,9 +13,34 @@ const items = [
|
|||||||
|
|
||||||
export function MobileNav() {
|
export function MobileNav() {
|
||||||
const { isAdmin } = useAuth()
|
const { isAdmin } = useAuth()
|
||||||
|
const nav = useRef<HTMLElement>(null)
|
||||||
|
useLayoutEffect(() => {
|
||||||
|
const element = nav.current
|
||||||
|
if (!element) return
|
||||||
|
const root = document.documentElement
|
||||||
|
const previous = root.style.getPropertyValue('--mobile-nav-offset')
|
||||||
|
const measure = () => {
|
||||||
|
const rect = element.getBoundingClientRect()
|
||||||
|
// The real rect already includes the current safe area and wrapping/layout.
|
||||||
|
const offset = rect.height > 0 ? Math.max(0, window.innerHeight - rect.top) : 0
|
||||||
|
root.style.setProperty('--mobile-nav-offset', `${offset}px`)
|
||||||
|
}
|
||||||
|
measure()
|
||||||
|
const observer = typeof ResizeObserver === 'undefined' ? null : new ResizeObserver(measure)
|
||||||
|
observer?.observe(element, { box: 'border-box' })
|
||||||
|
window.addEventListener('resize', measure)
|
||||||
|
window.addEventListener('orientationchange', measure)
|
||||||
|
return () => {
|
||||||
|
observer?.disconnect()
|
||||||
|
window.removeEventListener('resize', measure)
|
||||||
|
window.removeEventListener('orientationchange', measure)
|
||||||
|
if (previous) root.style.setProperty('--mobile-nav-offset', previous)
|
||||||
|
else root.style.removeProperty('--mobile-nav-offset')
|
||||||
|
}
|
||||||
|
}, [])
|
||||||
const visibleItems = isAdmin ? [...items, { to: '/admin', icon: Settings, label: 'Admin' }] : items
|
const visibleItems = isAdmin ? [...items, { to: '/admin', icon: Settings, label: 'Admin' }] : items
|
||||||
return (
|
return (
|
||||||
<nav className="fixed bottom-0 left-0 right-0 z-50 flex border-t bg-card md:hidden shadow-sm">
|
<nav ref={nav} aria-label="Navigation mobile" className="fixed bottom-0 left-0 right-0 z-50 flex border-t bg-card md:hidden shadow-sm">
|
||||||
{visibleItems.map(({ to, icon: Icon, label }) => (
|
{visibleItems.map(({ to, icon: Icon, label }) => (
|
||||||
<NavLink
|
<NavLink
|
||||||
key={to}
|
key={to}
|
||||||
|
|||||||
@ -29,7 +29,6 @@ export function Dashboard() {
|
|||||||
const [assets, setAssets] = useState<Asset[]>([])
|
const [assets, setAssets] = useState<Asset[]>([])
|
||||||
const [loading, setLoading] = useState(true)
|
const [loading, setLoading] = useState(true)
|
||||||
const [generating, setGenerating] = useState(false)
|
const [generating, setGenerating] = useState(false)
|
||||||
const [chatLauncherHost, setChatLauncherHost] = useState<HTMLDivElement | null>(null)
|
|
||||||
const [chatDrafts, setChatDrafts] = useState(() => new Map<string, SummaryQADraft>())
|
const [chatDrafts, setChatDrafts] = useState(() => new Map<string, SummaryQADraft>())
|
||||||
const saveChatDraft = useCallback((summaryId: string, draft: SummaryQADraft) => {
|
const saveChatDraft = useCallback((summaryId: string, draft: SummaryQADraft) => {
|
||||||
setChatDrafts(currentDrafts => {
|
setChatDrafts(currentDrafts => {
|
||||||
@ -173,12 +172,9 @@ export function Dashboard() {
|
|||||||
<h1 className="text-2xl font-bold">Bonjour 👋</h1>
|
<h1 className="text-2xl font-bold">Bonjour 👋</h1>
|
||||||
<p className="text-muted-foreground text-sm">{user?.email}</p>
|
<p className="text-muted-foreground text-sm">{user?.email}</p>
|
||||||
</div>
|
</div>
|
||||||
<div className="flex flex-col items-end gap-2">
|
|
||||||
<div ref={setChatLauncherHost} />
|
|
||||||
<Button onClick={generate} disabled={generating || checking || uncertain || loading || assets.length === 0 || !selectedModel}>
|
<Button onClick={generate} disabled={generating || checking || uncertain || loading || assets.length === 0 || !selectedModel}>
|
||||||
{generating && !uncertain ? <><Spinner className="h-4 w-4" /> {copy.pending}</> : <><Sparkles className="h-4 w-4" /> {copy.generate}</>}
|
{generating && !uncertain ? <><Spinner className="h-4 w-4" /> {copy.pending}</> : <><Sparkles className="h-4 w-4" /> {copy.generate}</>}
|
||||||
</Button>
|
</Button>
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
{loadError && <div role="alert"><p>{loadError}</p><Button onClick={() => void load()}>Recharger</Button></div>}
|
{loadError && <div role="alert"><p>{loadError}</p><Button onClick={() => void load()}>Recharger</Button></div>}
|
||||||
@ -220,7 +216,7 @@ export function Dashboard() {
|
|||||||
</CardHeader>
|
</CardHeader>
|
||||||
<CardContent>
|
<CardContent>
|
||||||
<p className="text-sm text-muted-foreground mb-3">Langue de cette synthèse : {currentOutcome ? (currentOutcome.language === 'fr' ? 'Français' : 'English') : 'non renseignée'}</p>
|
<p className="text-sm text-muted-foreground mb-3">Langue de cette synthèse : {currentOutcome ? (currentOutcome.language === 'fr' ? 'Français' : 'English') : 'non renseignée'}</p>
|
||||||
<SummaryQA summaryId={current.id} content={current.content} launcherHost={chatLauncherHost} initialDraft={chatDrafts.get(current.id)} onDraftChange={saveChatDraft} />
|
<SummaryQA summaryId={current.id} content={current.content} initialDraft={chatDrafts.get(current.id)} onDraftChange={saveChatDraft} />
|
||||||
<p className="mt-3 text-sm text-muted-foreground">Modèle utilisé : {current.provider_name && current.model_name ? `${current.provider_name} · ${current.model_name}` : 'non renseigné pour cette synthèse historique'}</p>
|
<p className="mt-3 text-sm text-muted-foreground">Modèle utilisé : {current.provider_name && current.model_name ? `${current.provider_name} · ${current.model_name}` : 'non renseigné pour cette synthèse historique'}</p>
|
||||||
</CardContent>
|
</CardContent>
|
||||||
</Card>
|
</Card>
|
||||||
|
|||||||
60
frontend/tests/chat-launcher-ticket65.test.tsx
Normal file
60
frontend/tests/chat-launcher-ticket65.test.tsx
Normal file
@ -0,0 +1,60 @@
|
|||||||
|
import { act, cleanup, fireEvent, render, screen, within } from '@testing-library/react'
|
||||||
|
import userEvent from '@testing-library/user-event'
|
||||||
|
import { afterEach, expect, it, vi } from 'vitest'
|
||||||
|
import { MemoryRouter } from 'react-router-dom'
|
||||||
|
import { SummaryQA } from '../src/components/SummaryQA'
|
||||||
|
import { MobileNav } from '../src/components/layout/MobileNav'
|
||||||
|
vi.mock('@/api/summaryQA', () => ({ summaryQAApi: { get: vi.fn().mockResolvedValue({ id: 'c', messages: [], web_search_supported: true }) } }))
|
||||||
|
vi.mock('@/lib/auth', () => ({ useAuth: () => ({ isAdmin: false }) }))
|
||||||
|
afterEach(() => { cleanup(); vi.restoreAllMocks(); vi.unstubAllGlobals() })
|
||||||
|
it('porte le trigger dans body hors du main scrollable, avec wrapper fixe et retour du focus', async () => {
|
||||||
|
vi.spyOn(window, 'scrollTo').mockImplementation(() => {})
|
||||||
|
const result = render(<main style={{ overflowY: 'auto', height: 400 }}><SummaryQA summaryId="s" content="Synthèse" /></main>)
|
||||||
|
Object.defineProperty(result.container.querySelector('main'), 'scrollTo', { value: vi.fn() })
|
||||||
|
const action = screen.getByRole('button', { name: 'Ouvrir le chat de cette synthèse' })
|
||||||
|
const wrapper = action.parentElement!
|
||||||
|
expect(wrapper.parentElement).toBe(document.body)
|
||||||
|
expect(wrapper).toHaveClass('fixed')
|
||||||
|
expect(wrapper.className).toContain('safe-area-inset-right')
|
||||||
|
expect(within(result.container).queryByRole('button', { name: 'Ouvrir le chat de cette synthèse' })).not.toBeInTheDocument()
|
||||||
|
fireEvent.scroll(result.container.querySelector('main')!, { target: { scrollTop: 700 } })
|
||||||
|
expect(action.parentElement).toBe(wrapper)
|
||||||
|
await userEvent.click(action)
|
||||||
|
expect(await screen.findByRole('dialog')).toBeInTheDocument()
|
||||||
|
await userEvent.keyboard('{Escape}')
|
||||||
|
expect(action).toHaveFocus()
|
||||||
|
})
|
||||||
|
it('publie la distance réelle nav→bas viewport et réagit au ResizeObserver, resize et rotation', () => {
|
||||||
|
let top = 730, height = 120
|
||||||
|
vi.stubGlobal('innerHeight', 850)
|
||||||
|
vi.spyOn(HTMLElement.prototype, 'getBoundingClientRect').mockImplementation(() => new DOMRect(0, top, 375, height))
|
||||||
|
let notify!: () => void
|
||||||
|
const observe = vi.fn(), disconnect = vi.fn()
|
||||||
|
vi.stubGlobal('ResizeObserver', class {
|
||||||
|
constructor(callback: () => void) { notify = callback }
|
||||||
|
observe = observe
|
||||||
|
disconnect = disconnect
|
||||||
|
})
|
||||||
|
const result = render(<MemoryRouter><MobileNav /></MemoryRouter>)
|
||||||
|
const offset = () => document.documentElement.style.getPropertyValue('--mobile-nav-offset')
|
||||||
|
expect(offset()).toBe('120px')
|
||||||
|
expect(observe).toHaveBeenCalledWith(screen.getByRole('navigation'), { box: 'border-box' })
|
||||||
|
top = 700; height = 150
|
||||||
|
act(() => notify())
|
||||||
|
expect(offset()).toBe('150px')
|
||||||
|
// A moved nav with the same height must still update on viewport changes.
|
||||||
|
top = 680
|
||||||
|
fireEvent(window, new Event('resize'))
|
||||||
|
expect(offset()).toBe('170px')
|
||||||
|
top = 650
|
||||||
|
fireEvent(window, new Event('orientationchange'))
|
||||||
|
expect(offset()).toBe('200px')
|
||||||
|
height = 0; top = 0
|
||||||
|
fireEvent(window, new Event('resize'))
|
||||||
|
expect(offset()).toBe('0px')
|
||||||
|
result.unmount()
|
||||||
|
expect(disconnect).toHaveBeenCalledOnce()
|
||||||
|
expect(offset()).toBe('')
|
||||||
|
fireEvent(window, new Event('resize'))
|
||||||
|
expect(offset()).toBe('')
|
||||||
|
})
|
||||||
@ -171,15 +171,18 @@ describe('Dashboard — génération de synthèses éphémères', () => {
|
|||||||
} finally { window.getSelection()?.removeAllRanges(); vi.restoreAllMocks() }
|
} finally { window.getSelection()?.removeAllRanges(); vi.restoreAllMocks() }
|
||||||
})
|
})
|
||||||
|
|
||||||
it('place le launcher chat dans le header directement au-dessus de Générer', async () => {
|
it('rend le launcher hors du header Dashboard et le masque sans synthèse', async () => {
|
||||||
renderDashboard()
|
const result = renderDashboard()
|
||||||
const launcher = await screen.findByRole('button', { name: 'Ouvrir le chat de cette synthèse' })
|
const launcher = await screen.findByRole('button', { name: 'Ouvrir le chat de cette synthèse' })
|
||||||
const generate = screen.getByRole('button', { name: 'Générer une synthèse' })
|
expect(launcher.parentElement).toHaveClass('fixed')
|
||||||
expect(launcher.parentElement?.nextElementSibling).toBe(generate)
|
expect(launcher.parentElement?.parentElement).toBe(document.body)
|
||||||
expect(launcher.parentElement?.parentElement).toBe(generate.parentElement)
|
expect(result.container.contains(launcher)).toBe(false)
|
||||||
expect(generate.parentElement).toHaveClass('flex-col')
|
|
||||||
expect(launcher).not.toHaveClass('fixed')
|
|
||||||
expect(launcher.querySelector('svg')).toBeInTheDocument()
|
expect(launcher.querySelector('svg')).toBeInTheDocument()
|
||||||
|
result.unmount()
|
||||||
|
listSummaries.mockResolvedValue([])
|
||||||
|
renderDashboard()
|
||||||
|
await screen.findByText('Aucune synthèse disponible')
|
||||||
|
expect(screen.queryByRole('button', { name: 'Ouvrir le chat de cette synthèse' })).not.toBeInTheDocument()
|
||||||
})
|
})
|
||||||
|
|
||||||
it.each(['ranking_model_unavailable', 'ranking_model_incompatible'])('guide vers les préférences pour %s', async (failure_code) => {
|
it.each(['ranking_model_unavailable', 'ranking_model_incompatible'])('guide vers les préférences pour %s', async (failure_code) => {
|
||||||
|
|||||||
@ -115,10 +115,10 @@ it.each([45, undefined])('explique le quota Q&A avec délai %s et conserve la qu
|
|||||||
expect(alert).toHaveTextContent(seconds === undefined ? 'Réessayez dans quelques instants.' : 'Réessayez dans 45 secondes.')
|
expect(alert).toHaveTextContent(seconds === undefined ? 'Réessayez dans quelques instants.' : 'Réessayez dans 45 secondes.')
|
||||||
expect(screen.getByRole('textbox')).toHaveValue('Pourquoi ?')
|
expect(screen.getByRole('textbox')).toHaveValue('Pourquoi ?')
|
||||||
})
|
})
|
||||||
it('garde le launcher dans le flux et mémorise une sélection au scroll/collapse sans ouvrir', () => {
|
it('garde le launcher fixe et mémorise une sélection au scroll/collapse sans ouvrir', () => {
|
||||||
render(<SummaryQA summaryId="s" content="Un passage de synthèse." />)
|
render(<SummaryQA summaryId="s" content="Un passage de synthèse." />)
|
||||||
const action = screen.getByRole('button', { name: 'Ouvrir le chat de cette synthèse' })
|
const action = screen.getByRole('button', { name: 'Ouvrir le chat de cette synthèse' })
|
||||||
expect(action).not.toHaveClass('fixed')
|
expect(action.parentElement).toHaveClass('fixed')
|
||||||
selectPassage()
|
selectPassage()
|
||||||
window.getSelection()?.removeAllRanges()
|
window.getSelection()?.removeAllRanges()
|
||||||
fireEvent(document, new Event('selectionchange'))
|
fireEvent(document, new Event('selectionchange'))
|
||||||
|
|||||||
@ -118,15 +118,12 @@ it('le polling ne supprime jamais le nouveau brouillon rédigé après envoi pen
|
|||||||
expect(screen.getByRole('textbox')).toHaveValue('Nouveau brouillon')
|
expect(screen.getByRole('textbox')).toHaveValue('Nouveau brouillon')
|
||||||
expect(screen.getByLabelText('Passage joint')).toHaveTextContent('Premier passage.')
|
expect(screen.getByLabelText('Passage joint')).toHaveTextContent('Premier passage.')
|
||||||
})
|
})
|
||||||
it('le launcher est rendu dans le host header sans déplacer le lecteur de synthèse', async () => {
|
it('le launcher est portalé dans body sans déplacer le lecteur de synthèse', async () => {
|
||||||
const host = document.createElement('div'); document.body.append(host)
|
const result = render(<SummaryQA summaryId="s" content="Contenu" />)
|
||||||
try {
|
expect(screen.getByRole('button', { name: launcher }).parentElement?.parentElement).toBe(document.body)
|
||||||
const result = render(<SummaryQA summaryId="s" content="Contenu" launcherHost={host} />)
|
expect(within(result.container).getByText('Contenu')).toBeInTheDocument()
|
||||||
expect(within(host).getByRole('button', { name: launcher })).toBeInTheDocument()
|
expect(within(result.container).queryByRole('button', { name: launcher })).not.toBeInTheDocument()
|
||||||
expect(within(result.container).getByText('Contenu')).toBeInTheDocument()
|
await open()
|
||||||
expect(within(result.container).queryByRole('button', { name: launcher })).not.toBeInTheDocument()
|
|
||||||
await open()
|
|
||||||
} finally { host.remove() }
|
|
||||||
})
|
})
|
||||||
|
|
||||||
it('valide question vide/plus de 4000 caractères et accepte une question d’un caractère sans passage', async () => {
|
it('valide question vide/plus de 4000 caractères et accepte une question d’un caractère sans passage', async () => {
|
||||||
|
|||||||
Reference in New Issue
Block a user