Skip to content

Commit fcb5fd0

Browse files
authored
Add PTY explicit layout resize coverage (#143)
1 parent 716cef4 commit fcb5fd0

2 files changed

Lines changed: 72 additions & 2 deletions

File tree

test/app-interactions.test.tsx

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1071,6 +1071,8 @@ describe("App interactions", () => {
10711071
try {
10721072
await flush(setup);
10731073
const initialFrame = setup.captureCharFrame();
1074+
const initialTopLine = firstVisibleAddedLine(initialFrame);
1075+
expect(initialTopLine).not.toBeNull();
10741076

10751077
await act(async () => {
10761078
await setup.mockInput.pressKey("d");
@@ -1090,9 +1092,17 @@ describe("App interactions", () => {
10901092
await setup.mockInput.pressKey("f");
10911093
});
10921094
await flush(setup);
1093-
frame = await waitForFrame(setup, (nextFrame) => nextFrame !== initialFrame);
1095+
frame = await waitForFrame(
1096+
setup,
1097+
(nextFrame) => {
1098+
const nextTopLine = firstVisibleAddedLine(nextFrame);
1099+
return nextTopLine !== null && nextTopLine !== initialTopLine;
1100+
},
1101+
20,
1102+
);
10941103
expect(frame).toContain("export const line");
1095-
expect(frame).not.toEqual(initialFrame);
1104+
expect(firstVisibleAddedLine(frame)).not.toBeNull();
1105+
expect(firstVisibleAddedLine(frame)).not.toBe(initialTopLine);
10961106
} finally {
10971107
await act(async () => {
10981108
setup.renderer.destroy();

test/integration/tuistory-hunk.integration.ts

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -187,6 +187,66 @@ describe("Hunk integration via tuistory", () => {
187187
}
188188
});
189189

190+
test("explicit split mode stays split after a live resize", async () => {
191+
const fixture = harness.createTwoFileRepoFixture();
192+
const session = await harness.launchHunk({
193+
args: ["diff", "--mode", "split"],
194+
cwd: fixture.dir,
195+
cols: 220,
196+
rows: 24,
197+
});
198+
199+
try {
200+
const wide = await session.waitForText(/View\s+Navigate\s+Theme\s+Agent\s+Help/, {
201+
timeout: 15_000,
202+
});
203+
204+
expect(harness.countMatches(wide, /alpha\.ts/g)).toBeGreaterThanOrEqual(2);
205+
expect(wide).toMatch(/.*/);
206+
207+
session.resize({ cols: 140, rows: 24 });
208+
const tight = await harness.waitForSnapshot(
209+
session,
210+
(text) => /.*/.test(text) && harness.countMatches(text, /alpha\.ts/g) === 1,
211+
5_000,
212+
);
213+
214+
expect(tight).toContain("betaValue = 1");
215+
} finally {
216+
session.close();
217+
}
218+
});
219+
220+
test("explicit stack mode stays stacked after a live resize", async () => {
221+
const fixture = harness.createTwoFileRepoFixture();
222+
const session = await harness.launchHunk({
223+
args: ["diff", "--mode", "stack"],
224+
cwd: fixture.dir,
225+
cols: 140,
226+
rows: 24,
227+
});
228+
229+
try {
230+
const narrow = await session.waitForText(/View\s+Navigate\s+Theme\s+Agent\s+Help/, {
231+
timeout: 15_000,
232+
});
233+
234+
expect(harness.countMatches(narrow, /alpha\.ts/g)).toBe(1);
235+
expect(narrow).not.toMatch(/.*/);
236+
237+
session.resize({ cols: 220, rows: 24 });
238+
const wide = await harness.waitForSnapshot(
239+
session,
240+
(text) => !/.*/.test(text) && harness.countMatches(text, /alpha\.ts/g) >= 2,
241+
5_000,
242+
);
243+
244+
expect(wide).toContain("1 - export const alpha = 1;");
245+
} finally {
246+
session.close();
247+
}
248+
});
249+
190250
test("filter focus narrows the visible review stream in the live app", async () => {
191251
const fixture = harness.createTwoFileRepoFixture();
192252
const session = await harness.launchHunk({

0 commit comments

Comments
 (0)