Skip to content

Commit d6fcf0f

Browse files
authored
Detect stale Git comparisons on re-entry (#405)
* fix(git): check comparison freshness on re-entry * test(git): wait for active comparison surface
1 parent ec4ac4a commit d6fcf0f

3 files changed

Lines changed: 17 additions & 5 deletions

File tree

integration-tests/tests/e2e/git-comparison.test.ts

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,10 +108,18 @@ describe('Lightpanda Git comparison', () => {
108108
);
109109
expect(mountedRows).toBeLessThan(30);
110110

111+
await app.selectMainWorkspaceSurface('Chat');
112+
await fixture.page.waitForSelector(
113+
'[role="tabpanel"][data-workspace-surface-id="singleton:chat"][aria-hidden="false"]',
114+
);
111115
await writeFile(join(project, 'large.txt'), `${refreshed}\n`, 'utf8');
116+
await app.selectMainWorkspaceSurface('Git');
117+
await fixture.page.waitForSelector(
118+
'[role="tabpanel"][data-workspace-surface-id="singleton:git"][aria-hidden="false"]',
119+
);
112120
await fixture.page.waitForFunction(
113121
() => document.body.textContent?.includes('The Working Tree changed.'),
114-
{ timeout: 25_000 },
122+
{ timeout: 5_000 },
115123
);
116124
expect(await fixture.page.$eval('body', (element) => element.textContent)).toContain(
117125
'large after marker',

web/src/lib/components/git/__tests__/git-freshness-polling.test.ts

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ describe('git freshness polling', () => {
2828
vi.useRealTimers();
2929
});
3030

31-
it('polls on the configured interval without an immediate first tick', () => {
31+
it('polls immediately and on the configured interval', async () => {
3232
vi.useFakeTimers();
3333
const checkFreshness = vi.fn();
3434
const documentRef = makeDocumentRef('visible');
@@ -40,11 +40,14 @@ describe('git freshness polling', () => {
4040
intervalMs: 15_000,
4141
});
4242

43-
expect(checkFreshness).not.toHaveBeenCalled();
43+
await vi.runAllTicks();
44+
expect(checkFreshness).toHaveBeenCalledOnce();
45+
expect(checkFreshness).toHaveBeenLastCalledWith('/project');
4446
vi.advanceTimersByTime(14_999);
45-
expect(checkFreshness).not.toHaveBeenCalled();
47+
expect(checkFreshness).toHaveBeenCalledOnce();
4648
vi.advanceTimersByTime(1);
47-
expect(checkFreshness).toHaveBeenCalledWith('/project');
49+
expect(checkFreshness).toHaveBeenCalledTimes(2);
50+
expect(checkFreshness).toHaveBeenLastCalledWith('/project');
4851

4952
cleanup();
5053
});

web/src/lib/components/git/git-freshness-polling.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ export function startGitFreshnessPolling({
3636
return startVisibilityPolling({
3737
intervalMs,
3838
poll: () => checkFreshness(projectPath),
39+
pollImmediately: true,
3940
documentRef,
4041
setIntervalFn,
4142
clearIntervalFn,

0 commit comments

Comments
 (0)