test(cv): qualify concurrent library renames in two browser tabs

This commit is contained in:
cesnimda
2026-11-20 19:28:41 +01:00
parent 89128e1c33
commit 68f33253a8
2 changed files with 73 additions and 1 deletions
@@ -32,3 +32,21 @@ The library now compares the name shown in the dialog with the name returned by
**Evidence scope.** The tests render the real library and prompt with mocked transport. A native two-tab/browser run, real database writes, PDF rendering and full integrated acceptance were outside this execution. The earlier 85-case verification above is historical. The changed library source blob is `4b5018c6e549a4c5711dcc84a00082629af0ef80` and test blob is `448f46e977f4c733b3d99265e500fed8ee7779bf`.
The AST-only Graphify refresh completed with 20,198 nodes and 50,033 edges. SQL extraction was unavailable and 146 source files yielded no symbols.
## Native two-tab rename and SQLite readback · 20 November 2026
Application source `89128e1c33378bf2c65f2f28b048a63957772eb7`. Two Chromium tabs shared a signed-in synthetic owner and the same CV. Tab one opened Rename on revision 1. Tab two renamed the CV through its library and committed revision 2. Tab one submitted its still-open draft, saw the conflict and the persisted name, and issued **zero PUTs**. After the owner reopened Rename and reviewed that name, tab one issued exactly one PUT with expected revision 2. A reload in tab two displayed the reviewed name. The variant and history APIs returned revisions 1, 2, 3. A separate read-only SQLite query against the disposable database verified exactly those three rows and identical stored settings at each revision.
**Passed.** Two native cases ran with one worker, zero retries, zero skips and zero flaky results. The new pre-read conflict case took 7.7 s. The existing post-read race took 4.7 s and received the real server 409 before an explicit retry. Both used a freshly built .NET 9.0.317 Release API, a unique local SQLite data root and a fresh static export. The .NET build had zero warnings or errors. The exact-lock Next 16.4.6 build completed compilation, TypeScript and static generation. The three component suites passed all 77 cases on the same dependencies; these overlap the 77 earlier cases. Scoped ESLint, whitespace and the AST refresh passed (20,199 nodes and 50,038 edges).
**Build recovery.** The initial webpack attempt used a cross-drive dependency junction which resolved Next 16.4.1 and failed module resolution. An independent offline `npm ci` installed 806 packages from the lockfile. The successful runs used Next 16.4.6, Jest 30.4.2 and Playwright 1.62.1. The npm log retained dependency deprecation notices and a pending install script for the resolver. No dependency versions changed. The local API emitted its existing SQLite migration and development key-storage warnings. This run did not qualify production migrations, backup/restore or key storage.
| Evidence | Identity |
| --- | --- |
| New browser test, Git blob | `a57a77d87a377ae26ac0869469ab04732d93249b` |
| Dependency lock, Git blob | `4c277d454e1164b1e24f21f463b5251052e53eaa` |
| Playwright JSON, SHA-256 | `861352d6c00beb09d6e7fee5f0e596992d4eb2658fe07a65c0599f81e344ad10` |
| Pinned Jest JSON, SHA-256 | `b6b5fd043f750e5a979f5ba70f81c86e314303eaaf707339b3fbc490a06d980b` |
| Static export index / Release API DLL, SHA-256 | `78a5db16a0e85d8f3ead4cb6431d7fd021148b6d02d38007a4701769fb9f7e39` / `769e32f5c4f8bac61743dce67748dd5198cbbc472c8c6c1630ccefe81a1c91d2` |
Raw receipts are under `E:/Storage/Projects/Active/temp docs/jobjakt-local-build/cv-library-rename-verification/`. Reproduce with the existing isolated static-export Playwright configuration and `phase7-cv-library.spec.ts --grep 'two library tabs|concurrent rename receives ordinary409' --workers=1 --retries=0`. Both loopback servers stopped at completion. Browser coverage was desktop Chromium in English, on synthetic local SQLite records. MariaDB, human/device checks, PDF rendering, full A3, integrated security and release acceptance remain open.
+55 -1
View File
@@ -1,7 +1,7 @@
import { expect, test as base, type APIRequestContext, type APIResponse, type Page, type Response, type TestInfo } from '@playwright/test';
import AxeBuilder from '@axe-core/playwright';
import { translations } from '../src/i18n/translations';
import type { CvTheme, CvVariant, CvVariantSummary } from '../src/cvBuilder';
import type { CvTheme, CvVariant, CvVariantSummary, CvVariantVersionInfo } from '../src/cvBuilder';
import { emptyStructuredCv } from '../src/profileCv';
import { readFile } from 'node:fs/promises';
import { createHash } from 'node:crypto';
@@ -416,6 +416,60 @@ test('[P7-04 PRES-C05 C07 C10 W07] keyboard rename duplicate and delete persist
sourceUnchanged: true, frozenUnchanged: true, qualification: 'Actual HTTP rename/duplicate/delete and frozen DTO readback; held duplicate continues the real request. Frozen DTO equality is not archived PDF-byte or restore qualification.' }), contentType: 'application/json' });
});
test('[P7-04 PRES-C05 C10] two library tabs preserve a concurrent name and allow an explicit retry', async ({ page, context, owner }, info) => {
const original = await createVariant(page.request, owner, 'Two-tab source CV');
const variantUrl = `${apiUrl}/cv/variants/${original.id}`;
const versions = async () => (await json<CvVariantVersionInfo[]>(await page.request.get(`${variantUrl}/versions`)))
.map(item => item.version).sort((left, right) => left - right);
const originalVersions = await versions();
const secondTab = await context.newPage();
const label = translations.en.cvDashboardRename;
const firstChoice = 'CV for school applications';
const secondChoice = 'CV for tutoring applications';
const writes: number[] = [];
page.on('request', request => {
if (request.url() === variantUrl && request.method() === 'PUT') writes.push(request.postDataJSON().expectedVersion);
});
const submit = (tab: Page) => tab.getByRole('dialog').getByRole('button', { name: label, exact: true }).click();
const saved = (tab: Page) => tab.waitForResponse(response => response.url() === variantUrl && response.request().method() === 'PUT');
await enter(page, owner);
await enter(secondTab, owner);
await openAction(page, original.name, label);
await page.getByRole('dialog').getByRole('textbox').fill(firstChoice);
await openAction(secondTab, original.name, label);
await secondTab.getByRole('dialog').getByRole('textbox').fill(secondChoice);
const [otherResponse] = await Promise.all([saved(secondTab), submit(secondTab)]);
const other = await json<CvVariant>(otherResponse);
expect(other).toMatchObject({ name: secondChoice, settings: original.settings, version: original.version + 1 });
await expect(card(secondTab, secondChoice)).toBeVisible();
await submit(page);
await expect(page.getByRole('alert').filter({ hasText: translations.en.cvEditorConflict })).toBeVisible();
await expect(card(page, secondChoice)).toBeVisible();
expect(writes).toEqual([]);
expect(await json<CvVariant>(await page.request.get(variantUrl))).toEqual(other);
expect(await versions()).toEqual([...originalVersions, other.version]);
await openAction(page, secondChoice, label);
const retry = page.getByRole('dialog').getByRole('textbox');
await expect(retry).toHaveValue(secondChoice);
await retry.fill(firstChoice);
const [retryResponse] = await Promise.all([saved(page), submit(page)]);
const reviewed = await json<CvVariant>(retryResponse);
expect(writes).toEqual([other.version]);
expect(reviewed).toMatchObject({ name: firstChoice, settings: original.settings, version: other.version + 1 });
expect(await json<CvVariant>(await page.request.get(variantUrl))).toEqual(reviewed);
expect(await versions()).toEqual([...originalVersions, other.version, reviewed.version]);
await secondTab.reload();
await expect(card(secondTab, firstChoice)).toBeVisible();
await info.attach('two-tab-rename-readback', { body: JSON.stringify({
initialVersion: original.version, secondTabVersion: other.version, firstTabPutPreconditions: writes,
finalVersion: reviewed.version, history: await versions(),
}), contentType: 'application/json' });
});
test('[P7-04 PRES-C05 C10] concurrent rename receives ordinary409 and requires owner review before a new save', async ({ page, owner }, info) => {
const sourceBefore = await seedSource(page, owner);
const original = await createVariant(page.request, owner, 'Recorded conflict CV');