From 77e5f05e3a81ac962b43fa9723ba3e3ebc1fbaef Mon Sep 17 00:00:00 2001 From: Niels Swimberghe <3382717+Swimburger@users.noreply.github.com> Date: Fri, 13 Nov 2026 15:20:36 -0500 Subject: [PATCH] Wait for lazy Zstandard module before processing --- App.razor | 12 +++++++++--- e2e/live-tests/live.spec.js | 8 ++++++-- 2 files changed, 15 insertions(+), 5 deletions(-) diff --git a/App.razor b/App.razor index 6c4ba83..33e5d3f 100644 --- a/App.razor +++ b/App.razor @@ -79,13 +79,18 @@
@if (compressionMode == CompressionMode.Compress) { - + } else { - + } - @if(!anyFiles){ + @if (!IsFormatReady) + { +
Loading Zstandard module…
+ } + else if (!anyFiles) + {
No files selected
}
@@ -134,6 +139,7 @@ private bool anyFiles; private readonly Dictionary _formatUrls = new(); private Type? _zstdStreamFactory; + private bool IsFormatReady => _format != CompressionFormat.ZStd || _zstdStreamFactory is not null; private const long WarnFileSizeBytes = 250L * 1024 * 1024; private static readonly SemaphoreSlim _semaphore = new(4, 4); diff --git a/e2e/live-tests/live.spec.js b/e2e/live-tests/live.spec.js index 73ce5cd..24fd308 100644 --- a/e2e/live-tests/live.spec.js +++ b/e2e/live-tests/live.spec.js @@ -29,14 +29,18 @@ for (const format of formats) { let downloadPromise = page.waitForEvent('download'); await page.locator('input[type="file"]').setInputFiles(inputPath); - await page.getByRole('button', { name: 'Compress Files' }).click(); + const compressButton = page.getByRole('button', { name: 'Compress Files' }); + await expect(compressButton).toBeEnabled({ timeout: 30000 }); + await compressButton.click(); const compressed = await downloadPromise; await compressed.saveAs(compressedPath); await page.locator('label[for="radio-decompress"]').click(); downloadPromise = page.waitForEvent('download'); await page.locator('input[type="file"]').setInputFiles(compressedPath); - await page.getByRole('button', { name: 'Decompress Files' }).click(); + const decompressButton = page.getByRole('button', { name: 'Decompress Files' }); + await expect(decompressButton).toBeEnabled({ timeout: 30000 }); + await decompressButton.click(); const decompressed = await downloadPromise; expect(fs.readFileSync(await decompressed.path(), 'utf8')).toBe(content); } finally {