mirror of
https://github.com/Ark0N/Codeman.git
synced 2026-11-30 16:39:33 +01:00
fix(web): keep Load full history on Loading… while it stands in for Reload (#814)
- A content-anchored Load full history pull sets _historyReloadActionLoadingFor and clears it on settle, as Reload history does. - The button renders from that loading state, so the re-render the in-flight pull triggers keeps it disabled on Loading…. - The top-anchor case keeps no loading state, so the bar still hides on a scroll back to live output.
This commit is contained in:
1 parent
a692f9f193
commit
e7f90cb3ec
3 files changed
+36
-5
No files matched your search
@@ -1378,13 +1378,31 @@ describe('manual history banner action', () => {
|
||||
truncationReason: kind === 'capped' ? 'capped' : 'tail',
|
||||
});
|
||||
expect(bar.children.filter((child) => child.className === 'history-trunc-load')).toHaveLength(1);
|
||||
expect(button()!.textContent).toBe(kind === 'recoverable' ? 'Load full history' : 'Reload history');
|
||||
const label = kind === 'recoverable' ? 'Load full history' : 'Reload history';
|
||||
expect(button()!.textContent).toBe(label);
|
||||
// Hold the pull open the way the real one does: in flight, Reload history
|
||||
// is no longer eligible, and the sync that follows rebuilds the bar.
|
||||
const { promise, resolve: release } = Promise.withResolvers<void>();
|
||||
app._maybeRefetchFullHistory.mockImplementationOnce(() => {
|
||||
app._fullHistoryRepullInFlight = true;
|
||||
return promise.finally(() => {
|
||||
app._fullHistoryRepullInFlight = false;
|
||||
});
|
||||
});
|
||||
const clicked = button()!.onclick!();
|
||||
app._syncHistoryReloadAction();
|
||||
expect({ text: button()!.textContent, disabled: button()!.disabled }).toEqual({
|
||||
text: 'Loading…',
|
||||
disabled: true,
|
||||
});
|
||||
release();
|
||||
await clicked;
|
||||
// Either way the one control stands in for Reload history, so it keeps the
|
||||
// reader's line rather than landing on the old row 0.
|
||||
await button()!.onclick!();
|
||||
expect(app._maybeRefetchFullHistory).toHaveBeenCalledExactlyOnceWith(
|
||||
expect.objectContaining({ force: true, anchor: 'content' })
|
||||
);
|
||||
expect({ text: button()!.textContent, disabled: button()!.disabled }).toEqual({ text: label, disabled: false });
|
||||
});
|
||||
|
||||
it('keeps the top anchor for Load full history when Reload history is not eligible', async () => {
|
||||
|
||||
Reference in new issue
Block a user