A one-of-a-kind resume builder that keeps your privacy in mind. Completely secure, customizable, portable, open-source and free forever. Try it out today!
TypeScript agent-skillsaidsh-pluginhacktoberfestjavascriptmcp-serverreactresume-builderself-hostedtypescript
fix: preserve unfinished document tags and failed rename drafts (#3867)
Amruth Pillaic29d8b231d3a
diff --git a/apps/mobile/scripts/experience.test.mjs b/apps/mobile/scripts/experience.test.mjsindex 26e3bd5fb..fde1906aa 100644--- a/apps/mobile/scripts/experience.test.mjs+++ b/apps/mobile/scripts/experience.test.mjs@@ -16,11 +16,15 @@ let cursor = 0;const react = {createElement: element,useCallback: (fn) => fn,+ useImperativeHandle(ref, make) {+ if (ref) ref.current = make();+ },useEffect() {},useState(initial) {const index = cursor++;if (!(index in hooks)) hooks[index] = typeof initial === "function" ? initial() : initial;- return [hooks[index], (value) => (hooks[index] = typeof value === "function" ? value(hooks[index]) : value)];+ const owner = hooks;+ return [owner[index], (value) => (owner[index] = typeof value === "function" ? value(owner[index]) : value)];},useRef(initial) {const [value] = react.useState(() => ({ current: initial }));@@ -2586,13 +2590,37 @@ const { DocumentMenu: BuilderDocumentMenu } = load("features/document-menu/index"@/shell/key-commands": { useKeyCommands() {} },"@/ui": { ...ui, IconButton: "IconButton", Sheet: "Sheet" },});+const { ChipInput: NativeTagInput } = load("ui/fields.tsx", {+ "./theme": { useTheme: () => theme },+ "./icon": {},+ "./layout": {},+ "./motion": {},+ "./overlays": {},+ "./switch": {},+ "./text": {},+ "@reactive-resume/utils/string": {},+});+let tagInputHooks = [];const menuView = () => render(BuilderDocumentMenu, { id: "menu-tags" });+const menuTagInput = () => {+ const props = control(menuView(), "Tags");+ const parentHooks = hooks;+ hooks = tagInputHooks;+ try {+ const tree = render(NativeTagInput, props);+ tagInputHooks = hooks;+ return tree;+ } finally {+ hooks = parentHooks;+ }+};const tagsAction = () =>nodes(menuView()).find((node) => node.type === "ListRow" && node.props.title === "Tags…").props;control(menuView(), "Document options").onPress();assert.equal(tagsAction().disabled, false);tagsAction().onPress();-control(menuView(), "Tags").onChange(["base", "portfolio"]);+control(menuTagInput(), "Tags").onChangeText("portfolio");+menuTagInput();control(menuView(), "Save").onPress();await settle();assert.deepEqual(@@ -2602,8 +2630,14 @@ assert.deepEqual(assert.equal(tagSaves.at(-1).data.basics.headline, "Portfolio designer");control(menuView(), "Document options").onPress();tagsAction().onPress();-control(menuView(), "Tags").onChange(["x".repeat(41)]);+tagInputHooks = [];+control(menuTagInput(), "Tags").onChangeText("x".repeat(41));+menuTagInput();+const beforeInvalidSave = tagSaves.length;+control(menuView(), "Save").onPress();+await settle();assert.equal(control(menuView(), "Save").disabled, true);+assert.equal(tagSaves.length, beforeInvalidSave, "unfinished overlong tag cannot reach the draft");control(menuView(), "Tags").onChange(Array.from({ length: 21 }, (_, index) => `tag-${index}`));assert.equal(control(menuView(), "Save").disabled, true);state.document.isLocked = true;diff --git a/apps/mobile/src/features/document-menu/index.tsx b/apps/mobile/src/features/document-menu/index.tsxindex 8ec54d47f..4b7f95e7d 100644--- a/apps/mobile/src/features/document-menu/index.tsx+++ b/apps/mobile/src/features/document-menu/index.tsx@@ -38,6 +38,7 @@ export function DocumentMenu({ id, inChrome = false }: DocumentMenuProps) {const [panel, setPanel] = useState<"menu" | "rename" | "duplicate" | "tags" | "notes" | "details" | null>(null);const [name, setName] = useState("");const [tags, setTags] = useState<string[]>([]);+ const commitTags = useRef<(() => string[]) | null>(null);const [slug, setSlug] = useState("");const helpRequested = useRef(false);const menuTrigger = useRef<ComponentRef<typeof Pressable>>(null);@@ -258,23 +259,26 @@ export function DocumentMenu({ id, inChrome = false }: DocumentMenuProps) {{panel === "tags" && (<><View pointerEvents={operations.busy || resume.isLocked ? "none" : "auto"}>- <ChipInput label={t`Tags`} values={tags} onChange={setTags} />+ <ChipInput commitRef={commitTags} label={t`Tags`} values={tags} onChange={setTags} /></View><Text variant="caption" color="ink3">{t`Up to 20 tags per document, 40 characters per tag.`}</Text><Buttonlabel={t`Save`}loading={operations.busy}disabled={resume.isLocked || tags.length > 20 || tags.some((tag) => !tag.trim() || tag.length > 40)}- onPress={() =>+ onPress={() => {+ if (operations.busy || resume.isLocked) return;+ const next = commitTags.current?.() ?? tags;+ if (next.length > 20 || next.some((tag) => !tag.trim() || tag.length > 40)) return;void run(async () => {await flushResume(id);useResumeStore.getState().updateDocument((value) => {if (value.id !== id) return;- value.tags = tags;+ value.tags = next;});await flushResume(id);- })- }+ });+ }}/></>)}diff --git a/apps/mobile/src/features/documents/document-sheets.tsx b/apps/mobile/src/features/documents/document-sheets.tsxindex 839f62d88..1f78d37a1 100644--- a/apps/mobile/src/features/documents/document-sheets.tsx+++ b/apps/mobile/src/features/documents/document-sheets.tsx@@ -2,7 +2,7 @@ import type { DocumentSummary } from "./filter";import { useLingui } from "@lingui/react/macro";import { useQuery } from "@tanstack/react-query";import { useRouter } from "expo-router";-import { useState } from "react";+import { useRef, useState } from "react";import { View } from "react-native";import { changedTags, documentRef, sharedTags } from "./filter";import { useNewDocuments } from "./new-documents";@@ -36,6 +36,7 @@ export function DocumentSheets({ value, onClose, onChange, onSelect }: DocumentSconst [name, setName] = useState(value.kind === "duplicate" ? value.name : (first?.name ?? ""));const shared = sharedTags(value.documents);const [tags, setTags] = useState(shared);+ const commitTags = useRef<(() => string[]) | null>(null);const [addingJob, setAddingJob] = useState(false);const options = orpc.applications.listSummary.queryOptions({ input: {} });const applications = useQuery({@@ -256,7 +257,7 @@ export function DocumentSheets({ value, onClose, onChange, onSelect }: DocumentS<><Text color="ink2">{t`Shows shared tags. Add or remove tags without changing each document's other tags.`}</Text><View pointerEvents={operations.busy ? "none" : "auto"}>- <ChipInput label={t`Tags`} values={tags} onChange={setTags} />+ <ChipInput commitRef={commitTags} label={t`Tags`} values={tags} onChange={setTags} /></View><Buttonlabel={t`Save`}@@ -267,16 +268,24 @@ export function DocumentSheets({ value, onClose, onChange, onSelect }: DocumentStags.some((tag) => tag.length > 40) ||targets.some((document) => changedTags(document, shared, tags).length > 20)}- onPress={() =>+ onPress={() => {+ if (operations.busy || !targets.length) return;+ const next = commitTags.current?.() ?? tags;+ if (+ next.length > 20 ||+ next.some((tag) => tag.length > 40) ||+ targets.some((document) => changedTags(document, shared, next).length > 20)+ )+ return;void execute(() =>operations.batch(value.documents,(document) =>- client.documents.setTags({ ...documentRef(document), tags: changedTags(document, shared, tags) }),+ client.documents.setTags({ ...documentRef(document), tags: changedTags(document, shared, next) }),{ applies: (document) => !document.isLocked },),- )- }+ );+ }}/><Text variant="caption" color="ink3">{t`Up to 20 tags per document, 40 characters per tag.`}</Text></>diff --git a/apps/mobile/src/ui/fields.tsx b/apps/mobile/src/ui/fields.tsxindex ce39c74ed..e0f855985 100644--- a/apps/mobile/src/ui/fields.tsx+++ b/apps/mobile/src/ui/fields.tsx@@ -2,7 +2,7 @@ import type { IconName } from "./icon";import type { ComponentRef, ReactNode, Ref } from "react";import type { TextInputProps } from "react-native";import { useLingui } from "@lingui/react/macro";-import { useEffect, useRef, useState } from "react";+import { useEffect, useImperativeHandle, useRef, useState } from "react";import { I18nManager, Platform, Pressable, TextInput, View } from "react-native";import Animated, { useAnimatedStyle, useSharedValue, withTiming } from "react-native-reanimated";import { filterOptions } from "@reactive-resume/utils/string";@@ -512,6 +512,8 @@ export function Chip({ label, selected, onPress, icon, onRemove }: ChipProps) {}export type ChipInputProps = {+ /** Explicit saves include unfinished text; ordinary Return/comma entry stays unchanged. */+ commitRef?: Ref<() => string[]>;label: string;values: string[];onChange: (values: string[]) => void;@@ -533,6 +535,7 @@ export function ChipInput({suggestions,helper,suggestionsLabel,+ commitRef,}: ChipInputProps) {const { space } = useTheme();const [draft, setDraft] = useState("");@@ -540,7 +543,13 @@ export function ChipInput({const next = [...values];for (const item of items.map((value) => value.trim())) if (item && !next.includes(item)) next.push(item);if (next.length !== values.length) onChange(next);+ return next;};+ useImperativeHandle(commitRef, () => () => {+ const next = add([draft]);+ setDraft("");+ return next;+ });const query = draft.trim().toLocaleLowerCase();const offered = (suggestions ?? []).filter((suggestion) => !values.includes(suggestion) && suggestion.toLocaleLowerCase().includes(query),diff --git a/apps/web/src/components/input/chip-input.test.tsx b/apps/web/src/components/input/chip-input.test.tsxindex 0118c839d..a4c08c2da 100644--- a/apps/web/src/components/input/chip-input.test.tsx+++ b/apps/web/src/components/input/chip-input.test.tsx@@ -3,6 +3,7 @@ import { cleanup, fireEvent, render, screen, waitFor } from "@testing-library/reimport { afterEach, beforeAll, expect, it, vi } from "vite-plus/test";import { i18n } from "@lingui/core";import { I18nProvider } from "@lingui/react";+import { createRef } from "react";import { ChipInput } from "./chip-input";import { loadLocale } from "@/libs/locale";@@ -97,3 +98,27 @@ it("announces keyword drags in German when German is the UI language", async ());await loadLocale("en-US");});++it("explicit Save commits an edited tag and preserves duplicate and Escape behavior", () => {+ const commitRef = createRef<() => string[]>();+ const saved = vi.fn();+ render(+ <I18nProvider i18n={i18n}>+ <ChipInput defaultValue={["Alpha", "Beta"]} commitRef={commitRef} />+ <button onClick={() => saved(commitRef.current?.())}>Save tags</button>+ </I18nProvider>,+ );+ fireEvent.click(screen.getByRole("button", { name: "Edit Alpha" }));+ fireEvent.change(screen.getByRole("textbox"), { target: { value: " Revised " } });+ fireEvent.click(screen.getByRole("button", { name: "Save tags" }));+ expect(saved).toHaveBeenLastCalledWith(["Revised", "Beta"]);+ fireEvent.click(screen.getByRole("button", { name: "Edit Revised" }));+ fireEvent.change(screen.getByRole("textbox"), { target: { value: "Beta" } });+ fireEvent.click(screen.getByRole("button", { name: "Save tags" }));+ expect(saved).toHaveBeenLastCalledWith(["Revised", "Beta"]);+ fireEvent.click(screen.getByRole("button", { name: "Edit Revised" }));+ fireEvent.change(screen.getByRole("textbox"), { target: { value: "Cancelled" } });+ fireEvent.keyDown(screen.getByRole("textbox"), { key: "Escape" });+ fireEvent.click(screen.getByRole("button", { name: "Save tags" }));+ expect(saved).toHaveBeenLastCalledWith(["Revised", "Beta"]);+});diff --git a/apps/web/src/components/input/chip-input.tsx b/apps/web/src/components/input/chip-input.tsxindex 2826b061a..bb5f8378b 100644--- a/apps/web/src/components/input/chip-input.tsx+++ b/apps/web/src/components/input/chip-input.tsx@@ -155,6 +155,8 @@ type Props = Omit<React.ComponentProps<"div">, "value" | "onChange"> & {defaultValue?: string[];onChange?: (value: string[]) => void;allowCommas?: boolean;+ /** Explicit document saves include unfinished text without changing blur/autosave behavior. */+ commitRef?: React.Ref<() => string[]>;/** The empty field's hint; keywords by default. Document tags say "Add a tag…". */placeholder?: string;};@@ -165,6 +167,7 @@ export function ChipInput({onChange,className,allowCommas = false,+ commitRef,placeholder,id: idProp,"aria-describedby": ariaDescribedByProp,@@ -196,23 +199,33 @@ export function ChipInput({const trimmed = chip.trim();return trimmed ? [trimmed] : [];});- if (nextValues.length === 0) return;+ if (nextValues.length === 0) return chips;- setChips([...new Set([...chips, ...nextValues])]);+ const next = [...new Set([...chips, ...nextValues])];+ setChips(next);+ return next;};const updateChip = (index: number, newValue: string) => {const trimmed = newValue.trim();- if (!trimmed || index < 0 || index >= chips.length) return;+ if (!trimmed || index < 0 || index >= chips.length) return chips;const existingIndex = chips.findIndex((c, i) => c === trimmed && i !== index);- if (existingIndex !== -1) return;+ if (existingIndex !== -1) return chips;const newChips = [...chips];newChips[index] = trimmed;setChips(newChips);+ return newChips;};+ React.useImperativeHandle(commitRef, () => () => {+ const next = editingIndex === null ? addChips([input]) : updateChip(editingIndex, input);+ setInput("");+ setEditingIndex(null);+ return next;+ });+const removeChip = (index: number) => {if (index < 0 || index >= chips.length) return;setChips(chips.slice(0, index).concat(chips.slice(index + 1)));diff --git a/apps/web/src/dialogs/resume/index.tsx b/apps/web/src/dialogs/resume/index.tsxindex 667166d40..19d5aef4e 100644--- a/apps/web/src/dialogs/resume/index.tsx+++ b/apps/web/src/dialogs/resume/index.tsx@@ -3,6 +3,7 @@ import { t } from "@lingui/core/macro";import { Trans } from "@lingui/react/macro";import { useMutation } from "@tanstack/react-query";import { useNavigate } from "@tanstack/react-router";+import { useRef } from "react";import z from "zod";import { Button } from "@reactive-resume/ui/components/button";import {@@ -37,6 +38,7 @@ type ResumeDialogProps = {export function ResumeDialog({ mode, data }: ResumeDialogProps) {const isUpdate = mode === "update";+ const commitTags = useRef<(() => string[]) | null>(null);const navigate = useNavigate();const closeDialog = useDialogStore((state) => state.closeDialog);@@ -110,6 +112,7 @@ export function ResumeDialog({ mode, data }: ResumeDialogProps) {onSubmit={(event) => {event.preventDefault();event.stopPropagation();+ commitTags.current?.();void form.handleSubmit();}}>@@ -148,6 +151,7 @@ export function ResumeDialog({ mode, data }: ResumeDialogProps) {<FormControlrender={<ChipInput+ commitRef={commitTags}value={field.state.value}onChange={(value) => {field.handleChange(value);diff --git a/apps/web/src/features/documents/document-actions.tsx b/apps/web/src/features/documents/document-actions.tsxindex 384baf9fc..36666447c 100644--- a/apps/web/src/features/documents/document-actions.tsx+++ b/apps/web/src/features/documents/document-actions.tsx@@ -5,7 +5,7 @@ import { plural, t } from "@lingui/core/macro";import { Plural, Trans } from "@lingui/react/macro";import { useMutation, useQuery, useQueryClient } from "@tanstack/react-query";import { useNavigate } from "@tanstack/react-router";-import { lazy, Suspense, useState } from "react";+import { lazy, Suspense, useRef, useState } from "react";import { useCopyToClipboard } from "usehooks-ts";import { publicResumeUrl } from "@reactive-resume/resume/sharing";import { Button } from "@reactive-resume/ui/components/button";@@ -63,7 +63,6 @@ export function useDocumentActions() {const rename = useMutation(orpc.documents.rename.mutationOptions({onSettled: refresh,- onError: (error) => toastError(error, t`Couldn't rename the document. Try again.`),}),);const setLocked = useMutation(orpc.documents.setLocked.mutationOptions({ onSettled: refresh }));@@ -79,7 +78,7 @@ export function useDocumentActions() {rename: (document: DocumentSummary, name: string) => {const trimmed = name.trim();if (!trimmed || trimmed === document.name) return;- rename.mutate({ ...ref(document), name: trimmed });+ return rename.mutateAsync({ ...ref(document), name: trimmed });},duplicate: async (document: DocumentSummary) => {@@ -511,12 +510,13 @@ export function TagsDialog({ documents: requested, onClose }: TagsDialogProps) {// Closing keeps the documents' tags on screen until the dialog has faded out.const [documents, onDocumentsOpenChangeComplete] = useClosingValue(requested);const [tags, setTags] = useState<string[] | null>(null);+ const commitTags = useRef<(() => string[]) | null>(null);const setDocumentTags = useMutation(orpc.documents.setTags.mutationOptions());const shared = documents ? sharedTags(documents) : [];const save = async () => {if (!documents) return;- const next = tags ?? shared;+ const next = commitTags.current?.() ?? tags ?? shared;const removed = shared.filter((tag) => !next.includes(tag));const added = next.filter((tag) => !shared.includes(tag));const results = await Promise.allSettled(@@ -569,7 +569,7 @@ export function TagsDialog({ documents: requested, onClose }: TagsDialogProps) {)}</DialogDescription></DialogHeader>- <ChipInput value={tags ?? shared} onChange={setTags} placeholder={t`Add a tag…`} />+ <ChipInput commitRef={commitTags} value={tags ?? shared} onChange={setTags} placeholder={t`Add a tag…`} /><DialogFooter><Button onClick={() => void save()} disabled={setDocumentTags.isPending}><Trans>Save tags</Trans>diff --git a/apps/web/src/routes/builder/$resumeId/-components/document-menu.tsx b/apps/web/src/routes/builder/$resumeId/-components/document-menu.tsxindex 213b7f195..eb1cf35ad 100644--- a/apps/web/src/routes/builder/$resumeId/-components/document-menu.tsx+++ b/apps/web/src/routes/builder/$resumeId/-components/document-menu.tsx@@ -123,6 +123,7 @@ type BuilderTagsDialogProps = {function BuilderTagsDialog({ tags: current, locked, onSave, onClose }: BuilderTagsDialogProps) {const [tags, setTags] = useState(current);+ const commitTags = useRef<(() => string[]) | null>(null);const save = useMutation({ mutationFn: onSave });const invalid = tags.length > 20 || tags.some((tag) => !tag.trim() || tag.length > 40);return (@@ -139,15 +140,17 @@ function BuilderTagsDialog({ tags: current, locked, onSave, onClose }: BuilderTa<formonSubmit={(event) => {event.preventDefault();- if (locked || save.isPending || invalid) return;- save.mutate(tags, {+ if (locked || save.isPending) return;+ const next = commitTags.current?.() ?? tags;+ if (next.length > 20 || next.some((tag) => !tag.trim() || tag.length > 40)) return;+ save.mutate(next, {onSuccess: onClose,onError: (error) => toast.add({ type: "error", description: getResumeErrorMessage(error) }),});}}><fieldset disabled={locked || save.isPending} className="grid gap-3">- <ChipInput value={tags} onChange={setTags} placeholder={t`Add a tag…`} />+ <ChipInput commitRef={commitTags} value={tags} onChange={setTags} placeholder={t`Add a tag…`} /><p className="text-xs text-ink-3"><Trans>Up to 20 tags per document, 40 characters per tag.</Trans></p>diff --git a/docs/guides/organizing-with-tags.mdx b/docs/guides/organizing-with-tags.mdxindex fc80d6470..e9a7d2934 100644--- a/docs/guides/organizing-with-tags.mdx+++ b/docs/guides/organizing-with-tags.mdx@@ -23,7 +23,7 @@ Tags are short labels you add to documents, such as the kind of role, the industSelect the pencil next to a tag to change it, or the **×** to remove it. You can drag tags to reorder them.</Step><Step title="Save">- Select **Save tags**. Closing the dialog without saving discards your changes.+ Select **Save tags** (**Save** on mobile). This also includes the tag you are still typing or editing; you do not need to press Enter first. If saving fails, your tags stay available to retry. Closing the dialog without saving discards your changes.</Step></Steps>diff --git a/tests/e2e/specs/document-duplicate.spec.ts b/tests/e2e/specs/document-duplicate.spec.tsindex 49bf5dcc8..d1d728a0a 100644--- a/tests/e2e/specs/document-duplicate.spec.ts+++ b/tests/e2e/specs/document-duplicate.spec.ts@@ -71,12 +71,15 @@ for (const kind of ["resume", "letter"] as const) {await expect(input).toHaveValue(`${sourceName.trim()} 2`);const copyName = "Fictional renamed portfolio ".repeat(4).slice(0, 100).trim();await input.fill(copyName);+ if (kind === "resume") await dialog.getByRole("textbox", { name: "Tags", exact: true }).fill("unfinished copy tag");await dialog.getByRole("button", { name: "Duplicate", exact: true }).click();await expect(page).toHaveTitle(`${copyName} | Reactive Resume`);const copyId = page.url().split("/").at(-1);if (!copyId) throw new Error("Duplicate editor has no document ID");expect(copyId).not.toBe(id);- expect((await read(page.request, kind, copyId)).name).toBe(copyName);+ const copy = await read(page.request, kind, copyId);+ expect(copy.name).toBe(copyName);+ if (kind === "resume") expect(copy.tags).toEqual(["portfolio", "unfinished copy tag"]);expect((await read(page.request, kind, id)).name).toBe(sourceName.trim());});diff --git a/tests/e2e/specs/document-title.spec.ts b/tests/e2e/specs/document-title.spec.tsindex 5713b7e45..74403843a 100644--- a/tests/e2e/specs/document-title.spec.ts+++ b/tests/e2e/specs/document-title.spec.ts@@ -40,8 +40,6 @@ test("builder rename stays inline and tags persist without changing the resume bawait page.getByRole("menuitem", { name: "Tags…", exact: true }).click();const tags = page.getByRole("dialog", { name: "Tags", exact: true });await tags.getByPlaceholder("Add a tag…", { exact: true }).fill("portfolio");- await tags.getByPlaceholder("Add a tag…", { exact: true }).press("Enter");- await expect(tags.getByText("portfolio", { exact: true })).toBeVisible();await tags.screenshot({ path: testInfo.outputPath("builder-tags.png"), animations: "disabled" });await tags.getByRole("button", { name: "Save tags", exact: true }).click();await expect(tags).not.toBeVisible();@@ -206,3 +204,54 @@ test("resume metadata timeout cancels the request and releases stream updates anif (!page.isClosed()) await page.unroute(updateUrl);}});++test("bulk library Save includes unfinished tags and retries partial failures without changing locked or unique tags", async ({+ authPage: page,+}) => {+ const ids: string[] = [];+ for (const name of ["Alpha", "Beta", "Locked"]) {+ const created = await page.request.post("/api/openapi/resumes", {+ data: { name, tags: ["base", name.toLowerCase()] },+ });+ await expect(created).toBeOK();+ ids.push(await created.json());+ }+ const locked = await page.request.post("/api/rpc/documents/setLocked", {+ data: { json: { type: "resume", id: ids[2], isLocked: true } },+ });+ await expect(locked).toBeOK();+ await page.goto("/dashboard?view=list");+ await page.getByRole("checkbox", { name: "Select this page", exact: true }).check();+ await page.getByRole("toolbar").getByRole("button", { name: "Tags…", exact: true }).click();+ const dialog = page.getByRole("dialog", { name: "Tags for 3 documents", exact: true });+ await dialog.getByPlaceholder("Add a tag…", { exact: true }).fill(" portfolio ");+ // Another session locks Beta after this dialog captured its selection: only that write must fail.+ const changed = await page.request.post("/api/rpc/documents/setLocked", {+ data: { json: { type: "resume", id: ids[1], isLocked: true } },+ });+ await expect(changed).toBeOK();+ await dialog.getByRole("button", { name: "Save tags", exact: true }).click();+ await expect(page.locator('[data-slot="toast"]')).toBeVisible();+ await expect(dialog).toBeVisible();+ await expect(dialog.getByText("portfolio", { exact: true })).toBeVisible();+ const partial = await page.request.get(`/api/openapi/resumes/${ids[0]}`);+ await expect(partial).toBeOK();+ expect((await partial.json()).tags).toEqual(["base", "alpha", "portfolio"]);+ const unlocked = await page.request.post("/api/rpc/documents/setLocked", {+ data: { json: { type: "resume", id: ids[1], isLocked: false } },+ });+ await expect(unlocked).toBeOK();+ await dialog.getByRole("button", { name: "Save tags", exact: true }).click();+ await expect(dialog).not.toBeVisible();+ for (const [index, name] of ["alpha", "beta", "locked"].entries()) {+ const read = await page.request.get(`/api/openapi/resumes/${ids[index]}`);+ await expect(read).toBeOK();+ expect((await read.json()).tags).toEqual(index === 2 ? ["base", name] : ["base", name, "portfolio"]);+ }+ await page.reload();+ await page.getByRole("button", { name: "Options for Alpha", exact: true }).click();+ await page.getByRole("menuitem", { name: "Tags…", exact: true }).click();+ await expect(+ page.getByRole("dialog", { name: "Tags", exact: true }).getByText("portfolio", { exact: true }),+ ).toBeVisible();+});diff --git a/tests/e2e/specs/private-rename-integration.spec.ts b/tests/e2e/specs/private-rename-integration.spec.tsindex 4183e68fb..94178a9a9 100644--- a/tests/e2e/specs/private-rename-integration.spec.ts+++ b/tests/e2e/specs/private-rename-integration.spec.ts@@ -147,3 +147,36 @@ async function renameInBuilder(page: Page, name: string) {await input.press("Enter");await expect(input).not.toBeVisible();}++test("failed library rename retains one draft and retries through protected HTTP and SQL", async ({+ authPage: page,+}) => {+ const pool = new Pool({ connectionString: process.env.DATABASE_URL });+ try {+ const created = await page.request.post("/api/openapi/resumes", { data: { name: "Retry original", tags: [] } });+ await expect(created).toBeOK();+ const id: string = await created.json();+ await page.goto("/dashboard?view=list");+ await page.getByRole("button", { name: "Options for Retry original", exact: true }).click();+ await page.getByRole("menuitem", { name: "Rename", exact: true }).click();+ const input = page.getByRole("textbox", { name: "Name", exact: true });+ await input.fill("Retained rename draft");+ const url = "**/api/rpc/documents/rename";+ await page.route(url, (route) => route.abort("failed"));+ await input.press("Enter");+ await expect(input).toHaveValue("Retained rename draft");+ await expect(page.locator('[data-slot="toast"]')).toHaveCount(1);+ await expect(input).toBeEnabled();+ expect((await pool.query("select name from resume where id=$1", [id])).rows[0].name).toBe("Retry original");+ await page.unroute(url);+ const saved = page.waitForResponse((response) => response.url().endsWith("/documents/rename") && response.ok());+ await input.press("Enter");+ await saved;+ await expect(input).not.toBeVisible();+ expect((await pool.query("select name from resume where id=$1", [id])).rows[0].name).toBe("Retained rename draft");+ await page.reload();+ await expect(page.getByRole("link", { name: "Retained rename draft", exact: true })).toBeVisible();+ } finally {+ await pool.end();+ }+});