test(e2e): make archive fixtures deterministic

This commit is contained in:
saltbo
2026-08-08 13:21:11 -04:00
parent 20eae12dda
commit d289e93fee
+14 -3
View File
@@ -1,4 +1,3 @@
import { randomBytes } from 'node:crypto'
import { expect, type Page, test } from '@playwright/test'
import { DirType } from '../shared/constants'
import type { BackgroundJob, PaginatedResponse, StorageObject } from '../shared/types'
@@ -12,8 +11,8 @@ test.describe('Archive jobs with queued streaming workers @all @critical', () =>
test('compresses and extracts through the background queue', async ({ page }) => {
await signUpAndGoToFiles(page)
await seedFile(page, 'alpha.txt', randomBytes(fixtureSize))
await seedFile(page, 'beta.txt', randomBytes(fixtureSize))
await seedFile(page, 'alpha.txt', fixtureBytes(fixtureSize, 0x13579bdf))
await seedFile(page, 'beta.txt', fixtureBytes(fixtureSize, 0x2468ace0))
await page.reload()
await selectFile(page, 'alpha.txt')
@@ -118,3 +117,15 @@ async function expectJobCompleted(page: Page, jobId: string): Promise<Background
function isBackgroundJobPost(url: string, method: string) {
return method === 'POST' && url.includes('/api/background-jobs')
}
function fixtureBytes(size: number, seed: number): Buffer {
const bytes = Buffer.allocUnsafe(size)
let state = seed
for (let index = 0; index < size; index += 1) {
state ^= state << 13
state ^= state >>> 17
state ^= state << 5
bytes[index] = state
}
return bytes
}