fix(research): verify creation acknowledgements before leaving drafts (RP31)
This commit is contained in:
parent
b09b2de406
commit
57ba86d035
8 changed files with 552 additions and 22 deletions
|
|
@ -164,7 +164,15 @@ const artifact = (hypothesisRevisionId: string | null = null): ResearchArtifact
|
|||
});
|
||||
function acceptedFinding(hypothesisRevisionId: string | null = null): ResearchArtifact {
|
||||
const saved = artifact(hypothesisRevisionId);
|
||||
const input = post().body as { evidence: ResearchEvidenceReference[] };
|
||||
const input = post().body as {
|
||||
title: string;
|
||||
body: string;
|
||||
contentOrigin: 'human' | 'ai' | 'unknown';
|
||||
evidence: ResearchEvidenceReference[];
|
||||
};
|
||||
saved.latestRevision.title = input.title;
|
||||
saved.latestRevision.body = input.body;
|
||||
saved.latestRevision.contentOrigin = input.contentOrigin;
|
||||
saved.latestRevision.source = null;
|
||||
saved.latestRevision.evidence = input.evidence.map(reference => ({
|
||||
...reference,
|
||||
|
|
@ -411,6 +419,43 @@ describe('saved-result finding', () => {
|
|||
expect(host.textContent).toContain('narrative remains unvalidated');
|
||||
expect(closed).toBe(0);
|
||||
});
|
||||
test.each([
|
||||
['title', { title: 'Substituted narrative' }],
|
||||
['body', { body: 'Substituted narrative' }],
|
||||
['origin', { contentOrigin: 'unknown' }],
|
||||
['parent', { artifactId: 'different-entry' }],
|
||||
['noninitial ordinal', { ordinal: 2 }],
|
||||
['validated state', { validationState: 'validated' }],
|
||||
['evidence state', { evidenceState: 'none' }],
|
||||
] as const)('%s narrative acknowledgement freezes the finding draft', async (_label, change) => {
|
||||
await mountDialog();
|
||||
await draft();
|
||||
await preflight();
|
||||
const saved = acceptedFinding();
|
||||
await flush(() =>
|
||||
reply(
|
||||
post(),
|
||||
{ artifact: { ...saved, latestRevision: { ...saved.latestRevision, ...change } } },
|
||||
201
|
||||
)
|
||||
);
|
||||
expect(host.textContent).toContain('saved finding response could not be verified');
|
||||
expect(host.textContent).not.toContain('Finding saved.');
|
||||
expect(field('Finding title').value).toBe('Exact finding');
|
||||
expect(field('Finding body').value).toBe('Keep this narrative');
|
||||
expect(button('Save finding').disabled).toBe(true);
|
||||
expect(host.querySelector('a[href*="artifact=saved-finding"]')).toBeNull();
|
||||
await flush(() => button('Save finding').click());
|
||||
expect(requests.filter(item => item.method === 'POST')).toHaveLength(1);
|
||||
});
|
||||
test('archived creation acknowledgement cannot claim a saved finding', async () => {
|
||||
await mountDialog();
|
||||
await draft();
|
||||
await preflight();
|
||||
await flush(() => reply(post(), { artifact: { ...acceptedFinding(), archived: true } }, 201));
|
||||
expect(host.textContent).toContain('saved finding response could not be verified');
|
||||
expect(button('Save finding').disabled).toBe(true);
|
||||
});
|
||||
test.each([
|
||||
'empty',
|
||||
'missing',
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue