Skip to content
Merged
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
12 changes: 9 additions & 3 deletions App.razor
Original file line number Diff line number Diff line change
Expand Up @@ -79,13 +79,18 @@
<div class="mb-3">
@if (compressionMode == CompressionMode.Compress)
{
<button role="button" class="btn btn-primary btn-lg w-100" @onclick="CompressFiles" disabled="@(!anyFiles)">Compress Files</button>
<button role="button" class="btn btn-primary btn-lg w-100" @onclick="CompressFiles" disabled="@(!anyFiles || !IsFormatReady)">Compress Files</button>
}
else
{
<button role="button" class="btn btn-primary btn-lg w-100" @onclick="DecompressFiles" disabled="@(!anyFiles)">Decompress Files</button>
<button role="button" class="btn btn-primary btn-lg w-100" @onclick="DecompressFiles" disabled="@(!anyFiles || !IsFormatReady)">Decompress Files</button>
}
@if(!anyFiles){
@if (!IsFormatReady)
{
<div class="text-muted small text-center mt-1" role="status">Loading Zstandard module…</div>
}
else if (!anyFiles)
{
<div class="text-danger small text-center mt-1">No files selected</div>
}
</div>
Expand Down Expand Up @@ -134,6 +139,7 @@
private bool anyFiles;
private readonly Dictionary<CompressionFormat, string> _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);

Expand Down
8 changes: 6 additions & 2 deletions e2e/live-tests/live.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down