Skip to content

Commit 7c83ab1

Browse files
authored
fix: show existing backups in settings (#233)
Co-authored-by: Dennis Braun <itsDNNS@users.noreply.github.com>
1 parent 4f39ef4 commit 7c83ab1

File tree

2 files changed

+33
-4
lines changed

2 files changed

+33
-4
lines changed

app/static/js/settings.js

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ function switchSection(id) {
4040

4141
/* Auto-load data for certain panels */
4242
if (id === 'security') loadApiTokens();
43-
if (id === 'backup') loadBackupList();
43+
if (target && target.querySelector('#backup-list')) loadBackupList();
4444
if (id === 'themes') refreshRegistry();
4545

4646
/* URL hash */
@@ -710,8 +710,9 @@ function loadBackupList() {
710710
fetch('/api/backup/list')
711711
.then(function(r) { return r.json(); })
712712
.then(function(res) {
713+
var backups = Array.isArray(res) ? res : (res && Array.isArray(res.backups) ? res.backups : []);
713714
el.textContent = '';
714-
if (!res.backups || res.backups.length === 0) {
715+
if (backups.length === 0) {
715716
var emptySpan = document.createElement('span');
716717
emptySpan.style.cssText = 'color:var(--muted);font-style:italic;';
717718
emptySpan.textContent = T.backup_none || 'No backups found';
@@ -721,9 +722,9 @@ function loadBackupList() {
721722
var table = document.createElement('table');
722723
table.style.cssText = 'width:100%;border-collapse:collapse;';
723724
var tbody = document.createElement('tbody');
724-
res.backups.forEach(function(b) {
725+
backups.forEach(function(b) {
725726
var sizeMB = (b.size / 1048576).toFixed(1);
726-
var date = new Date(b.modified * 1000).toLocaleString();
727+
var date = b.modified ? new Date(b.modified).toLocaleString() : '';
727728
var tr = document.createElement('tr');
728729
tr.style.cssText = 'border-bottom:1px solid var(--card-border);';
729730

tests/e2e/test_settings.py

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,3 +57,31 @@ def test_security_has_password_field(self, settings_page):
5757
def test_back_to_dashboard_link(self, settings_page):
5858
link = settings_page.locator('a[href="/"]')
5959
assert link.count() > 0
60+
61+
62+
class TestBackupModule:
63+
"""Backup module settings interactions."""
64+
65+
def test_backup_section_loads_existing_backups(self, settings_page):
66+
settings_page.route(
67+
"**/api/backup/list",
68+
lambda route: route.fulfill(
69+
status=200,
70+
content_type="application/json",
71+
body="""
72+
[
73+
{
74+
"filename": "docsight_backup_2026-03-14_120000.tar.gz",
75+
"size": 3145728,
76+
"modified": "2026-03-14T12:00:00"
77+
}
78+
]
79+
""",
80+
),
81+
)
82+
83+
settings_page.locator('button[data-section="mod-docsight_backup"]').click()
84+
85+
backup_list = settings_page.locator("#backup-list")
86+
assert backup_list.locator("code").first.text_content() == "docsight_backup_2026-03-14_120000.tar.gz"
87+
assert backup_list.get_by_text("3.0 MB").count() > 0

0 commit comments

Comments
 (0)