feat(editor): « Citer » button and family labels in references
This commit is contained in:
1 parent
240c2ba0e7
commit
8c3fcca0b9
16 files changed
+507
-53
No files matched your search
@@ -58,7 +58,7 @@ const ref = (id: string, citation: string, url = '', doi = '') =>
|
||||
},
|
||||
}) as const
|
||||
|
||||
function sheetText(): string {
|
||||
function sheetText(family = ['ref-a', 'ref-b']): string {
|
||||
let text = baseText()
|
||||
text = insert(text, ref('ref-a', 'Barone, Ostéologie'))
|
||||
text = insert(text, ref('ref-b', 'Denoix', 'https://exemple.org/Épaule'))
|
||||
@@ -77,7 +77,7 @@ function sheetText(): string {
|
||||
kind: 'dysfunction',
|
||||
name: name('Cat A'),
|
||||
description: {},
|
||||
reference_ids: ['ref-a', 'ref-b'],
|
||||
reference_ids: family,
|
||||
review_status: 'to_confirm',
|
||||
children: [],
|
||||
},
|
||||
@@ -86,8 +86,8 @@ function sheetText(): string {
|
||||
}
|
||||
|
||||
/** The sheet plus one finding node under Cat A (default: citing ref-a and ref-c). */
|
||||
function nodeText(ids = ['ref-a', 'ref-c']): string {
|
||||
return edit(sheetText(), {
|
||||
function nodeText(ids = ['ref-a', 'ref-c'], family?: string[]): string {
|
||||
return edit(sheetText(family), {
|
||||
op: 'insert',
|
||||
parent: { kind: 'finding', zone_id: 'zone-a', path: ['fcat-a'] },
|
||||
element: {
|
||||
@@ -590,3 +590,115 @@ describe('the panel review fixes', () => {
|
||||
await focusIs(heading)
|
||||
})
|
||||
})
|
||||
|
||||
describe('the family wording (Rev 6)', () => {
|
||||
const familyHeading = (name: string) =>
|
||||
within(citationsDialog()).getByRole('heading', { name })
|
||||
const chip = () => screen.getByTestId('editor-references-filter')
|
||||
const showAll = (user: User) =>
|
||||
user.click(
|
||||
within(panel()).getByRole('button', {
|
||||
name: "Tout afficher dans l'onglet Références",
|
||||
}),
|
||||
)
|
||||
|
||||
it('a family: dialog title, count, its own tile row, edit title', async () => {
|
||||
const user = await mount()
|
||||
await select(user, /Cat A/)
|
||||
await user.click(trigger())
|
||||
await focusIs(closeButton)
|
||||
expect(familyHeading('Références de la famille')).toBeVisible()
|
||||
expect(panel()).toHaveTextContent('2 références citées par cette famille')
|
||||
await user.click(within(panel()).getByRole('button', { name: /^Barone/ }))
|
||||
const tile = tiles()[0] as HTMLElement
|
||||
expect(within(tile).getByText('cette famille')).toBeInTheDocument()
|
||||
expect(within(tile).queryByText('famille')).toBeNull()
|
||||
await user.click(
|
||||
within(citationsDialog()).getByRole('button', { name: 'Modifier' }),
|
||||
)
|
||||
await waitFor(() =>
|
||||
expect(
|
||||
familyHeading('Modifier les références de la famille'),
|
||||
).toBeVisible(),
|
||||
)
|
||||
})
|
||||
|
||||
it('a finding keeps the finding wording', async () => {
|
||||
const user = await mount()
|
||||
await openFromFinding(user)
|
||||
expect(heading()).toBeVisible()
|
||||
expect(panel()).toHaveTextContent('2 références citées par ce constat')
|
||||
})
|
||||
|
||||
it('an empty family: the empty line, then the filtered tab names the family', async () => {
|
||||
const user = await mount(1280, nodeText(['ref-a', 'ref-c'], []))
|
||||
await select(user, /Cat A/)
|
||||
await user.click(trigger('0 référence'))
|
||||
await focusIs(closeButton)
|
||||
expect(panel()).toHaveTextContent('Cette famille ne cite aucune référence.')
|
||||
await showAll(user)
|
||||
await closed()
|
||||
expect(chip()).toHaveTextContent('Références de la famille : Cat A')
|
||||
expect(
|
||||
within(chip()).getByRole('button', {
|
||||
name: 'Retirer le filtre de la famille Cat A',
|
||||
}),
|
||||
).toBeVisible()
|
||||
expect(
|
||||
within(chip()).getByRole('button', { name: 'Revenir à la famille' }),
|
||||
).toBeVisible()
|
||||
expect(screen.getByTestId('editor-references-no-result')).toHaveTextContent(
|
||||
'Cette famille ne cite aucune référence.',
|
||||
)
|
||||
})
|
||||
|
||||
it('a filtered family removed by an undo says the family is gone', async () => {
|
||||
const user = await mount()
|
||||
act(() => {
|
||||
store.getState().commit({
|
||||
op: 'insert',
|
||||
parent: { kind: 'zone', id: 'zone-a' },
|
||||
element: {
|
||||
kind: 'finding_category',
|
||||
value: {
|
||||
id: 'fcat-b',
|
||||
kind: 'dysfunction',
|
||||
name: name('Cat B'),
|
||||
description: {},
|
||||
reference_ids: ['ref-c'],
|
||||
review_status: 'to_confirm',
|
||||
children: [],
|
||||
},
|
||||
},
|
||||
})
|
||||
})
|
||||
await select(user, /Cat B/)
|
||||
await user.click(trigger('1 référence'))
|
||||
await showAll(user)
|
||||
await closed()
|
||||
expect(chip()).toHaveTextContent('Références de la famille : Cat B')
|
||||
act(() => {
|
||||
store.getState().undoStep()
|
||||
})
|
||||
await waitFor(() =>
|
||||
expect(live()).toHaveTextContent(
|
||||
"La famille n'existe plus : le filtre est retiré",
|
||||
),
|
||||
)
|
||||
})
|
||||
|
||||
it('a family that vanishes closes its dialog and says the family is gone', async () => {
|
||||
const user = await mount()
|
||||
await select(user, /Cat A/)
|
||||
act(() => {
|
||||
store.getState().commit({
|
||||
op: 'remove',
|
||||
key: { kind: 'finding', zone_id: 'zone-a', path: ['fcat-a'] },
|
||||
})
|
||||
})
|
||||
await waitFor(() => expect(findingDialog()).toBeNull())
|
||||
await waitFor(() =>
|
||||
expect(live()).toHaveTextContent("Cette famille n'existe plus"),
|
||||
)
|
||||
})
|
||||
})
|
||||
Reference in new issue
Block a user