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
test(applications): cover reply recovery and reminder transitions
Amruth Pillai9a14bde997ad
diff --git a/apps/mobile/scripts/workspace-reply-stage.test.mjs b/apps/mobile/scripts/workspace-reply-stage.test.mjsindex 5c585f2b4..e0c0f4d62 100644--- a/apps/mobile/scripts/workspace-reply-stage.test.mjs+++ b/apps/mobile/scripts/workspace-reply-stage.test.mjs@@ -60,6 +60,8 @@ function harness({ lifetime = 30 } = {}) {copy: async () => true,copied: [],logs: [],+ logReply: async () => undefined,+ invalidations: 0,effects: [],clearedReminders: [],};@@ -81,6 +83,14 @@ function harness({ lifetime = 30 } = {}) {activity: [{ id: "e1", type: "stage", at: "2026-11-01T12:00:00.000Z", writeSequence: 1 }],};const jsx = (type, props) => ({ type, props });+ const hooks = [];+ let cursor = 0;+ let renderingReply = false;+ const hook = (initial) => {+ if (!renderingReply) return initial();+ const index = cursor++;+ return (hooks[index] ??= initial());+ };const messages = load(MOBILE + "/src/features/workspace/tabs/messages.tsx",{@@ -91,10 +101,31 @@ function harness({ lifetime = 30 } = {}) {"expo-clipboard": { setStringAsync: (text) => (env.copied.push(text), env.copy()) },"expo-router": { useLocalSearchParams: () => ({}), useRouter: () => ({}) },react: {- useState: (init) => [typeof init === "function" ? init() : init, () => {}],- useRef: (value) => ({ current: value }),- useEffect: (effect) => env.effects.push(effect),- useEffectEvent: (effect) => effect,+ useState: (init) => {+ const cell = hook(() => ({ value: typeof init === "function" ? init() : init }));+ return [+ cell.value,+ (value) => {+ cell.value = typeof value === "function" ? value(cell.value) : value;+ },+ ];+ },+ useRef: (value) => hook(() => ({ current: value })),+ useEffect: (effect, dependencies) => {+ const cell = hook(() => ({}));+ if (!cell.dependencies || dependencies.some((value, index) => !Object.is(value, cell.dependencies[index]))) {+ cell.dependencies = dependencies;+ env.effects.push(() => {+ cell.cleanup?.();+ cell.cleanup = effect();+ });+ }+ },+ useEffectEvent: (effect) => {+ const cell = hook(() => ({ current: effect }));+ cell.current = effect;+ return (cell.event ??= (...args) => cell.current(...args));+ },useSyncExternalStore: (_subscribe, get) => get(),},"react/jsx-runtime": { jsx, jsxs: jsx, Fragment: "Fragment" },@@ -118,7 +149,12 @@ function harness({ lifetime = 30 } = {}) {"../state": state,"@/api/client": {client: {- applications: { logReply: async (...args) => env.logs.push(args) },+ applications: {+ logReply: async (...args) => {+ env.logs.push(args);+ return env.logReply(...args);+ },+ },career: {undoReply: (input) => {env.undoCalls += 1;@@ -141,7 +177,9 @@ function harness({ lifetime = 30 } = {}) {"@/features/applications/next-step": { describeNextStep: () => ({ title: "x" }), getNextStep: () => null },"@/features/applications/queries": {stageScope: () => "srv:" + env.account,- useInvalidateApplications: () => async () => {},+ useInvalidateApplications: () => async () => {+ env.invalidations++;+ },},"@/features/applications/stage-actions": {listedApplication: () => listedRow,@@ -188,7 +226,21 @@ function harness({ lifetime = 30 } = {}) {followUpNote: null,updatedAt: new Date(0),};- const replyTree = () => messages.ReplyCard({ reply, application, readOnly: false });+ const flushEffects = () => {+ for (const effect of env.effects.splice(0)) effect();+ };+ const replyTree = (flush = true) => {+ cursor = 0;+ renderingReply = true;+ let tree;+ try {+ tree = messages.ReplyCard({ reply, application, readOnly: false });+ } finally {+ renderingReply = false;+ }+ if (flush) flushEffects();+ return tree;+ };const press = () => {const tree = messages.ProposalCard({ reply, application, now: new Date(), readOnly: false });const find = (node) => {@@ -209,7 +261,7 @@ function harness({ lifetime = 30 } = {}) {return baselines.get("app-1");};const undoToast = () => toasts.find((toast) => toast.action?.label === "Undo");- return { env, press, bulkStart, undoToast, toasts, replyTree };+ return { env, press, bulkStart, undoToast, toasts, replyTree, application, flushEffects };}function buttonIn(node, label) {@@ -255,15 +307,40 @@ test("native reply does not log clipboard failure or a stale account, and ignoreassert.equal(h.env.logs.length, 0);});+test("native reply warns and refreshes when logging is uncertain after copying succeeds", async () => {+ const h = harness();+ h.env.logReply = async () => {+ throw new Error("Lost response");+ };+ buttonIn(h.replyTree(), "Copy and log as replied").props.onPress();+ await new Promise(setImmediate);+ assert.deepEqual(h.env.copied, ["Available [Datum und Uhrzeit 1] or [slot 2]."]);+ assert.equal(h.env.logs.length, 1);+ assert.equal(h.env.invalidations, 1);+ assert.equal(+ h.toasts.at(-1).message,+ "Reply copied. Logging wasn't confirmed. Check the timeline before trying again.",+ );+});+test("native reply view cancels only the cleared follow-up reminder and ignores a stale account effect", async () => {const h = harness();+ h.application.followUpAt = new Date("2030-03-15T09:00:00Z");+ h.replyTree();+ assert.deepEqual(h.env.clearedReminders, []);+ h.application.followUpAt = null;h.replyTree();- h.env.effects.shift()();await new Promise(setImmediate);assert.deepEqual(h.env.clearedReminders, [{ kind: "follow-up", applicationId: "app-1" }]);+ // Unchanged props must not rerun the cancellation effect.+ h.replyTree();+ assert.equal(h.env.clearedReminders.length, 1);+ h.application.followUpAt = new Date("2030-03-16T09:00:00Z");h.replyTree();+ h.application.followUpAt = null;+ h.replyTree(false);h.env.account = "acct-B";- h.env.effects.shift()();+ h.flushEffects();await new Promise(setImmediate);assert.equal(h.env.clearedReminders.length, 1);});diff --git a/apps/web/src/features/career/workspace/workspace.test.tsx b/apps/web/src/features/career/workspace/workspace.test.tsxindex 92c9bd4f3..d2ddf67c4 100644--- a/apps/web/src/features/career/workspace/workspace.test.tsx+++ b/apps/web/src/features/career/workspace/workspace.test.tsx@@ -363,6 +363,26 @@ it("highlights localized reply placeholders without blocking Copy, and logs onlyid: application.id,expectedVersion: '["2026-10-08T12:00:00.000Z","applied",null,null,null,false]',});+ await waitFor(() => expect(api.invalidate).toHaveBeenCalledWith(application.id));+});++it("warns and refreshes the application when logging is uncertain after copying succeeds", async () => {+ const writeText = vi.fn().mockResolvedValue(undefined);+ vi.stubGlobal("navigator", { clipboard: { writeText } });+ api.logReply.mockRejectedValueOnce(new Error("Lost response"));+ api.data.savedItems = [reply()];+ mount(<MessagesTab {...props} application={{ ...application, status: "applied" }} />);+ fireEvent.click(screen.getByRole("button", { name: "Copy and log as replied" }));+ const { toast } = await import("@reactive-resume/ui/components/toast");+ await waitFor(() =>+ expect(toast.add).toHaveBeenCalledWith({+ type: "error",+ description: "Reply copied. Logging wasn't confirmed. Check the timeline before trying again.",+ }),+ );+ expect(writeText).toHaveBeenCalledWith("Original reply");+ expect(api.logReply).toHaveBeenCalledTimes(1);+ expect(api.invalidate).toHaveBeenCalledWith(application.id);});it("does not log after failed clipboard access, duplicate presses or an account switch during copying", async () => {diff --git a/tests/e2e/specs/followed-up.spec.ts b/tests/e2e/specs/followed-up.spec.tsindex 36b212deb..b8e31f193 100644--- a/tests/e2e/specs/followed-up.spec.ts+++ b/tests/e2e/specs/followed-up.spec.ts@@ -58,7 +58,7 @@ test("reply placeholders keep normal Copy independent; explicit log persists conconst id = await create(page.request, {followUpAt: "2030-03-15T09:00:00Z",followUpNote: "Reply with availability",- followUpDateOnly: false,+ followUpDateOnly: true,});const sql = await database();try {@@ -86,7 +86,7 @@ test("reply placeholders keep normal Copy independent; explicit log persists conconst before = await read(page.request, id);await sql.query(`insert into career_schedule (id,user_id,application_id,kind,next_run_at,enabled)- select $1,user_id,id,'prepare','2030-03-16T09:00:00Z',false from application where id=$2`,+ select $1,user_id,id,'prepare','2030-03-16T09:00:00Z',true from application where id=$2`,[randomUUID(), id],);const schedules = (await sql.query("select * from career_schedule where application_id=$1", [id])).rows;@@ -107,6 +107,7 @@ test("reply placeholders keep normal Copy independent; explicit log persists conexpect(after).toMatchObject({followUpAt: null,followUpNote: null,+ followUpDateOnly: false,status: before.status,laneId: before.laneId,appliedAt: before.appliedAt,