| | @@ -784,10 +784,15 @@ |
| 784 | 784 | |
| 785 | 785 | expect(world.reads, "the edit's read is under way").toEqual([0]) |
| 786 | 786 | |
| 787 | | - expect(await $.command.run(Fixtures.DIFF)).toEqual({ |
| 788 | | - text: 'Diff panel shown', |
| 789 | | - }) |
| 787 | + const shown = $.command.run(Fixtures.DIFF) |
| 790 | 788 | |
| 789 | + await world.clock.advance(1) |
| 790 | + |
| 791 | + expect( |
| 792 | + await shown, |
| 793 | + '/diff reads before it opens, as the edit does', |
| 794 | + ).toEqual({ text: 'Diff panel shown' }) |
| 795 | + |
| 791 | 796 | expect(await $.command.run(Fixtures.DIFF)).toEqual({ |
| 792 | 797 | text: 'Diff panel hidden', |
| 793 | 798 | }) |
| | @@ -816,8 +821,12 @@ |
| 816 | 821 | }) |
| 817 | 822 | |
| 818 | 823 | await world.clock.settle() |
| 824 | + |
| 825 | + const shown = $.command.run(Fixtures.DIFF) |
| 826 | + |
| 827 | + await world.clock.advance(1) |
| 828 | + await shown |
| 819 | 829 | await $.command.run(Fixtures.DIFF) |
| 820 | | - await $.command.run(Fixtures.DIFF) |
| 821 | 830 | await $.tool.call({ tool: 'Bash', command: 'make' }) |
| 822 | 831 | await world.clock.advance(Fixtures.SETTLE_MS) |
| 823 | 832 | |
| | @@ -843,8 +852,11 @@ |
| 843 | 852 | }) |
| 844 | 853 | |
| 845 | 854 | await world.clock.settle() |
| 846 | | - await $.command.run(Fixtures.DIFF) |
| 855 | + |
| 856 | + const shown = $.command.run(Fixtures.DIFF) |
| 857 | + |
| 847 | 858 | await world.clock.advance(Fixtures.SETTLE_MS) |
| 859 | + await shown |
| 848 | 860 | |
| 849 | 861 | expect( |
| 850 | 862 | world.opened.map(pane => pane.id), |
| | @@ -1030,6 +1042,12 @@ |
| 1030 | 1042 | ).toEqual(['diff']) |
| 1031 | 1043 | |
| 1032 | 1044 | expect( |
| 1045 | + world.runs.map(run => Fixtures.gitWordOf(run.argv)).slice(0, 2), |
| 1046 | + 'the repository was found and read once before the open, as the ' + |
| 1047 | + 'built-in primes; nothing polls for a pane no one sees', |
| 1048 | + ).toEqual(['rev-parse --show-toplevel', 'status']) |
| 1049 | + |
| 1050 | + expect( |
| 1033 | 1051 | world.runs.map(run => Fixtures.gitWordOf(run.argv)), |
| 1034 | 1052 | 'the repository was found and read once to decide, no hunks fetched ' + |
| 1035 | 1053 | 'for a pane no one sees', |
| | @@ -1041,6 +1059,11 @@ |
| 1041 | 1059 | 'ls-files', |
| 1042 | 1060 | ]) |
| 1043 | 1061 | |
| 1062 | + expect( |
| 1063 | + world.runs.map(run => Fixtures.gitWordOf(run.argv)), |
| 1064 | + 'no HEAD poll for a withdrawn pane', |
| 1065 | + ).not.toContain(Fixtures.POLL_WORD) |
| 1066 | + |
| 1044 | 1067 | isNarrow = false |
| 1045 | 1068 | |
| 1046 | 1069 | expect( |
| | @@ -1094,6 +1117,59 @@ |
| 1094 | 1117 | ).toEqual(['diff']) |
| 1095 | 1118 | }) |
| 1096 | 1119 | |
| 1120 | + test('a docked pane opens once its first fetch settled', async ($, on) => { |
| 1121 | + const opened: string[] = [] |
| 1122 | + const clock = Fixtures.startsSession(on) |
| 1123 | + |
| 1124 | + on('process.run', async ($, e) => { |
| 1125 | + if (e.argv.includes('--shortstat')) { |
| 1126 | + await clock.sleep(Fixtures.SLOW_DIFF_MS) |
| 1127 | + } |
| 1128 | + |
| 1129 | + return { value: Fixtures.gitIn(e.argv) } |
| 1130 | + }) |
| 1131 | + |
| 1132 | + on('ui.open', ($, e) => { |
| 1133 | + opened.push(e.id) |
| 1134 | + |
| 1135 | + return { value: undefined } |
| 1136 | + }) |
| 1137 | + |
| 1138 | + on('ui.close', () => ({ value: undefined })) |
| 1139 | + on('ui.invalidate', () => ({ value: undefined })) |
| 1140 | + on('ui.render', { component: 'PromptHint' }, () => Fixtures.HINT_DRAWN) |
| 1141 | + on('session.messages', () => ({ value: [] })) |
| 1142 | + on('settings.read', () => ({ value: {} })) |
| 1143 | + on('tool.call', () => ({ result: 'edited' })) |
| 1144 | + mock.store(on) |
| 1145 | + mock.env(on, {}) |
| 1146 | + |
| 1147 | + await $.session.start(Fixtures.SESSION) |
| 1148 | + await $.ui.render(Fixtures.HINT) |
| 1149 | + |
| 1150 | + await $.tool.call({ |
| 1151 | + tool: 'Edit', |
| 1152 | + file_path: '/work/app.ts', |
| 1153 | + old_string: '1', |
| 1154 | + new_string: '2', |
| 1155 | + }) |
| 1156 | + |
| 1157 | + await clock.advance(Fixtures.SLOW_DIFF_MS - 1) |
| 1158 | + |
| 1159 | + expect(opened, 'git has not answered: no pane, no Loading frame').toEqual( |
| 1160 | + [], |
| 1161 | + ) |
| 1162 | + |
| 1163 | + await clock.advance(Fixtures.SETTLE_MS) |
| 1164 | + |
| 1165 | + expect(opened, 'the fetch settled: the pane opens filled').toEqual(['diff']) |
| 1166 | + |
| 1167 | + const drawn = Fixtures.textOf(await $.ui.render(Fixtures.PANE)) |
| 1168 | + |
| 1169 | + expect(drawn).toContain('1 file changed') |
| 1170 | + expect(drawn).not.toContain('Loading diff') |
| 1171 | + }) |
| 1172 | + |
| 1097 | 1173 | test('/clear closes the pane it finds open', async ($, on) => { |
| 1098 | 1174 | const world = Fixtures.inRepository(on) |
| 1099 | 1175 | |