feat(home): import messages open with a full-restoration or partial-recovery headline; BDR-040 recorded
This commit is contained in:
1 parent
de2bd0437e
commit
62b8a43e09
7 files changed
+106
-23
No files matched your search
@@ -1,9 +1,11 @@
|
||||
/**
|
||||
* T15 (STEP6 §7, §16): the home route on Step 6 archives, with
|
||||
* `importReportFromPdf` mocked. Same sheet: archive kept in the store and
|
||||
* mirrored, archive_ok alert. Other sheet: the report is rebased on the
|
||||
* `importReportFromPdf` mocked. Every alert opens with a headline: complete
|
||||
* restoration or partial recovery. Same sheet: archive kept in the store and
|
||||
* mirrored, complete + archive_ok. Other sheet: the report is rebased on the
|
||||
* loaded sheet (unresolved flags, labels from the archived snapshot, sheet
|
||||
* ref updated) and the alert says so with the count. Snapshot rejected: the
|
||||
* ref updated) and the alert says degraded with the count; a rebase that
|
||||
* resolved everything stays complete. Snapshot rejected: degraded with the
|
||||
* reason label. Attachment stripped: its error message.
|
||||
*/
|
||||
import {
|
||||
@@ -159,7 +161,9 @@ async function mountAndPickPdf(): Promise<void> {
|
||||
}
|
||||
|
||||
const alertMock = () => vi.mocked(window.alert)
|
||||
const alertText = () => alertMock().mock.calls[0]![0] as string
|
||||
/** The alert split on its blank lines: headline first, then the detail lines. */
|
||||
const alertLines = () =>
|
||||
(alertMock().mock.calls[0]![0] as string).split('\n\n')
|
||||
const errorText = () => screen.queryByText(/./, { selector: 'p.text-red-700' })
|
||||
|
||||
describe('HomeRoute import of a Step 6 archive', () => {
|
||||
@@ -176,7 +180,10 @@ describe('HomeRoute import of a Step 6 archive', () => {
|
||||
report.id,
|
||||
)
|
||||
expect(alertMock()).toHaveBeenCalledTimes(1)
|
||||
expect(alertText()).toBe(fr['home.import.archive_ok'])
|
||||
expect(alertLines()).toEqual([
|
||||
fr['home.import.complete'],
|
||||
fr['home.import.archive_ok'],
|
||||
])
|
||||
})
|
||||
|
||||
it('other sheet: rebases onto the loaded sheet, labels from the archived snapshot, alert with the count', async () => {
|
||||
@@ -200,12 +207,32 @@ describe('HomeRoute import of a Step 6 archive', () => {
|
||||
// The archive stays as exported, never rebased.
|
||||
expect(useReportStore.getState().archive).toEqual(archive)
|
||||
expect(alertMock()).toHaveBeenCalledTimes(1)
|
||||
expect(alertText()).toBe(
|
||||
[
|
||||
fr['home.import.archive_ok'],
|
||||
fr['home.import.rebased']!.replace('{count}', '2'),
|
||||
].join('\n\n'),
|
||||
)
|
||||
expect(alertLines()).toEqual([
|
||||
fr['home.import.degraded'],
|
||||
fr['home.import.archive_ok'],
|
||||
fr['home.import.rebased']!.replace('{count}', '2'),
|
||||
])
|
||||
})
|
||||
|
||||
it('other sheet, everything resolved: complete headline, the rebased line says 0', async () => {
|
||||
const report = minimalReport(sheet, {
|
||||
sheet: { ...sheet.sheet.ref, documentSha256: OTHER_SHA },
|
||||
observations: reportWithHip().observations,
|
||||
})
|
||||
const archive = archiveEnvelope(sheet, report)
|
||||
archive.sheetSnapshot.ref.documentSha256 = OTHER_SHA
|
||||
importMock.mockResolvedValue(archived(report, archive))
|
||||
await mountAndPickPdf()
|
||||
await screen.findByTestId('editor-route')
|
||||
const opened = useReportStore.getState().report!
|
||||
expect(opened.sheet).toEqual(sheet.sheet.ref)
|
||||
expect(opened.observations[0]!.zones[0]!.unresolved).toBeUndefined()
|
||||
expect(alertMock()).toHaveBeenCalledTimes(1)
|
||||
expect(alertLines()).toEqual([
|
||||
fr['home.import.complete'],
|
||||
fr['home.import.archive_ok'],
|
||||
fr['home.import.rebased']!.replace('{count}', '0'),
|
||||
])
|
||||
})
|
||||
|
||||
it('snapshot rejected: the report opens, the alert names the reason, no archive kept', async () => {
|
||||
@@ -219,12 +246,13 @@ describe('HomeRoute import of a Step 6 archive', () => {
|
||||
expect(useReportStore.getState().archive).toBeNull()
|
||||
expect(sessionStorage.getItem(ARCHIVE_KEY)).toBeNull()
|
||||
expect(alertMock()).toHaveBeenCalledTimes(1)
|
||||
expect(alertText()).toBe(
|
||||
expect(alertLines()).toEqual([
|
||||
fr['home.import.degraded'],
|
||||
fr['home.import.snapshot_rejected']!.replace(
|
||||
'{reason}',
|
||||
fr['home.import.snapshot_reason.caps']!,
|
||||
),
|
||||
)
|
||||
])
|
||||
})
|
||||
|
||||
it('attachment_stripped → its error message, nothing opened', async () => {
|
||||
|
||||
Reference in new issue
Block a user