mirror of
https://github.com/wu736139669/hapi.git
synced 2026-11-25 05:07:05 +00:00
* fix(web): allow retrying failed attachment uploads
* fix(web): address attachment retry review feedback
* fix(web): respect attachment adapter retryability
* fix(web): preserve attachment order on retry
* fix(web): finish attachment retry review fixes
* chore: sync upstream main at a259ad3
* fix(web): preserve order across overlapping attachment retries
* fix(web): cancel and guard overlapping attachment retries
35 lines
1.5 KiB
TypeScript
35 lines
1.5 KiB
TypeScript
import { describe, expect, it } from 'vitest'
|
|
import { moveAttachmentId, orderItemsById, reconcileAttachmentOrder, replaceAttachmentId } from './attachmentOrder'
|
|
|
|
describe('attachment order helpers', () => {
|
|
it('keeps existing order while appending newly added attachments', () => {
|
|
expect(reconcileAttachmentOrder(['b', 'stale', 'a'], ['a', 'b', 'c'])).toEqual(['b', 'a', 'c'])
|
|
})
|
|
|
|
it('moves an attachment immediately before the drop target', () => {
|
|
expect(moveAttachmentId(['a', 'b', 'c'], 'a', 'c')).toEqual(['b', 'a', 'c'])
|
|
expect(moveAttachmentId(['a', 'b', 'c'], 'c', 'a')).toEqual(['c', 'a', 'b'])
|
|
expect(moveAttachmentId(['a', 'b', 'c'], 'a', 'b', 'after')).toEqual(['b', 'a', 'c'])
|
|
})
|
|
|
|
it('orders objects without dropping ids unknown to the order list', () => {
|
|
const items = [{ id: 'a' }, { id: 'b' }, { id: 'c' }]
|
|
expect(orderItemsById(items, ['c', 'a'])).toEqual([{ id: 'c' }, { id: 'a' }, { id: 'b' }])
|
|
})
|
|
|
|
it('replaces a retried attachment at its original index', () => {
|
|
expect(replaceAttachmentId(['first', 'failed', 'last'], 'failed', 'retried')).toEqual([
|
|
'first', 'retried', 'last',
|
|
])
|
|
expect(replaceAttachmentId(['first', 'last', 'retried'], 'failed', 'retried', 1)).toEqual([
|
|
'first', 'retried', 'last',
|
|
])
|
|
expect(replaceAttachmentId(
|
|
replaceAttachmentId(['a', 'b', 'c'], 'a', 'a-retry'),
|
|
'b',
|
|
'b-retry',
|
|
1,
|
|
)).toEqual(['a-retry', 'b-retry', 'c'])
|
|
})
|
|
})
|