fix(rd21): retain draft revisions and qualify conflict recovery
This commit is contained in:
@@ -11,7 +11,7 @@ const apiUrl = 'http://localhost:5302/api';
|
||||
const password = 'E2ePassword123!';
|
||||
type Owner = { id: string; email: string; headers: Record<string, string> };
|
||||
type Sample = { language: 'en' | 'nb'; theme: 'light' | 'dark'; width: number; height: number };
|
||||
type CareerReadback = { profile: StructuredCvProfile; completeness: unknown; cvText: string | null };
|
||||
type CareerReadback = { profile: StructuredCvProfile; completeness: unknown; cvText: string | null; revision: number };
|
||||
type Version = { version: number; source: string; isCurrent: boolean; createdAtUtc: string };
|
||||
type Run = { id: number; status: string; artifactFileName: string | null; operation: unknown };
|
||||
type ReviewDiff = { runId: number; status: string; diff: { categories: { category: string;
|
||||
@@ -98,9 +98,9 @@ async function readSource(api: APIRequestContext) {
|
||||
|
||||
async function seedSource(page: Page, owner: Owner, twoVersions = false) {
|
||||
const raw = 'Exact CURRENT original career source — æøå\nReviewed work and qualifications.\n';
|
||||
await json<CareerReadback>(await page.request.put(`${apiUrl}/career/profile`, { headers: owner.headers, data: { profile: source(), cvText: raw } }));
|
||||
await json<CareerReadback>(await page.request.put(`${apiUrl}/career/profile`, { headers: owner.headers, data: { expectedVersion: (await (await page.request.get(`${apiUrl}/career/profile`)).json()).revision, profile: source(), cvText: raw } }));
|
||||
if (twoVersions) await json<CareerReadback>(await page.request.put(`${apiUrl}/career/profile`, { headers: owner.headers,
|
||||
data: { profile: source('Second reviewed canonical context'), cvText: raw } }));
|
||||
data: { expectedVersion: (await (await page.request.get(`${apiUrl}/career/profile`)).json()).revision, profile: source('Second reviewed canonical context'), cvText: raw } }));
|
||||
return readSource(page.request);
|
||||
}
|
||||
|
||||
@@ -280,7 +280,7 @@ test('[P7-03 PRES-C01 C02 C03 C04 C05 W07] explicit select/deselect acceptance u
|
||||
await page.keyboard.press('Enter');
|
||||
const firstAccepted = await firstResponse;
|
||||
expect(firstAccepted.status()).toBe(200);
|
||||
expect(firstAccepted.request().postDataJSON()).toEqual({ acceptedLowConfidenceIds: [] });
|
||||
expect(firstAccepted.request().postDataJSON()).toEqual({ acceptedLowConfidenceIds: [], expectedVersion: before.canonical.revision });
|
||||
await expect(article.getByText(translations.en.careerImportApplied, { exact: true })).toBeVisible();
|
||||
await expect(article).toBeFocused();
|
||||
const afterFirst = await readSource(page.request);
|
||||
@@ -306,7 +306,7 @@ test('[P7-03 PRES-C01 C02 C03 C04 C05 W07] explicit select/deselect acceptance u
|
||||
await secondArticle.getByRole('button', { name: translations.nb.profileCvApplyChanges, exact: true }).click();
|
||||
const secondAccepted = await secondResponse;
|
||||
expect(secondAccepted.status()).toBe(200);
|
||||
expect(secondAccepted.request().postDataJSON()).toEqual({ acceptedLowConfidenceIds: ['Contact'] });
|
||||
expect(secondAccepted.request().postDataJSON()).toEqual({ acceptedLowConfidenceIds: ['Contact'], expectedVersion: afterFirst.canonical.revision });
|
||||
await expect(secondArticle).toBeFocused();
|
||||
const afterSecond = await readSource(page.request);
|
||||
expect(afterSecond.canonical.profile.contact.email).toBe(importedContactEmail);
|
||||
@@ -314,7 +314,7 @@ test('[P7-03 PRES-C01 C02 C03 C04 C05 W07] explicit select/deselect acceptance u
|
||||
expect((await json<{ email: string }>(await page.request.get(`${apiUrl}/auth/me`))).email).toBe(owner.email);
|
||||
expect(afterSecond.canonical.cvText).toBe(before.canonical.cvText);
|
||||
expect(afterSecond.history).toHaveLength(afterFirst.history.length + 1);
|
||||
expect((await page.request.post(`${apiUrl}/profile-cv/runs/${secondRun}/accept`, { headers: owner.headers, data: { acceptedLowConfidenceIds: ['Contact'] } })).status()).toBe(409);
|
||||
expect((await page.request.post(`${apiUrl}/profile-cv/runs/${secondRun}/accept`, { headers: owner.headers, data: { expectedVersion: afterFirst.canonical.revision, acceptedLowConfidenceIds: ['Contact'] } })).status()).toBe(409);
|
||||
expect(await readSource(page.request)).toEqual(afterSecond);
|
||||
const afterDocuments = await Promise.all(documents.urls.map(async url => json<unknown>(await page.request.get(url))));
|
||||
expect(afterDocuments).toEqual(documents.before);
|
||||
@@ -365,7 +365,7 @@ test('[P7-03 PRES-C02 C04 E09] stored reviews are owner scoped and foreign/anony
|
||||
try {
|
||||
const adminOwner = await login(admin, 'e2e@example.test');
|
||||
const ownerB = await login(other, await createOwner(admin, adminOwner));
|
||||
await json<CareerReadback>(await other.put(`${apiUrl}/career/profile`, { headers: ownerB.headers, data: { profile: source('Owner B reviewed context'), cvText: 'Owner B exact raw' } }));
|
||||
await json<CareerReadback>(await other.put(`${apiUrl}/career/profile`, { headers: ownerB.headers, data: { expectedVersion: (await (await other.get(`${apiUrl}/career/profile`)).json()).revision, profile: source('Owner B reviewed context'), cvText: 'Owner B exact raw' } }));
|
||||
const beforeB = await readSource(other);
|
||||
const runB = seedPending(info, ownerB);
|
||||
await assertReachableLowContact(other, runB, beforeB.canonical.profile.contact.email);
|
||||
@@ -373,12 +373,12 @@ test('[P7-03 PRES-C02 C04 E09] stored reviews are owner scoped and foreign/anony
|
||||
expect((await json<Run[]>(await other.get(`${apiUrl}/profile-cv/runs`))).map(run => run.id)).toEqual([runB]);
|
||||
for (const [api, foreign, headers] of [[page.request, runB, owner.headers], [other, runA, ownerB.headers]] as const) {
|
||||
expect((await api.get(`${apiUrl}/profile-cv/runs/${foreign}/diff`)).status()).toBe(404);
|
||||
expect((await api.post(`${apiUrl}/profile-cv/runs/${foreign}/accept`, { headers, data: { acceptedLowConfidenceIds: ['Contact'] } })).status()).toBe(404);
|
||||
expect((await api.post(`${apiUrl}/profile-cv/runs/${foreign}/accept`, { headers, data: { expectedVersion: 0, acceptedLowConfidenceIds: ['Contact'] } })).status()).toBe(404);
|
||||
expect((await api.post(`${apiUrl}/profile-cv/runs/${foreign}/discard`, { headers })).status()).toBe(404);
|
||||
}
|
||||
expect((await anonymous.get(`${apiUrl}/profile-cv/runs`)).status()).toBe(401);
|
||||
expect((await anonymous.get(`${apiUrl}/profile-cv/runs/${runA}/diff`)).status()).toBe(401);
|
||||
expect((await anonymous.post(`${apiUrl}/profile-cv/runs/${runA}/accept`, { data: { acceptedLowConfidenceIds: [] } })).status()).toBe(401);
|
||||
expect((await anonymous.post(`${apiUrl}/profile-cv/runs/${runA}/accept`, { data: { expectedVersion: 0, acceptedLowConfidenceIds: [] } })).status()).toBe(401);
|
||||
expect((await anonymous.post(`${apiUrl}/profile-cv/runs/${runA}/discard`)).status()).toBe(401);
|
||||
expect(await readSource(page.request)).toEqual(beforeA);
|
||||
expect(await readSource(other)).toEqual(beforeB);
|
||||
|
||||
Reference in New Issue
Block a user