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: ask for donations only after a successful export
Amruth Pillaib4469f753f9b
diff --git a/apps/web/src/components/ui/donation-toast.test.tsx b/apps/web/src/components/ui/donation-toast.test.tsxdeleted file mode 100644index 664c11d0c..000000000--- a/apps/web/src/components/ui/donation-toast.test.tsx+++ /dev/null@@ -1,59 +0,0 @@-// @vitest-environment happy-dom-// @vitest-environment-options {"url":"https://localhost:3000"}--import { act, fireEvent, render, screen } from "@testing-library/react";-import { afterEach, beforeEach, expect, it, vi } from "vite-plus/test";-import { i18n } from "@lingui/core";-import Cookies from "js-cookie";-import { DonationToast } from "./donation-toast";--const route = vi.hoisted(() => ({ pathname: "/dashboard" }));-vi.mock("@tanstack/react-router", () => ({ useRouterState: () => route.pathname }));--const FIVE_MINUTES = 5 * 60 * 1000;-const DISMISSED_COOKIE = "donation-toast-dismissed";--beforeEach(() => {- vi.useFakeTimers({ toFake: ["Date", "setTimeout", "clearTimeout", "requestAnimationFrame", "cancelAnimationFrame"] });- i18n.loadAndActivate({ locale: "en-US", messages: {} });- Cookies.remove(DISMISSED_COOKIE);-});--afterEach(() => {- Cookies.remove(DISMISSED_COOKIE);- vi.useRealTimers();-});--it("asks after five minutes and remembers a dismissal", async () => {- render(<DonationToast />);-- await act(() => vi.advanceTimersByTimeAsync(FIVE_MINUTES));- // In the DOM, not "visible": without LazyMotion features loaded, the entrance stays at opacity 0.- expect(screen.getByText("Enjoying Reactive Resume?")).toBeInTheDocument();-- fireEvent.click(screen.getByRole("button", { name: "Maybe later" }));- expect(Cookies.get(DISMISSED_COOKIE)).toBe("true");-});--it("never covers the homepage or other public pages", async () => {- route.pathname = "/";- render(<DonationToast />);- await act(() => vi.advanceTimersByTimeAsync(FIVE_MINUTES));- expect(screen.queryByText("Enjoying Reactive Resume?")).toBeNull();- route.pathname = "/dashboard";-});--it("waits while a toast or dialog is showing", async () => {- route.pathname = "/dashboard";- const toast = document.createElement("div");- toast.dataset.slot = "toast";- document.body.append(toast);- render(<DonationToast />);-- await act(() => vi.advanceTimersByTimeAsync(FIVE_MINUTES));- expect(screen.queryByText("Enjoying Reactive Resume?")).not.toBeInTheDocument();-- toast.remove();- await act(() => vi.advanceTimersByTimeAsync(31_000));- expect(screen.getByText("Enjoying Reactive Resume?")).toBeInTheDocument();-});diff --git a/apps/web/src/components/ui/donation-toast.tsx b/apps/web/src/components/ui/donation-toast.tsxdeleted file mode 100644index 2cc675bf9..000000000--- a/apps/web/src/components/ui/donation-toast.tsx+++ /dev/null@@ -1,84 +0,0 @@-import { t } from "@lingui/core/macro";-import { useRouterState } from "@tanstack/react-router";-import Cookies from "js-cookie";-import { AnimatePresence, m } from "motion/react";-import { useId, useState } from "react";-import { useTimeout } from "usehooks-ts";-import { Button } from "@reactive-resume/ui/components/button";-import { Icon } from "@reactive-resume/ui/components/icon";-import { cn } from "@reactive-resume/utils/style";-import { D3, EASE, EXIT } from "@/libs/motion";--const DONATE_URL = "https://opencollective.com/reactive-resume/donate";-const SHOW_DELAY_MS = 5 * 60 * 1000; // 5 minutes-// While a toast or dialog is up (something was just saved, or is being decided), wait this long and look again.-const HOLD_MS = 30 * 1000;--const busy = () => !!document.querySelector('[data-slot="toast"], [role="dialog"], [role="alertdialog"]');-const DISMISSED_COOKIE_NAME = "donation-toast-dismissed";--export function DonationToast() {- const titleId = useId();- const pathname = useRouterState({ select: (state) => state.location.pathname });- const [open, setOpen] = useState(false);- // Only inside the app: on the homepage and other public pages it would sit over the story being read.- const inApp = pathname.startsWith("/dashboard") || pathname.startsWith("/builder");-- // Never closes by itself: "Maybe later", or donating, is what records the 1-week cookie.- const [delay, setDelay] = useState<number | null>(() =>- Cookies.get(DISMISSED_COOKIE_NAME) === "true" ? null : SHOW_DELAY_MS,- );- useTimeout(() => {- if (!busy()) return setOpen(true);- // A different value restarts the timer for another wait.- setDelay((current) => (current === HOLD_MS ? HOLD_MS + 1 : HOLD_MS));- }, delay);-- const dismiss = () => {- setOpen(false);- Cookies.set(DISMISSED_COOKIE_NAME, "true", { expires: 7, path: "/", secure: true, sameSite: "lax" });- };-- return (- <AnimatePresence>- {open && inApp && (- <m.aside- aria-labelledby={titleId}- initial={{ opacity: 0, y: 8 }}- animate={{ opacity: 1, y: 0, transition: { duration: D3, ease: EASE } }}- exit={{ opacity: 0, y: 6, transition: { duration: D3 * EXIT, ease: EASE } }}- className={cn(- "fixed inset-x-3 bottom-3 z-40 flex gap-3 rounded-xl border border-line bg-surface p-4 shadow-e2 sm:inset-x-auto sm:end-5 sm:bottom-5 sm:w-[344px]",- // Clears the dashboard's bottom tab bar on phones.- pathname.startsWith("/dashboard") && "max-sm:bottom-[calc(64px+env(safe-area-inset-bottom))]",- )}- >- <Icon name="hand-heart" className="mt-px shrink-0 text-accent-text" />-- <div className="min-w-0">- <p id={titleId} className="text-sm font-semibold text-ink">- {t`Enjoying Reactive Resume?`}- </p>- <p className="mt-1 text-[13px] leading-relaxed text-ink-2">- {t`It's free and open source, kept going by donations from the people who use it. If it has helped you, consider chipping in.`}- </p>-- <div className="mt-3 flex items-center gap-1">- <Button- size="sm"- nativeButton={false}- render={<a href={DONATE_URL} target="_blank" rel="noopener noreferrer" />}- onClick={dismiss}- >- {t`Donate`}- </Button>- <Button variant="ghost" size="sm" onClick={dismiss} className="text-ink-2">- {t`Maybe later`}- </Button>- </div>- </div>- </m.aside>- )}- </AnimatePresence>- );-}diff --git a/apps/web/src/features/resume/share/download-tab.test.tsx b/apps/web/src/features/resume/share/download-tab.test.tsxindex 3d23dafc8..dc0b3d6b8 100644--- a/apps/web/src/features/resume/share/download-tab.test.tsx+++ b/apps/web/src/features/resume/share/download-tab.test.tsx@@ -34,8 +34,10 @@ it("offers peer feedback only after a successful export and clears it for a new);const invite = () => screen.queryByRole("link", { name: "Get resume feedback on Discord" });expect(invite()).toBeNull();+ expect(screen.queryByRole("link", { name: "Donate" })).toBeNull();fireEvent.click(screen.getByRole("button", { name: "Download PDF" }));expect(invite()).toBeNull();+ expect(screen.queryByRole("link", { name: "Donate" })).toBeNull();finish(file);const link = await screen.findByRole("link", { name: "Get resume feedback on Discord" });expect(link.getAttribute("href")).toBe("https://discord.gg/9kAqrGcwn5");@@ -44,10 +46,12 @@ it("offers peer feedback only after a successful export and clears it for a newfireEvent.click(screen.getByRole("radio", { name: /Word/ }));expect(invite()).toBeNull();+ expect(screen.queryByRole("link", { name: "Donate" })).toBeNull();mocks.generate.mockRejectedValueOnce(new Error("Export unavailable"));fireEvent.click(screen.getByRole("button", { name: "Download Word" }));await screen.findByRole("alert");expect(invite()).toBeNull();+ expect(screen.queryByRole("link", { name: "Donate" })).toBeNull();expect(mocks.download).toHaveBeenCalledTimes(1);mocks.generate.mockResolvedValueOnce(file);fireEvent.click(screen.getByRole("button", { name: "Download PDF instead" }));diff --git a/apps/web/src/routes/__root.tsx b/apps/web/src/routes/__root.tsxindex c68b14a5e..b4c9648d1 100644--- a/apps/web/src/routes/__root.tsx+++ b/apps/web/src/routes/__root.tsx@@ -14,10 +14,10 @@ import { TanStackDevtools } from "@tanstack/react-devtools";import { HotkeysProvider } from "@tanstack/react-hotkeys";import { QueryClientProvider } from "@tanstack/react-query";import { ReactQueryDevtoolsPanel } from "@tanstack/react-query-devtools";-import { createRootRouteWithContext, HeadContent, Outlet, redirect, useRouterState } from "@tanstack/react-router";+import { createRootRouteWithContext, HeadContent, Outlet, redirect } from "@tanstack/react-router";import { TanStackRouterDevtoolsPanel } from "@tanstack/react-router-devtools";import { LazyMotion, MotionConfig } from "motion/react";-import { lazy, Suspense, useEffect } from "react";+import { useEffect } from "react";import { Toaster } from "@reactive-resume/ui/components/toast";import { TooltipProvider } from "@reactive-resume/ui/components/tooltip";import { isAppSectionPath } from "@reactive-resume/utils/app-paths";@@ -49,11 +49,6 @@ const iconContextValue: IconProps = { size: 16, weight: "regular" };const motionFeatures = import("@/libs/motion-features").then((module) => module.default);const loadMotionFeatures = () => motionFeatures;-// Shows after five minutes at the earliest, so it loads after everything else.-const DonationToast = lazy(() =>- import("@/components/ui/donation-toast").then((module) => ({ default: module.DonationToast })),-);-export const Route = createRootRouteWithContext<RouterContext>()({component: RootComponent,// index.html carries the tags that never change (charset, viewport, icons, manifest); the server adds each page's@@ -80,9 +75,6 @@ function RootComponent() {// WebMCP: browser agents can list and open the signed-in user's documents from any page.useDocumentWebMcpTools(session !== null);- // Suppress the app-wide donation toast inside the builder so it doesn't cover the right-sidebar controls.- const isBuilder = useRouterState({ select: (s) => s.location.pathname.startsWith("/builder") });-// The theme class is owned by ThemeProvider, which also follows the system appearance.useEffect(() => {document.documentElement.lang = locale;@@ -107,11 +99,6 @@ function RootComponent() {<Outlet /><SessionRecovery />- {!isBuilder && (- <Suspense>- <DonationToast />- </Suspense>- )}<DialogManager /><CommandPalette /><KeyboardShortcuts />diff --git a/docs/guides/exporting-your-resume.mdx b/docs/guides/exporting-your-resume.mdxindex 921e42c19..2264ca5b0 100644--- a/docs/guides/exporting-your-resume.mdx+++ b/docs/guides/exporting-your-resume.mdx@@ -55,6 +55,9 @@ The file is named after the full name on your resume, followed by the word for r</Step></Steps>+After a successful download in the web sheet, an optional **Donate** link appears below the button. It does not+appear while the file is being prepared or if the download fails. There is no timed donation prompt while you work.+A few things you may see on this tab:- **Check has _n_ things to review. You can still download.** Check mode found issues on your resume. They never block a download; select **Review** to see them first.diff --git a/tests/e2e/specs/donation-timing.spec.ts b/tests/e2e/specs/donation-timing.spec.tsnew file mode 100644index 000000000..c2f50e6bb--- /dev/null+++ b/tests/e2e/specs/donation-timing.spec.ts@@ -0,0 +1,46 @@+import { createSampleResumeFromDashboard, openDownloadDialog } from "../fixtures/resume";+import { expect, test } from "../fixtures/test";++test("private setup never interrupts work with a timed donation request", async ({ authPage: page }) => {+ await page.clock.install();+ await page.goto("/dashboard/settings/ai");+ await expect(page.getByRole("heading", { name: "AI & developer", exact: true })).toBeVisible();+ await page.clock.runFor(1000);+ await page.clock.fastForward(6 * 60 * 1000);+ await page.clock.runFor(1000);+ await expect(page.getByText("Enjoying Reactive Resume?", { exact: true })).toHaveCount(0);+ await expect(page.getByRole("button", { name: "Maybe later", exact: true })).toHaveCount(0);+});++test("resume donation invitation follows the completed file download", async ({ authPage: page }, info) => {+ await createSampleResumeFromDashboard(page, info);+ const sheet = await openDownloadDialog(page);+ const donate = sheet.getByRole("link", { name: "Donate", exact: true });+ await expect(donate).toHaveCount(0);+ await sheet.getByRole("radio", { name: /JSON/ }).click();+ const pending = page.waitForEvent("download");+ await sheet.getByRole("button", { name: "Download JSON", exact: true }).click();+ const file = await pending;+ expect(await file.failure()).toBeNull();+ await expect(donate).toHaveAttribute("href", "https://opencollective.com/reactive-resume/donate");+ await sheet.getByRole("radio", { name: /Markdown/ }).click();+ await expect(donate).toHaveCount(0);+});++test("letter donation invitation follows the completed file download", async ({ authPage: page }) => {+ const created = await page.request.post("/api/openapi/cover-letters", {+ data: { name: "Fictional export letter", content: "<p>Thank you for considering my application.</p>" },+ });+ await expect(created).toBeOK();+ const { id } = await created.json();+ await page.goto(`/builder/letter/${id}`);+ const sheet = await openDownloadDialog(page);+ const donate = sheet.getByRole("link", { name: "Donate", exact: true });+ await expect(donate).toHaveCount(0);+ await sheet.getByRole("radio", { name: /JSON/ }).click();+ const pending = page.waitForEvent("download");+ await sheet.getByRole("button", { name: "Download JSON", exact: true }).click();+ const file = await pending;+ expect(await file.failure()).toBeNull();+ await expect(donate).toHaveAttribute("href", "https://opencollective.com/reactive-resume/donate");+});