Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 10 additions & 10 deletions src/crystal/server/special_pages.py
Original file line number Diff line number Diff line change
Expand Up @@ -759,7 +759,7 @@ def not_in_archive_html(
</div>

<div class="cr-page__actions">
<button onclick="history.back()" class="cr-button cr-button--secondary">
<button id="cr-back-button" onclick="history.back()" class="cr-button cr-button--secondary">
← Go Back
</button>
<button id="cr-action-button" {'disabled ' if readonly else ''}onclick="onActionButtonClicked()" class="cr-button cr-button--primary">⬇ Download</button>
Expand Down Expand Up @@ -1043,14 +1043,9 @@ def not_in_archive_html(
const name = document.getElementById('cr-root-url-name').value.trim();

clearActionMessage();
setActionInProgress(true);

try {
// Start individual URL download (which will create the root URL automatically)
await startUrlDownload(/*isRoot=*/true, /*rootName=*/name);
} finally {
setActionInProgress(false);
}
// Start individual URL download (which will create the root URL automatically).
// NOTE: startUrlDownload() manages setActionInProgress() internally.
await startUrlDownload(/*isRoot=*/true, /*rootName=*/name);
}

// -----------------------------------------------------------------
Expand All @@ -1070,6 +1065,7 @@ def not_in_archive_html(
clearActionMessage();
setActionInProgress(true);

let downloadStarted = false;
try {
const createUrl = '/_/crystal/create-group';
const response = await fetch(createUrl, {
Expand Down Expand Up @@ -1100,6 +1096,8 @@ def not_in_archive_html(
// If download was requested, start individual URL download
// otherwise collapse the disabled form to show only essential elements
if (downloadGroupImmediately) {
downloadStarted = true;
// NOTE: startUrlDownload() manages setActionInProgress() internally.
await startUrlDownload(/*isRoot=*/false, /*rootName=*/'');
} else {
collapseCreateGroupForm();
Expand All @@ -1108,7 +1106,9 @@ def not_in_archive_html(
console.error('Group action error:', error);
showActionMessage('✖️ Failed to create group', /*isSuccess=*/false);
} finally {
setActionInProgress(false);
if (!downloadStarted) {
setActionInProgress(false);
}
}
}

Expand Down
30 changes: 30 additions & 0 deletions src/crystal/tests/test_server.py
Original file line number Diff line number Diff line change
Expand Up @@ -997,6 +997,36 @@ def pw_task(raw_page: RawPage, *args, **kwargs) -> None:
await pw.run(pw_task)


@awith_playwright
async def test_given_nia_page_when_download_starts_then_all_controls_except_go_back_button_are_disabled(pw: Playwright) -> None:
async with _not_in_archive_page_visible_temporarily() as (comic1_url_in_archive, *_):
def pw_task(raw_page: RawPage, *args, **kwargs) -> None:
page = NotInArchivePage.open(raw_page, url_in_archive=comic1_url_in_archive)

# Verify all controls are initially enabled
expect(page.action_button).to_be_enabled()
expect(page.go_back_button).to_be_enabled()

with reloads_paused(raw_page):
# Start download (default action type: Create Root URL)
page.action_button.click()

# Wait for progress bar to appear, which means the server has
# acknowledged the download request and it is now in progress
page.progress_bar.wait_for(state='visible')

# Verify all controls are disabled while download is in progress
expect(page.create_root_url_radio).to_be_disabled()
expect(page.create_group_radio).to_be_disabled()
expect(page.download_only_radio).to_be_disabled()
expect(page.root_url_name_field).to_be_disabled()
expect(page.action_button).to_be_disabled()

# Verify the "← Go Back" button is still enabled
expect(page.go_back_button).to_be_enabled()
await pw.run(pw_task)


# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
# Test: "Not in Archive" Page: Create Group

Expand Down
4 changes: 4 additions & 0 deletions src/crystal/tests/util/pages.py
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,10 @@ def download_group_immediately_checkbox(self) -> Locator:

# === Action Button ===

@property
def go_back_button(self) -> Locator:
return self.raw_page.locator('#cr-back-button')

@property
def action_button(self) -> Locator:
return self.raw_page.locator('#cr-action-button')
Expand Down
Loading