feat(qa): add synthesis conversations with source retention (#52)
This commit is contained in:
63
frontend/e2e/ticket54-summary-qa.spec.mjs
Normal file
63
frontend/e2e/ticket54-summary-qa.spec.mjs
Normal file
@ -0,0 +1,63 @@
|
||||
import { expect, test } from '@playwright/test'
|
||||
import { readStackManifest } from './stack-manifest.mjs'
|
||||
|
||||
for (const width of [1280, 375]) test(`ticket #54: passage and Q&A remain accessible at ${width}px`, async ({ page }) => {
|
||||
const stack = readStackManifest()
|
||||
await page.setViewportSize({ width, height: 850 })
|
||||
await page.context().route('**/*', route => {
|
||||
const host = new URL(route.request().url()).hostname
|
||||
return host === '127.0.0.1' || host === '[::1]' ? route.continue() : route.abort('blockedbyclient')
|
||||
})
|
||||
const summary = { id: '00000000-0000-0000-0000-000000005401', user_id: 'reader', content: 'Passage de la synthèse pour poser une question.', ai_provider_id: null, generated_at: '2026-11-25T00:00:00Z' }
|
||||
const conversation = { id: 'c', summary_id: summary.id, mode: 'stateless', uses_source_articles: false, provider_session_supported: false, source_expires_at: '2026-01-01T00:00:00Z', sources_expired: true, source_count: 0, messages: [] }
|
||||
const questions = []
|
||||
await page.route('**/api/**', async route => {
|
||||
const path = new URL(route.request().url()).pathname
|
||||
const respond = data => route.fulfill({ json: { data } })
|
||||
if (path === '/api/summaries') return respond([summary])
|
||||
if (path === '/api/summaries/generations' || path === '/api/me/assets') return respond([])
|
||||
if (path === '/api/summaries/generation-jobs/recent') return respond(null)
|
||||
if (path === `/api/summaries/${summary.id}/conversation`) return respond(conversation)
|
||||
if (path === `/api/summaries/${summary.id}/conversation/messages`) {
|
||||
const question = route.request().postDataJSON()
|
||||
questions.push(question)
|
||||
const turn = { ...question, id: 't', answer: 'Réponse sur cette synthèse.', status: 'answered', replayed: false, created_at: '2026-11-25T00:00:00Z' }
|
||||
conversation.messages.push(turn)
|
||||
return respond(turn)
|
||||
}
|
||||
return route.continue()
|
||||
})
|
||||
await page.goto(new URL('/login', stack.frontendUrl).href)
|
||||
await page.getByLabel('Adresse email').fill(stack.bootstrapAdmin.email)
|
||||
await page.getByLabel('Mot de passe').fill(stack.bootstrapAdmin.password)
|
||||
await page.getByRole('button', { name: 'Se connecter' }).click()
|
||||
const passage = page.getByText(summary.content, { exact: true })
|
||||
await expect(passage).toBeVisible()
|
||||
await passage.evaluate(element => {
|
||||
for (const name of ['contextmenu', 'selectstart', 'copy', 'touchstart']) {
|
||||
if (!element.dispatchEvent(new Event(name, { bubbles: true, cancelable: true }))) throw new Error(`${name} blocked`)
|
||||
}
|
||||
if (getComputedStyle(element).userSelect === 'none') throw new Error('selection disabled')
|
||||
const range = document.createRange()
|
||||
range.selectNodeContents(element)
|
||||
const selection = window.getSelection()
|
||||
selection.removeAllRanges()
|
||||
selection.addRange(range)
|
||||
document.dispatchEvent(new Event('selectionchange'))
|
||||
})
|
||||
await expect(page.getByRole('textbox', { name: 'Votre question' })).toHaveCount(0)
|
||||
await page.getByRole('button', { name: 'Interroger ce passage' }).click()
|
||||
const question = page.getByRole('textbox', { name: 'Votre question' })
|
||||
await expect(question).toBeFocused()
|
||||
await expect(page.getByText(/Les sources ont expiré/)).toBeVisible()
|
||||
await question.fill('Que signifie ce passage ?')
|
||||
await page.getByRole('button', { name: 'Envoyer la question' }).click()
|
||||
await expect(page.getByText('Réponse sur cette synthèse.', { exact: true })).toBeVisible()
|
||||
expect(questions).toHaveLength(1)
|
||||
expect(questions[0]).toMatchObject({ passage: summary.content, question: 'Que signifie ce passage ?', request_id: expect.stringMatching(/^[a-f0-9-]{36}$/) })
|
||||
expect(await page.evaluate(() => document.documentElement.scrollWidth <= innerWidth)).toBe(true)
|
||||
await page.getByRole('button', { name: 'Retour à la synthèse' }).click()
|
||||
await expect(page.getByRole('button', { name: 'Interroger ce passage' })).toBeFocused()
|
||||
await page.getByRole('button', { name: 'Questions sur cette synthèse' }).click()
|
||||
await expect(page.getByText('Réponse sur cette synthèse.', { exact: true })).toBeVisible()
|
||||
})
|
||||
Reference in New Issue
Block a user