From 5e80d307a75c9cae1f96720b3e47d85e736f85b6 Mon Sep 17 00:00:00 2001 From: nmemmert <67961292+nmemmert@users.noreply.github.com> Date: Wed, 14 Oct 2026 14:21:20 -0400 Subject: [PATCH] Count "Download from my account" as a backup for the Home nudge Only "Download backup" recorded the date, so downloading from the account left Home saying "You haven't downloaded a backup yet". Both now record it. Co-Authored-By: Claude Sonnet 5.5 --- src/components/settings/DataSection.jsx | 2 +- src/components/settings/DataSection.test.jsx | 37 ++++++++++++++++++++ 2 files changed, 38 insertions(+), 1 deletion(-) create mode 100644 src/components/settings/DataSection.test.jsx diff --git a/src/components/settings/DataSection.jsx b/src/components/settings/DataSection.jsx index b1ea71b..f23386d 100644 --- a/src/components/settings/DataSection.jsx +++ b/src/components/settings/DataSection.jsx @@ -81,7 +81,7 @@ export default function DataSection() {
{authUser && ( - Download from my account + markBackedUp()} className={`${btn} inline-block`} title="Everything saved to your account on the server, including studies from other devices">Download from my account )} diff --git a/src/components/settings/DataSection.test.jsx b/src/components/settings/DataSection.test.jsx new file mode 100644 index 0000000..11c8d5c --- /dev/null +++ b/src/components/settings/DataSection.test.jsx @@ -0,0 +1,37 @@ +import { render, screen } from '@testing-library/react'; +import userEvent from '@testing-library/user-event'; +import { vi, test, expect, beforeEach } from 'vitest'; +import { AppContext } from '../../context/AppContext.js'; +import { ToastProvider } from '../Toasts.jsx'; +import { lastBackupAt } from '../../utils/backup.js'; +import DataSection from './DataSection.jsx'; + +const value = { + authUser: { email: 'a@b.test' }, readerBookmarks: {}, readerBookmarkNotes: {}, readerTextHighlights: [], readerColorLabels: {}, readerInkByPage: {}, + readingPlansState: { progress: [], customPlans: [], activity: [] }, importReaderMarks: vi.fn(), importReadingPlans: vi.fn(), refreshProjectIndex: vi.fn(), prayers: [], importPrayers: vi.fn(), +}; +const setup = () => { + render(); + return userEvent.setup(); +}; + +beforeEach(() => { + localStorage.clear(); + URL.createObjectURL = vi.fn(() => 'blob:x'); + URL.revokeObjectURL = vi.fn(); + document.addEventListener('click', (e) => { if (e.target.closest?.('a[download]')) e.preventDefault(); }); // no real navigation in the test +}); + +test('downloading the backup file is remembered, so Home stops asking', async () => { + const user = setup(); + expect(lastBackupAt()).toBeNull(); + await user.click(screen.getByRole('button', { name: 'Download backup' })); + expect(lastBackupAt()).toBeGreaterThan(Date.now() - 5000); +}); + +test('downloading from the account is remembered too', async () => { + const user = setup(); + expect(lastBackupAt()).toBeNull(); + await user.click(screen.getByRole('link', { name: 'Download from my account' })); + expect(lastBackupAt()).toBeGreaterThan(Date.now() - 5000); +});