fix: connect source documents with red thread

This commit is contained in:
2026-08-14 18:11:51 +02:00
parent 38f50848d0
commit 57c8c91f21
3 changed files with 34 additions and 5 deletions
+28 -2
View File
@@ -30,6 +30,10 @@ async function createEvent(page: Page, title: string, narrative: string, occurre
test('a cloned Glass Harbor level can be solved without modifying its template', async ({ page, request }) => {
test.setTimeout(90_000)
await expect.poll(async () => {
const seededLevels = await (await request.get('/api/levels')).json() as { id: string }[]
return seededLevels.some(level => level.id.startsWith('glass-harbor-case-'))
}).toBe(true)
const levels = await (await request.get('/api/levels')).json() as { id: string }[]
const playable = levels.find(level => level.id.startsWith('glass-harbor-case-'))
if (!playable) throw new Error('Glass Harbor playable clone was not seeded')
@@ -96,14 +100,35 @@ test('a cloned Glass Harbor level can be solved without modifying its template',
await waitForSave(page, () => page.getByRole('button', { name: 'ADD TAG & TIGHTEN', exact: true }).click())
await expect(page.locator('.connections g.tightening path')).toBeVisible()
const procurement = page.locator('.evidence-card.folder').filter({ hasText: 'PROCUREMENT & OWNERSHIP' })
await waitForSave(page, () => procurement.getByRole('button', { name: 'OPEN', exact: true }).click())
const companyRegister = page.locator('.source-file-widget.open').filter({ hasText: 'Company Register Extract' })
const memorandum = page.locator('.source-file-widget.open').filter({ hasText: 'Delivery Redirection Memorandum' })
const photograph = page.locator('.source-file-widget.open').filter({ hasText: 'Warehouse 3 Security Photograph' })
await companyRegister.click()
await expect(companyRegister).toHaveClass(/\bselected\b/)
await page.getByRole('button', { name: 'Red thread', exact: true }).click()
await expect(companyRegister).toHaveClass(/\blinking\b/)
await memorandum.click()
await expect(threadEditor.getByText('Company Register Extract · Voss Antiquities Ltd', { exact: true })).toBeVisible()
await expect(threadEditor.getByText('Delivery Redirection Memorandum', { exact: true })).toBeVisible()
await page.getByLabel('Thread tag').fill('Proves Voss owns Warehouse 3')
await waitForSave(page, () => page.getByRole('button', { name: 'ADD TAG & TIGHTEN', exact: true }).click())
await page.getByRole('button', { name: 'Red thread', exact: true }).click()
await photograph.click()
await expect(threadEditor.getByText('Company Register Extract · Voss Antiquities Ltd', { exact: true })).toBeVisible()
await expect(threadEditor.getByText('Warehouse 3 Security Photograph', { exact: true })).toBeVisible()
await page.getByLabel('Thread tag').fill('Proves Voss owns Warehouse 3')
await waitForSave(page, () => page.getByRole('button', { name: 'ADD TAG & TIGHTEN', exact: true }).click())
await page.reload()
await expect(page.locator('.evidence-card.party')).toHaveCount(6)
await expect(page.locator('.evidence-card.event')).toHaveCount(3)
await expect(page.locator('.evidence-card.note')).toHaveCount(1)
await expect(page.locator('.story-strip')).toContainText('CO-771 was diverted to Warehouse 3')
await expect(page.locator('.event-support-lines line')).toHaveCount(6)
await expect(page.locator('.connections path')).toHaveCount(1)
const relationTag = page.locator('.thread-tag')
await expect(page.locator('.connections path')).toHaveCount(3)
const relationTag = page.locator('.thread-tag').filter({ hasText: 'Proof Elias is the driver' })
await expect(relationTag).toContainText('Proof Elias is the driver')
await relationTag.click()
await expect(relationTag).toHaveClass(/\bexpanded\b/)
@@ -120,6 +145,7 @@ test('a cloned Glass Harbor level can be solved without modifying its template',
const solved = await (await request.get(`/api/levels/${playable.id}`)).json()
expect(solved.connections).toContainEqual(expect.objectContaining({ label: 'Proof Elias is the driver', tightness: 85, tagStyle: 'compact' }))
expect(solved.connections.filter((connection: { label?: string }) => connection.label === 'Proves Voss owns Warehouse 3')).toHaveLength(2)
const template = await (await request.get('/api/templates')).json() as { slug: string; currentVersion: number }[]
expect(template).toContainEqual(expect.objectContaining({ slug: 'glass-harbor', currentVersion: 1 }))