Skip to content

Commit 295891d

Browse files
Copilotdavidfstr
andcommitted
Not in Archive Page: Disable all controls except Go Back during download
Co-authored-by: davidfstr <764688+davidfstr@users.noreply.github.com> Agent-Logs-Url: https://github.com/davidfstr/Crystal-Web-Archiver/sessions/68b88cdd-82a8-49f7-a6ff-9a71161f8402
1 parent 598751d commit 295891d

File tree

3 files changed

+43
-9
lines changed

3 files changed

+43
-9
lines changed

src/crystal/server/special_pages.py

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1043,14 +1043,9 @@ def not_in_archive_html(
10431043
const name = document.getElementById('cr-root-url-name').value.trim();
10441044
10451045
clearActionMessage();
1046-
setActionInProgress(true);
1047-
1048-
try {
1049-
// Start individual URL download (which will create the root URL automatically)
1050-
await startUrlDownload(/*isRoot=*/true, /*rootName=*/name);
1051-
} finally {
1052-
setActionInProgress(false);
1053-
}
1046+
// Start individual URL download (which will create the root URL automatically).
1047+
// NOTE: startUrlDownload() manages setActionInProgress() internally.
1048+
await startUrlDownload(/*isRoot=*/true, /*rootName=*/name);
10541049
}
10551050
10561051
// -----------------------------------------------------------------
@@ -1070,6 +1065,7 @@ def not_in_archive_html(
10701065
clearActionMessage();
10711066
setActionInProgress(true);
10721067
1068+
let downloadStarted = false;
10731069
try {
10741070
const createUrl = '/_/crystal/create-group';
10751071
const response = await fetch(createUrl, {
@@ -1100,6 +1096,8 @@ def not_in_archive_html(
11001096
// If download was requested, start individual URL download
11011097
// otherwise collapse the disabled form to show only essential elements
11021098
if (downloadGroupImmediately) {
1099+
downloadStarted = true;
1100+
// NOTE: startUrlDownload() manages setActionInProgress() internally.
11031101
await startUrlDownload(/*isRoot=*/false, /*rootName=*/'');
11041102
} else {
11051103
collapseCreateGroupForm();
@@ -1108,7 +1106,9 @@ def not_in_archive_html(
11081106
console.error('Group action error:', error);
11091107
showActionMessage('✖️ Failed to create group', /*isSuccess=*/false);
11101108
} finally {
1111-
setActionInProgress(false);
1109+
if (!downloadStarted) {
1110+
setActionInProgress(false);
1111+
}
11121112
}
11131113
}
11141114

src/crystal/tests/test_server.py

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -997,6 +997,36 @@ def pw_task(raw_page: RawPage, *args, **kwargs) -> None:
997997
await pw.run(pw_task)
998998

999999

1000+
@awith_playwright
1001+
async def test_given_nia_page_when_download_starts_then_all_controls_except_go_back_button_are_disabled(pw: Playwright) -> None:
1002+
async with _not_in_archive_page_visible_temporarily() as (comic1_url_in_archive, *_):
1003+
def pw_task(raw_page: RawPage, *args, **kwargs) -> None:
1004+
page = NotInArchivePage.open(raw_page, url_in_archive=comic1_url_in_archive)
1005+
1006+
# Verify all controls are initially enabled
1007+
expect(page.action_button).to_be_enabled()
1008+
expect(page.go_back_button).to_be_enabled()
1009+
1010+
with reloads_paused(raw_page):
1011+
# Start download (default action type: Create Root URL)
1012+
page.action_button.click()
1013+
1014+
# Wait for progress bar to appear, which means the server has
1015+
# acknowledged the download request and it is now in progress
1016+
page.progress_bar.wait_for(state='visible')
1017+
1018+
# Verify all controls are disabled while download is in progress
1019+
expect(page.create_root_url_radio).to_be_disabled()
1020+
expect(page.create_group_radio).to_be_disabled()
1021+
expect(page.download_only_radio).to_be_disabled()
1022+
expect(page.root_url_name_field).to_be_disabled()
1023+
expect(page.action_button).to_be_disabled()
1024+
1025+
# Verify the "← Go Back" button is still enabled
1026+
expect(page.go_back_button).to_be_enabled()
1027+
await pw.run(pw_task)
1028+
1029+
10001030
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
10011031
# Test: "Not in Archive" Page: Create Group
10021032

src/crystal/tests/util/pages.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,10 @@ def download_group_immediately_checkbox(self) -> Locator:
127127

128128
# === Action Button ===
129129

130+
@property
131+
def go_back_button(self) -> Locator:
132+
return self.raw_page.locator('button:has-text("← Go Back")')
133+
130134
@property
131135
def action_button(self) -> Locator:
132136
return self.raw_page.locator('#cr-action-button')

0 commit comments

Comments
 (0)