Compare commits

..

1 Commits

Author SHA1 Message Date
cesnimda 9795a491e0 Preserve browser navigation through the five design journeys 2026-11-20 14:02:54 +01:00
6 changed files with 52 additions and 80 deletions
@@ -20,15 +20,3 @@ No fresh export build/native browser journey, real API/session/cookie-switch int
Evidence is under [cv-library-lifetime](evidence/cv-library-lifetime/SOURCE_RECEIPTS.json). Normalised source hashes and raw receipt hashes bind this bounded result.
AST graph refresh PASSED on an exact 1,003-file tracked-code snapshot on E: (E:/Storage/Projects/Active/temp docs/jobjakt-local-build/a3-cv-library-source). SOURCE_MANIFEST.json binds files to source commit de2fb452; 10,345 nodes and 36,111 edges. 51 no-symbol warnings retained. Code-only snapshot excludes documentation. Stale generated integration graph: all 2,721 files (97,063,540 bytes) preserved and SHA256-verified on E before replacing its C directory with a junction; no tracked source or evidence removed.
## Concurrent rename in the library · 20 November 2026
On application source `7a2b8a95c146d67bc4584740e4a72740cfc25cbf`, the rename dialog opened with the listed name. After confirmation the library fetched the current CV and used its latest revision and settings to write the requested name. A second editor could rename the same CV while that dialog was open. The subsequent write adopted the second editor’s revision and silently replaced their name. If both editors chose the same name the redundant write also created a revision.
The library now compares the name shown in the dialog with the name returned by the existing detail read. When they differ it shows the latest persisted name and skips the write. If the requested name differs as well, the existing localised conflict message appears. A user can reopen Rename on the current name and explicitly retry. A concurrent change confined to settings still allows a rename, using the latest settings and expected revision. A change after the detail read remains subject to server revision checks.
**Reproduction and verification.** Both added component cases failed on the original source because a PUT was issued. The corrected combined run passed **77 distinct cases in three suites** (47 CV library, 15 CV helpers, 15 session boundary), zero failed or skipped. The conflict case verifies an explicit retry sends exactly one PUT with the current revision and settings. The equal-name case verifies zero PUTs and no conflict alert. TypeScript, scoped ESLint and Git whitespace checks passed. Raw Jest results are in the local `cv-library-rename-verification` evidence directory. SHA-256 values are `1841f3d9e7199d6f8e6deb886d2581a93f36b66273e3083075e5fd2dd2a46ba5` (red) and `8db570ffa120e80dc047db98ad2f3368a586cd35791a164343ee150742312495` (final). An intermediate invocation included a misspelled suite path and exited 1. Its two successful suites and the separate corrected session-suite run overlap the final 77.
**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.
@@ -10,6 +10,8 @@ python -m http.server 4327 --bind 127.0.0.1 --directory docs/ui-modernisation/re
## Compare the experiences
Browser Back and Forward retrace screens and selected opportunities within a concept. For example, open a filtered job, enter its CV workspace and go back twice to return to the filtered results. The ten desktop/phone selected-job journeys exercised this round trip and its forward path on 20 November. Drafts and filters are held in memory for the review session.
| Direction | First interaction | Desktop and phone | Implementation implication |
| --- | --- | --- | --- |
| A · Clear Desk | Scan the activity list and agenda | Compact top navigation, high density, horizontally scrollable on a phone | Existing tracker and agenda owners fit. Check legibility as text size increases. |
@@ -1,5 +1,4 @@
const $ = (s) => document.querySelector(s),
q = new URLSearchParams(location.search);
const $ = (s) => document.querySelector(s);
const screens = [
"home",
"discover",
@@ -14,14 +13,20 @@ const screens = [
"admin",
"onboarding",
];
const selected = (key, allowed, fallback) =>
allowed.includes(q.get(key)) ? q.get(key) : fallback;
function routeFromLocation() {
const query = new URLSearchParams(location.search);
const selected = (key, allowed, fallback) =>
allowed.includes(query.get(key)) ? query.get(key) : fallback;
return {
concept: selected("concept", "ABCDE".split(""), ""),
screen: selected("screen", screens, "home"),
lang: selected("lang", ["en", "nb"], "en"),
theme: selected("theme", ["light", "dark"], "light"),
phone: query.get("mobile") === "1",
};
}
const state = {
concept: selected("concept", "ABCDE".split(""), ""),
screen: selected("screen", screens, "home"),
lang: selected("lang", ["en", "nb"], "en"),
theme: selected("theme", ["light", "dark"], "light"),
phone: q.get("mobile") === "1",
...routeFromLocation(),
calendarView: "agenda",
trackerView: "list",
query: "",
@@ -343,7 +348,11 @@ const records = jobs.map((job, i) => ({
function trackedCount() {
return records.filter((r) => r.stage === "saved").length;
}
let current = records.find((r) => r.id === q.get("job")) || records[0];
function jobFromLocation() {
const id = new URLSearchParams(location.search).get("job");
return records.find((r) => r.id === id) || records[0];
}
let current = jobFromLocation();
const detailText = [
[
"Coordinate community care, support families and work with local healthcare teams.",
@@ -550,7 +559,7 @@ function gallery() {
"",
)}</div><section style="margin-top:45px"><h2>What to compare</h2><p>Try finding a job, saving it, preparing a CV, reviewing a letter and scheduling a follow-up. Switch between desktop and mobile, English and Bokmål, light and dark. These are design prototypes with synthetic data, not provider or production qualification.</p><a href="compare.html">Compare screenshots and tradeoffs</a> · <a href="RESEARCH.md">Research notes</a></section></main>`;
}
function render() {
function render(navigating = false) {
if (!state.concept) {
$("#app").innerHTML = gallery();
return;
@@ -607,20 +616,26 @@ function render() {
.join(
"",
)}</select></label><label><select aria-label="Language" id="lang"><option value="en" ${state.lang === "en" ? "selected" : ""}>English</option><option value="nb" ${state.lang === "nb" ? "selected" : ""}>Norsk</option></select></label><button data-action="theme">${state.theme === "dark" ? "☀ Light" : "☾ Dark"}</button><button data-action="mobile">${state.phone ? t("desktop") : t("mobile")}</button></div><div class="shell"><header class="top"><a class="brand" href="#" data-screen="home"><span>${state.concept === "E" ? "↗" : "j"}</span>${c.name}</a><nav class="nav" aria-label="Primary">${nav.map((s) => link(s, t(s), state.screen === s ? "active" : "")).join("")}</nav><div class="actions">${link("mail", "✉ " + t("mail"))}${link("settings", t("settings"))}<span class="avatar">AO</span></div></header><main class="content" id="main">${(screens[state.screen] || home)()}<details style="margin-top:35px"><summary>${t("help")}</summary><div class="actions" style="margin-top:12px">${["cv", "letter", "mail", "settings", "admin", "onboarding"].map((s) => link(s, t(s))).join("")}</div></details></main>${state.concept === "E" ? `<nav class="journey-nav" aria-label="Journey">${["home", "discover", "applications", "profile", "calendar"].map((s) => link(s, t(s), state.screen === s ? "active" : "")).join("")}</nav>` : ""}</div><footer class="footnote">${t("synthetic")}</footer>`;
history.replaceState(
null,
"",
`?concept=${state.concept}&screen=${state.screen}&lang=${state.lang}&theme=${state.theme}&job=${current.id}${state.phone ? "&mobile=1" : ""}`,
);
const search = `?concept=${state.concept}&screen=${state.screen}&lang=${state.lang}&theme=${state.theme}&job=${current.id}${state.phone ? "&mobile=1" : ""}`;
if (search !== location.search) {
if (navigating) history.pushState(null, "", search);
else history.replaceState(null, "", search);
}
}
window.addEventListener("popstate", () => {
Object.assign(state, routeFromLocation());
current = jobFromLocation();
render();
});
document.addEventListener("click", (event) => {
const a = event.target.closest("[data-screen]");
if (a) {
if (event.button !== 0 || event.metaKey || event.ctrlKey || event.shiftKey || event.altKey) return;
event.preventDefault();
if (a.dataset.job)
current = records.find((r) => r.id === a.dataset.job) || records[0];
state.screen = a.dataset.screen;
render();
render(true);
window.scrollTo(0, 0);
return;
}
@@ -630,7 +645,7 @@ document.addEventListener("click", (event) => {
if (screens.includes(action)) {
if (state.screen === "home" && action === "detail") current = records[0];
state.screen = action;
render();
render(true);
window.scrollTo(0, 0);
} else if (action === "theme") {
state.theme = state.theme === "light" ? "dark" : "light";
@@ -659,7 +674,7 @@ document.addEventListener("click", (event) => {
current.followup = true;
state.calendarView = "agenda";
state.screen = "calendar";
render();
render(true);
toast(
state.lang === "nb"
? "Oppfølging lagt til i prototypen"
@@ -706,7 +721,7 @@ document.addEventListener("change", (e) => {
}
if (["concept", "screen", "lang"].includes(e.target.id)) {
state[e.target.id] = e.target.value;
render();
render(e.target.id !== "lang");
}
if (e.target.id === "settingLanguage") {
state.lang = e.target.value;
@@ -111,8 +111,18 @@ async function verify() {
await page.locator("#summary").inputValue(),
"Field electrician CV.",
);
await page.goBack();
assert.equal(new URL(page.url()).searchParams.get("screen"), "detail");
assert.equal(await page.locator("main h1").innerText(), "Front-of-house supervisor");
await page.goBack();
assert.equal(await page.locator("#country").inputValue(), "Denmark");
assert.equal(await page.locator("#search").inputValue(), "supervisor");
await page.goForward();
assert.equal(await page.locator("main h1").innerText(), "Front-of-house supervisor");
await page.goForward();
assert.match(await page.locator("main .heading").innerText(), /Harbour House/);
assert.deepEqual(errors, []);
results.push({ concept, width, lang, theme, passed: true });
results.push({ concept, width, lang, theme, historyRoundTrip: true, passed: true });
await page.close();
}
}
@@ -509,41 +509,6 @@ test('a rename conflict keeps the original library entry and never retries the w
expect(mockedApi.delete).not.toHaveBeenCalled();
});
test.each(['My proposed name', 'Name from another editor'])(
'a concurrent rename preserves the saved title before applying "%s"', async proposedName => {
const latest = { ...existingCv, name: 'Name from another editor', version: 7, settings: emptyCvVariantSettings('clean') };
mockedApi.get.mockImplementation(async url => ({ data: url === '/cv/variants' ? [existingCv]
: url === '/cv/variants/1' ? latest : themes }) as any);
mockedApi.put.mockResolvedValue({ data: { ...latest, name: proposedName, version: 8 } } as any);
renderPage();
await screen.findByText(existingCv.name);
await selectAction('Rename');
fireEvent.change(await screen.findByRole('textbox'), { target: { value: proposedName } });
fireEvent.click(screen.getByRole('button', { name: 'Rename' }));
await waitFor(() => expect(mockedApi.get).toHaveBeenCalledWith('/cv/variants/1'));
await waitFor(() => expect(screen.getByRole('link')).toHaveAttribute('aria-disabled', 'false'));
expect(mockedApi.put).not.toHaveBeenCalled();
expect(screen.getByRole('link', { name: 'Open Name from another editor' })).toBeInTheDocument();
if (proposedName === latest.name) {
expect(screen.queryByText('CV changed elsewhere')).not.toBeInTheDocument();
return;
}
expect(screen.getByText('CV changed elsewhere')).toBeInTheDocument();
fireEvent.click(screen.getByRole('button', { name: 'Actions for Name from another editor' }));
fireEvent.click(await screen.findByRole('menuitem', { name: 'Rename' }));
const retry = await screen.findByRole('textbox');
expect(retry).toHaveValue(latest.name);
fireEvent.change(retry, { target: { value: proposedName } });
fireEvent.click(screen.getByRole('button', { name: 'Rename' }));
expect(await screen.findByRole('link', { name: 'Open My proposed name' })).toBeInTheDocument();
expect(mockedApi.put).toHaveBeenCalledTimes(1);
expect(mockedApi.put).toHaveBeenCalledWith('/cv/variants/1', {
name: proposedName, settings: latest.settings, source: 'manual', expectedVersion: latest.version,
});
},
);
test('cancelling deletion returns focus to the surviving CV action control without removing the CV', async () => {
mockedApi.get.mockImplementation(async (url) => ({ data: url === '/cv/variants' ? [existingCv] : themes }) as any);
renderPage();
+4 -12
View File
@@ -173,23 +173,15 @@ export default function CvBuilderPage() {
if (!active) return;
const current = variants.find((item) => item.id === id);
try {
const input = await promptForValue({ key: "cvDashboardRenameMessage" }, current?.name ?? "", { title: { key: "cvDashboardRenameCv" }, confirmLabel: { key: "cvDashboardRename" } });
const nextName = input?.trim();
if (!active() || !nextName || nextName === current?.name) return;
const nextName = await promptForValue({ key: "cvDashboardRenameMessage" }, current?.name ?? "", { title: { key: "cvDashboardRenameCv" }, confirmLabel: { key: "cvDashboardRename" } });
if (!active() || !nextName?.trim() || nextName.trim() === current?.name) return;
setPending(true);
const variant = await cvBuilderApi.get(id);
if (!active()) return;
const renamedElsewhere = variant.name !== current?.name;
const updated = renamedElsewhere ? variant : await cvBuilderApi.save(id, {
name: nextName, settings: variant.settings, source: "manual", expectedVersion: variant.version,
});
const updated = await cvBuilderApi.save(id, { name: nextName.trim(), settings: variant.settings, source: "manual", expectedVersion: variant.version });
if (!active()) return;
setVariants((items) => items.map((item) => item.id === id ? { ...item, name: updated.name, updatedAtUtc: updated.updatedAtUtc, version: updated.version } : item));
if (renamedElsewhere && updated.name !== nextName) {
setActionError({ key: "cvEditorConflict" });
} else {
toast(localeRef.current("cvDashboardRenamed"), "success");
}
toast(localeRef.current("cvDashboardRenamed"), "success");
} catch (err) { if (active()) setActionError({ error: err, key: "cvDashboardRenameFailed" }); }
finally { finishAction(active); }
};