remove tests

This commit is contained in:
prakash 2026-06-25 14:39:00 +05:30
parent 3899a6ebb3
commit 5e8a881481
No known key found for this signature in database

View file

@ -191,89 +191,6 @@ describe('Golden retriever', () => {
expect(requestAt).toBe(1) // only the first file upload should have happened so far
})
// Regression test for https://github.com/transloadit/uppy/issues/6280
// A failing localStorage write must never break uploading. This is what
// originally broke: large Transloadit state overflowed localStorage's ~5MB
// cap, `setItem` threw QuotaExceededError, and the uncaught throw cascaded on
// every assembly update. Persistence is best-effort on every backend, so
// adding files must stay functional even when localStorage is unusable.
test('does not throw when localStorage is full/unavailable', async () => {
const originalSetItem = Storage.prototype.setItem
const setItemSpy = vi
.spyOn(Storage.prototype, 'setItem')
.mockImplementation(function (this: Storage, key: string, value: string) {
if (key.startsWith('uppyState:')) {
// Simulate Chrome hitting its ~5MB localStorage cap.
throw new DOMException('exceeded the quota', 'QuotaExceededError')
}
return originalSetItem.call(this, key, value)
})
try {
const uppy = createUppy().use(GoldenRetriever)
// Adding files persists the recovery snapshot. A throwing localStorage
// must not propagate out of that persistence.
expect(() => {
for (let i = 0; i < 5; i++) {
uppy.addFile({
name: `${i}.txt`,
type: 'text/plain',
data: createMockFile({ size: 1000 }),
})
}
}).not.toThrow()
// Uppy must remain functional despite persistence failing.
expect(uppy.getFiles().length).toBe(5)
} finally {
setItemSpy.mockRestore()
}
})
// Regression test for https://github.com/transloadit/uppy/issues/6280
// The recovery snapshot is persisted to IndexedDB (which has a far larger
// quota than localStorage's ~5MB cap), so recovery keeps working even when
// localStorage is full or unavailable.
test('recovers files via IndexedDB even when localStorage is unavailable', async ({
worker,
}) => {
worker.use(
http.post('http://localhost/upload', () => HttpResponse.json({})),
)
const originalSetItem = Storage.prototype.setItem
const setItemSpy = vi
.spyOn(Storage.prototype, 'setItem')
.mockImplementation(function (this: Storage, key: string, value: string) {
if (key.startsWith('uppyState:')) {
// Simulate localStorage being full/unavailable.
throw new DOMException('exceeded the quota', 'QuotaExceededError')
}
return originalSetItem.call(this, key, value)
})
try {
let uppy = createUppy().use(GoldenRetriever)
const fileInput = document.querySelector('.uppy-Dashboard-input')!
const file = createMockFile({ size: 50000 })
await userEvent.upload(fileInput, file)
// Reload the page and recreate Uppy. The snapshot can only have survived
// in IndexedDB, since every localStorage write threw above.
uppy = createUppy({ withPageReload: true })
.use(GoldenRetriever)
.use(XHRUpload, { endpoint: 'http://localhost/upload' })
await new Promise((resolve) => uppy.once('restored', resolve))
expect(uppy.getFiles().length).toBe(1)
await expect.element(page.getByText(file.name)).toBeVisible()
} finally {
setItemSpy.mockRestore()
}
})
// IndexedDB is the primary backend, but where it's unavailable (e.g. some
// private-mode/webview contexts) GoldenRetriever must fall back to the
// localStorage-backed MetaDataStore and still restore. This is the only test