fix(ui): keep synthesis chat launcher above mobile navigation (#65)

This commit is contained in:
2026-11-26 15:28:48 +01:00
parent f75de489cc
commit 057857fd7a
9 changed files with 175 additions and 36 deletions

View File

@ -1,7 +1,7 @@
import { expect, test } from '@playwright/test'
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()
await page.setViewportSize({ width, height: 850 })
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 })
await expect(passage).toBeVisible()
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).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 actionBox = await action.boundingBox()
const generateBox = await generate.boundingBox()
expect(actionBox.y + actionBox.height).toBeLessThanOrEqual(generateBox.y)
expect(await action.evaluate(element => getComputedStyle(element).position)).not.toBe('fixed')
const wrapper = action.locator('..')
expect(await wrapper.evaluate(element => element.parentElement === document.body)).toBe(true)
await expect(wrapper).toHaveCSS('position', 'fixed')
await expect(action).toHaveCSS('width', '48px')
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.
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 add = dialog.getByRole('button', { name: 'Ajouter le passage sélectionné à la question' })
await expect(dialog.getByRole('heading')).toBeFocused()
expect(Number(await dialog.evaluate(element => getComputedStyle(element).zIndex))).toBeGreaterThan(launcherZ)
await expect(question).toHaveValue('')
await expect(add).toHaveCount(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 page.keyboard.press('Escape')
await expect(action).toBeFocused()
expect(await main.evaluate(element => element.scrollTop)).toBe(mainScrollBeforeChat)
async function selectText(element) {
await element.evaluate(element => {