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 <noreply@anthropic.com>
This commit is contained in:
1 parent
1bc515164a
commit
5e80d307a7
2 files changed
+38
-1
No files matched your search
@@ -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(<AppContext.Provider value={value}><ToastProvider><DataSection /></ToastProvider></AppContext.Provider>);
|
||||
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);
|
||||
});
|
||||
Reference in new issue
Block a user