Skip to content

Commit 6755e3f

Browse files
committed
fix(git): check comparison freshness on re-entry
1 parent a3be198 commit 6755e3f

3 files changed

Lines changed: 29 additions & 9 deletions

File tree

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

Lines changed: 21 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -106,12 +106,28 @@ describe('Lightpanda Git comparison', () => {
106106
'[data-git-virtual-row]',
107107
(rows) => rows.length,
108108
);
109-
expect(mountedRows).toBeLessThan(30);
109+
expect(mountedRows).toBeLessThan(30);
110110

111-
await writeFile(join(project, 'large.txt'), `${refreshed}\n`, 'utf8');
112-
await fixture.page.waitForFunction(
113-
() => document.body.textContent?.includes('The Working Tree changed.'),
114-
{ timeout: 25_000 },
111+
await app.selectMainWorkspaceSurface('Chat');
112+
await fixture.page.waitForFunction(() =>
113+
[...document.querySelectorAll<HTMLButtonElement>('[role="tab"]')].some(
114+
(tab) =>
115+
(tab.getAttribute('aria-label') || tab.textContent?.trim()) === 'Chat'
116+
&& tab.getAttribute('aria-selected') === 'true',
117+
),
118+
);
119+
await writeFile(join(project, 'large.txt'), `${refreshed}\n`, 'utf8');
120+
await app.selectMainWorkspaceSurface('Git');
121+
await fixture.page.waitForFunction(() =>
122+
[...document.querySelectorAll<HTMLButtonElement>('[role="tab"]')].some(
123+
(tab) =>
124+
(tab.getAttribute('aria-label') || tab.textContent?.trim()) === 'Git'
125+
&& tab.getAttribute('aria-selected') === 'true',
126+
),
127+
);
128+
await fixture.page.waitForFunction(
129+
() => document.body.textContent?.includes('The Working Tree changed.'),
130+
{ timeout: 5_000 },
115131
);
116132
expect(await fixture.page.$eval('body', (element) => element.textContent)).toContain(
117133
'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)