feat: person @mentions edit-mode infrastructure (PR-B1, #362) #369
@@ -72,8 +72,11 @@ describe('createBlockAutoSave', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('preserves the in-flight text + mentionedPersons across a save failure (B12)', async () => {
|
it('preserves the in-flight text + mentionedPersons across a save failure (B12)', async () => {
|
||||||
|
// Hold the second saveFn so we can observe the saving→saved transition
|
||||||
|
// (Tester #5506 §5).
|
||||||
|
let resolveSecond!: () => void;
|
||||||
mockSaveFn.mockRejectedValueOnce(new Error('boom'));
|
mockSaveFn.mockRejectedValueOnce(new Error('boom'));
|
||||||
mockSaveFn.mockResolvedValueOnce(undefined);
|
mockSaveFn.mockReturnValueOnce(new Promise<void>((r) => (resolveSecond = r)));
|
||||||
const as = createBlockAutoSave({ saveFn: mockSaveFn, documentId: 'doc-1' });
|
const as = createBlockAutoSave({ saveFn: mockSaveFn, documentId: 'doc-1' });
|
||||||
|
|
||||||
const mentions: PersonMention[] = [{ personId: 'p-aug', displayName: 'Auguste Raddatz' }];
|
const mentions: PersonMention[] = [{ personId: 'p-aug', displayName: 'Auguste Raddatz' }];
|
||||||
@@ -82,8 +85,14 @@ describe('createBlockAutoSave', () => {
|
|||||||
expect(as.getSaveState('block-1')).toBe('error');
|
expect(as.getSaveState('block-1')).toBe('error');
|
||||||
|
|
||||||
// Retry without re-passing the data — the hook resends the preserved payload.
|
// Retry without re-passing the data — the hook resends the preserved payload.
|
||||||
await as.handleRetry('block-1', 'should-not-be-used', []);
|
const retryPromise = as.handleRetry('block-1', 'should-not-be-used', []);
|
||||||
|
// Yield once so executeSave runs synchronously up to the saveFn await.
|
||||||
|
await Promise.resolve();
|
||||||
|
expect(as.getSaveState('block-1')).toBe('saving');
|
||||||
expect(mockSaveFn).toHaveBeenLastCalledWith('block-1', '@Auguste Raddatz hi', mentions);
|
expect(mockSaveFn).toHaveBeenLastCalledWith('block-1', '@Auguste Raddatz hi', mentions);
|
||||||
|
|
||||||
|
resolveSecond();
|
||||||
|
await retryPromise;
|
||||||
expect(as.getSaveState('block-1')).toBe('saved');
|
expect(as.getSaveState('block-1')).toBe('saved');
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user