fix(research): preserve verified hypothesis links after partial lookup failure (RP11)
This commit is contained in:
parent
f4cee5affa
commit
32f40ee753
3 changed files with 136 additions and 17 deletions
|
|
@ -627,6 +627,105 @@ describe('research workspace', () => {
|
|||
[...host.querySelectorAll('button')].some(item => item.textContent === 'Edit latest revision')
|
||||
).toBe(false);
|
||||
});
|
||||
for (const failureFirst of [false, true]) {
|
||||
test(`exact hypothesis link survives unrelated history failure (${failureFirst ? 'failure first' : 'match first'})`, async () => {
|
||||
const original = hypothesis().latestRevision;
|
||||
const linked = hypothesis('h1', {
|
||||
latestRevision: { ...original, id: 'h1-r2', ordinal: 2 },
|
||||
});
|
||||
const finding = artifact('a1', { kind: 'finding', hypothesisRevisionId: original.id });
|
||||
await mount('/research/p1?artifact=a1');
|
||||
await flush(() => replyProject(project(), [linked, hypothesis('h2')], [finding]));
|
||||
await flush(() => replyArtifact(finding));
|
||||
const match = () =>
|
||||
reply(request('hypotheses/h1/revisions'), {
|
||||
revisions: [original, linked.latestRevision],
|
||||
});
|
||||
const failure = () =>
|
||||
reply(request('hypotheses/h2/revisions'), { error: 'Temporary history failure' }, 503);
|
||||
await flush(failureFirst ? failure : match);
|
||||
await flush(failureFirst ? match : failure);
|
||||
expect(
|
||||
host.querySelector('a[href="/research/p1?hypothesis=h1&revision=h1-r1"]')
|
||||
).not.toBeNull();
|
||||
expect(host.textContent).not.toContain('Could not resolve the linked hypothesis history');
|
||||
expect(host.textContent).not.toContain('unavailable in the loaded project history');
|
||||
});
|
||||
}
|
||||
test('incomplete hypothesis lookup remains retryable through project refresh', async () => {
|
||||
const original = hypothesis().latestRevision;
|
||||
const linked = hypothesis('h1', {
|
||||
latestRevision: { ...original, id: 'h1-r2', ordinal: 2 },
|
||||
});
|
||||
const unrelated = hypothesis('h2');
|
||||
const finding = artifact('a1', { kind: 'finding', hypothesisRevisionId: original.id });
|
||||
await mount('/research/p1?artifact=a1');
|
||||
await flush(() => replyProject(project(), [linked, unrelated], [finding]));
|
||||
await flush(() => replyArtifact(finding));
|
||||
await flush(() => {
|
||||
reply(request('hypotheses/h1/revisions'), { error: 'Temporary history failure' }, 503);
|
||||
reply(request('hypotheses/h2/revisions'), { revisions: [unrelated.latestRevision] });
|
||||
});
|
||||
expect(host.textContent).toContain('Could not resolve the linked hypothesis history');
|
||||
expect(host.textContent).not.toContain('unavailable in the loaded project history');
|
||||
expect(host.querySelector('a[href*="?hypothesis=h1&revision=h1-r1"]')).toBeNull();
|
||||
await flush(() => click('Refresh project'));
|
||||
await flush(() => replyProject(project(), [linked, unrelated], [finding]));
|
||||
await flush(() => {
|
||||
reply(request('hypotheses/h1/revisions'), { revisions: [original, linked.latestRevision] });
|
||||
reply(request('hypotheses/h2/revisions'), { revisions: [unrelated.latestRevision] });
|
||||
});
|
||||
expect(host.textContent).not.toContain('Could not resolve the linked hypothesis history');
|
||||
expect(
|
||||
host.querySelector('a[href="/research/p1?hypothesis=h1&revision=h1-r1"]')
|
||||
).not.toBeNull();
|
||||
});
|
||||
test('fully read hypothesis history distinguishes absence and rejects a foreign revision owner', async () => {
|
||||
const finding = artifact('a1', { kind: 'finding', hypothesisRevisionId: 'missing-r1' });
|
||||
await mount('/research/p1?artifact=a1');
|
||||
await flush(() => replyProject(project(), [hypothesis()], [finding]));
|
||||
await flush(() => replyArtifact(finding));
|
||||
await flush(() =>
|
||||
reply(request('hypotheses/h1/revisions'), {
|
||||
revisions: [
|
||||
hypothesis().latestRevision,
|
||||
{ ...hypothesis('h2').latestRevision, id: 'missing-r1' },
|
||||
],
|
||||
})
|
||||
);
|
||||
expect(host.textContent).toContain('unavailable in the loaded project history');
|
||||
expect(host.textContent).not.toContain('Could not resolve the linked hypothesis history');
|
||||
expect(host.querySelector('a[href*="?hypothesis="]')).toBeNull();
|
||||
});
|
||||
for (const destination of ['finding', 'project'] as const) {
|
||||
test(`late hypothesis resolution cannot attach to a different ${destination}`, async () => {
|
||||
const original = hypothesis().latestRevision;
|
||||
const linked = hypothesis('h1', {
|
||||
latestRevision: { ...original, id: 'h1-r2', ordinal: 2 },
|
||||
});
|
||||
const finding = artifact('a1', { kind: 'finding', hypothesisRevisionId: original.id });
|
||||
await mount('/research/p1?artifact=a1');
|
||||
await flush(() => replyProject(project(), [linked, hypothesis('h2')], [finding]));
|
||||
await flush(() => replyArtifact(finding));
|
||||
const previousMatch = request('hypotheses/h1/revisions');
|
||||
const previousFailure = request('hypotheses/h2/revisions');
|
||||
const nextProjectId = destination === 'project' ? 'p2' : 'p1';
|
||||
const next = artifact('a2', { projectId: nextProjectId, kind: 'finding' });
|
||||
await flush(() => navigate(`/research/${nextProjectId}?artifact=a2`));
|
||||
if (destination === 'project') {
|
||||
await flush(() => replyProject(project('p2'), [], [next]));
|
||||
}
|
||||
await flush(() => replyArtifact(next));
|
||||
await flush(() => {
|
||||
reply(previousMatch, { revisions: [original, linked.latestRevision] });
|
||||
reply(previousFailure, { error: 'Temporary history failure' }, 503);
|
||||
});
|
||||
expect(location).toBe(`/research/${nextProjectId}?artifact=a2`);
|
||||
expect(host.querySelector('a[href*="?hypothesis="]')).toBeNull();
|
||||
expect(host.textContent).not.toContain('Linked hypothesis revision:');
|
||||
expect(host.textContent).not.toContain('Could not resolve the linked hypothesis history');
|
||||
});
|
||||
}
|
||||
test('late entry read and late revision success cannot overwrite a newly selected entry', async () => {
|
||||
await mount('/research/p1?hypothesis=h1');
|
||||
await flush(() => replyProject());
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue