pi-odd-worktree 3.11.0 → 3.11.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/extensions/odd-worktree-tools.ts +81 -39
- package/lib/gh-prs.js +4 -1
- package/lib/issue-preview.js +53 -10
- package/lib/issues-view.js +55 -21
- package/lib/pr-preview.js +36 -5
- package/lib/prs-view.js +398 -65
- package/package.json +1 -1
- package/tools/gh-prs.test.js +5 -1
- package/tools/issue-preview.test.js +113 -0
- package/tools/issues-command.test.js +8 -5
- package/tools/issues-view.test.js +130 -0
- package/tools/pr-preview.test.js +134 -0
- package/tools/prs-command.test.js +49 -0
- package/tools/prs-view.test.js +350 -5
package/tools/prs-view.test.js
CHANGED
|
@@ -116,6 +116,7 @@ function makeView(opts = {}) {
|
|
|
116
116
|
|| ((number) => ({ ok: true, pullRequest: pullRequest(number), comments: [] })),
|
|
117
117
|
loadLabels: opts.loadLabels,
|
|
118
118
|
loadAssignees: opts.loadAssignees,
|
|
119
|
+
loadIssueCandidates: opts.loadIssueCandidates,
|
|
119
120
|
permissions: opts.permissions,
|
|
120
121
|
labels: opts.labels,
|
|
121
122
|
actions,
|
|
@@ -162,6 +163,23 @@ function deferred() {
|
|
|
162
163
|
return { promise, resolve };
|
|
163
164
|
}
|
|
164
165
|
|
|
166
|
+
// T20: the linked-issues candidate seam. `pages` is one entry per read, each
|
|
167
|
+
// with the rows it answers, the cursor that continues AFTER it, and whether the
|
|
168
|
+
// repository has more; every request is recorded. A read request with `after`
|
|
169
|
+
// continues from the page whose cursor it names.
|
|
170
|
+
function candidateSource(pages, options = {}) {
|
|
171
|
+
const calls = [];
|
|
172
|
+
const load = async (request) => {
|
|
173
|
+
calls.push(request);
|
|
174
|
+
if (typeof options.fail === 'string') return { ok: false, error: options.fail };
|
|
175
|
+
const after = request.after == null ? null : request.after;
|
|
176
|
+
const at = after === null ? 0 : pages.findIndex((page) => page.cursor === after) + 1;
|
|
177
|
+
const page = pages[at] || { rows: [], hasMore: false, cursor: null };
|
|
178
|
+
return { ok: true, rows: page.rows, hasMore: page.hasMore === true, cursor: page.cursor ?? null };
|
|
179
|
+
};
|
|
180
|
+
return { load, calls };
|
|
181
|
+
}
|
|
182
|
+
|
|
165
183
|
// S3: the reader asks view-layout for the smaller 30% list share, so every
|
|
166
184
|
// geometry helper here reads the same allocation the view paints.
|
|
167
185
|
function readerPanes(width) {
|
|
@@ -1016,31 +1034,235 @@ describe('prs view writes (S2)', () => {
|
|
|
1016
1034
|
test('i edits the linked issues as add/remove deltas', async () => {
|
|
1017
1035
|
const applied = [];
|
|
1018
1036
|
const source = pageSource({ mine: [pullRequest(6)], review: [], involved: [] });
|
|
1037
|
+
// T20: `n` opens the candidate list, so the added number is PICKED there and
|
|
1038
|
+
// never typed into a bare field.
|
|
1039
|
+
const candidates = candidateSource([{
|
|
1040
|
+
rows: [
|
|
1041
|
+
{ number: 12, title: 'Twelve', state: 'open' },
|
|
1042
|
+
{ number: 14, title: 'Fourteen', state: 'open' },
|
|
1043
|
+
{ number: 77, title: 'Seventy seven', state: 'open' },
|
|
1044
|
+
],
|
|
1045
|
+
hasMore: false,
|
|
1046
|
+
cursor: null,
|
|
1047
|
+
}]);
|
|
1019
1048
|
const { view } = makeView({
|
|
1020
1049
|
loadPullRequestPage: source.load,
|
|
1021
1050
|
loadPullRequest: (number) => ({ ok: true, pullRequest: pullRequest(number, { permissions: EDITABLE }), comments: [] }),
|
|
1051
|
+
loadIssueCandidates: candidates.load,
|
|
1022
1052
|
actions: { editLinkedIssues: (number, delta) => { applied.push({ number, delta }); return { ok: true }; } },
|
|
1023
1053
|
});
|
|
1024
1054
|
await tick();
|
|
1025
1055
|
view.handleInput('i');
|
|
1056
|
+
await tick();
|
|
1026
1057
|
assert.equal(view.state.mode, 'linkedIssues');
|
|
1027
1058
|
let pane = rightOf(view, 150);
|
|
1028
|
-
assert.match(pane, /\[x\] #12/);
|
|
1029
|
-
assert.match(pane, /\[x\] #14/);
|
|
1059
|
+
assert.match(pane, /\[x\] #12 Tw/);
|
|
1060
|
+
assert.match(pane, /\[x\] #14 Fo/);
|
|
1030
1061
|
view.handleInput('down');
|
|
1031
1062
|
view.handleInput('space');
|
|
1032
1063
|
view.handleInput('n');
|
|
1033
|
-
|
|
1034
|
-
view.handleInput('
|
|
1064
|
+
await tick();
|
|
1065
|
+
view.handleInput('down');
|
|
1066
|
+
view.handleInput('down');
|
|
1067
|
+
view.handleInput('space');
|
|
1035
1068
|
view.handleInput('enter');
|
|
1036
1069
|
pane = rightOf(view, 150);
|
|
1037
|
-
assert.match(pane, /\[x\] #77/, 'the
|
|
1070
|
+
assert.match(pane, /\[x\] #77 Se/, 'the picked number is part of the draft');
|
|
1038
1071
|
view.handleInput('ctrl+s');
|
|
1039
1072
|
await tick();
|
|
1040
1073
|
assert.deepEqual(applied, [{ number: 6, delta: { add: [77], remove: [14] } }]);
|
|
1041
1074
|
assert.equal(view.state.mode, 'list');
|
|
1042
1075
|
});
|
|
1043
1076
|
|
|
1077
|
+
test('T20: the linked toggles name each issue by number and title', async () => {
|
|
1078
|
+
const source = pageSource({ mine: [pullRequest(6)], review: [], involved: [] });
|
|
1079
|
+
const candidates = candidateSource([{
|
|
1080
|
+
rows: [
|
|
1081
|
+
{ number: 61, title: 'TEMP: rail check 1', state: 'open' },
|
|
1082
|
+
{ number: 77, title: 'Another linked issue', state: 'open' },
|
|
1083
|
+
],
|
|
1084
|
+
hasMore: false,
|
|
1085
|
+
cursor: null,
|
|
1086
|
+
}]);
|
|
1087
|
+
const { view } = makeView({
|
|
1088
|
+
loadPullRequestPage: source.load,
|
|
1089
|
+
loadPullRequest: (number) => ({
|
|
1090
|
+
ok: true,
|
|
1091
|
+
pullRequest: pullRequest(number, { permissions: EDITABLE, linkedIssues: [61, 77] }),
|
|
1092
|
+
comments: [],
|
|
1093
|
+
}),
|
|
1094
|
+
loadIssueCandidates: candidates.load,
|
|
1095
|
+
});
|
|
1096
|
+
await tick();
|
|
1097
|
+
view.handleInput('i');
|
|
1098
|
+
await tick();
|
|
1099
|
+
const pane = rightOf(view, 150);
|
|
1100
|
+
assert.match(pane, /\[x\] #61 TEMP: rail check 1/, 'the toggle is `#N title`, never a bare number');
|
|
1101
|
+
assert.match(pane, /\[x\] #77 Another linked issue/);
|
|
1102
|
+
assert.equal(candidates.calls.length, 1, 'the titles are read once when the editor opens');
|
|
1103
|
+
assert.deepEqual(candidates.calls[0], { after: null, pageSize: 18 });
|
|
1104
|
+
});
|
|
1105
|
+
|
|
1106
|
+
test('T20: n lists the repository issues with the linked ones first and checked', async () => {
|
|
1107
|
+
const source = pageSource({ mine: [pullRequest(6)], review: [], involved: [] });
|
|
1108
|
+
// The seam answers hotspots first; the linked numbers must still come first.
|
|
1109
|
+
const candidates = candidateSource([{
|
|
1110
|
+
rows: [
|
|
1111
|
+
{ number: 20, title: 'Newest open issue', state: 'open' },
|
|
1112
|
+
{ number: 12, title: 'Twelve', state: 'open' },
|
|
1113
|
+
{ number: 14, title: 'Fourteen', state: 'open' },
|
|
1114
|
+
],
|
|
1115
|
+
hasMore: false,
|
|
1116
|
+
cursor: null,
|
|
1117
|
+
}]);
|
|
1118
|
+
const { view } = makeView({
|
|
1119
|
+
loadPullRequestPage: source.load,
|
|
1120
|
+
loadPullRequest: (number) => ({ ok: true, pullRequest: pullRequest(number, { permissions: EDITABLE }), comments: [] }),
|
|
1121
|
+
loadIssueCandidates: candidates.load,
|
|
1122
|
+
});
|
|
1123
|
+
await tick();
|
|
1124
|
+
view.handleInput('i');
|
|
1125
|
+
await tick();
|
|
1126
|
+
view.handleInput('n');
|
|
1127
|
+
await tick();
|
|
1128
|
+
const pane = rightRows(view, 150).join('\n');
|
|
1129
|
+
assert.match(pane, /\[x\] #12 Twelve/);
|
|
1130
|
+
assert.match(pane, /\[x\] #14 Fourteen/);
|
|
1131
|
+
assert.match(pane, /\[ \] #20 Newest open issue/);
|
|
1132
|
+
const linkedAt = pane.indexOf('[x] #12');
|
|
1133
|
+
const otherAt = pane.indexOf('[ ] #20');
|
|
1134
|
+
assert.ok(linkedAt >= 0 && otherAt > linkedAt, 'the linked issues are painted before the rest');
|
|
1135
|
+
});
|
|
1136
|
+
|
|
1137
|
+
test('T20: the candidate list reads the next page as it scrolls', async () => {
|
|
1138
|
+
const source = pageSource({ mine: [pullRequest(6)], review: [], involved: [] });
|
|
1139
|
+
const row = (number) => ({ number, title: `Issue ${number}`, state: 'open' });
|
|
1140
|
+
const candidates = candidateSource([
|
|
1141
|
+
{ rows: [1, 2, 3, 4].map(row), hasMore: true, cursor: 'c4' },
|
|
1142
|
+
{ rows: [5, 6, 7, 8].map(row), hasMore: false, cursor: null },
|
|
1143
|
+
]);
|
|
1144
|
+
const { view } = makeView({
|
|
1145
|
+
loadPullRequestPage: source.load,
|
|
1146
|
+
loadPullRequest: (number) => ({ ok: true, pullRequest: pullRequest(number, { permissions: EDITABLE, linkedIssues: [] }), comments: [] }),
|
|
1147
|
+
loadIssueCandidates: candidates.load,
|
|
1148
|
+
rows: 10,
|
|
1149
|
+
});
|
|
1150
|
+
await tick();
|
|
1151
|
+
view.handleInput('i');
|
|
1152
|
+
await tick();
|
|
1153
|
+
view.handleInput('n');
|
|
1154
|
+
await tick();
|
|
1155
|
+
assert.equal(candidates.calls.length, 1, 'the editor open read the first page once');
|
|
1156
|
+
assert.equal(candidates.calls[0].after, null);
|
|
1157
|
+
assert.equal(candidates.calls[0].pageSize, 4, 'a page is the pane row budget');
|
|
1158
|
+
view.handleInput('ctrl+j');
|
|
1159
|
+
await tick();
|
|
1160
|
+
assert.equal(candidates.calls.length, 2, 'scrolling down reads the next page');
|
|
1161
|
+
assert.equal(candidates.calls[1].after, 'c4', 'the continuation is the previous page cursor');
|
|
1162
|
+
assert.match(rightOf(view, 150, 10), /#5 Issue 5/, 'the next page joins the list');
|
|
1163
|
+
});
|
|
1164
|
+
|
|
1165
|
+
test('T20: space toggles a candidate, enter keeps it and esc discards it', async () => {
|
|
1166
|
+
const source = pageSource({ mine: [pullRequest(6)], review: [], involved: [] });
|
|
1167
|
+
const candidates = candidateSource([{
|
|
1168
|
+
rows: [
|
|
1169
|
+
{ number: 12, title: 'Twelve', state: 'open' },
|
|
1170
|
+
{ number: 20, title: 'Twenty', state: 'open' },
|
|
1171
|
+
],
|
|
1172
|
+
hasMore: false,
|
|
1173
|
+
cursor: null,
|
|
1174
|
+
}]);
|
|
1175
|
+
const { view } = makeView({
|
|
1176
|
+
loadPullRequestPage: source.load,
|
|
1177
|
+
loadPullRequest: (number) => ({ ok: true, pullRequest: pullRequest(number, { permissions: EDITABLE, linkedIssues: [12] }), comments: [] }),
|
|
1178
|
+
loadIssueCandidates: candidates.load,
|
|
1179
|
+
});
|
|
1180
|
+
await tick();
|
|
1181
|
+
view.handleInput('i');
|
|
1182
|
+
await tick();
|
|
1183
|
+
view.handleInput('n');
|
|
1184
|
+
await tick();
|
|
1185
|
+
view.handleInput('down');
|
|
1186
|
+
view.handleInput('space');
|
|
1187
|
+
assert.match(rightOf(view, 150), /\[x\] #20 Twenty/, 'space toggles the focused row');
|
|
1188
|
+
view.handleInput('enter');
|
|
1189
|
+
let pane = rightOf(view, 150);
|
|
1190
|
+
assert.match(pane, /\[x\] #12 Twelve/);
|
|
1191
|
+
assert.match(pane, /\[x\] #20 Twenty/, 'enter keeps the selection back in the toggles');
|
|
1192
|
+
// A second, fresh draft: the list's own pick is discarded on esc.
|
|
1193
|
+
view.handleInput('escape');
|
|
1194
|
+
view.handleInput('i');
|
|
1195
|
+
await tick();
|
|
1196
|
+
view.handleInput('n');
|
|
1197
|
+
await tick();
|
|
1198
|
+
view.handleInput('down');
|
|
1199
|
+
view.handleInput('space');
|
|
1200
|
+
assert.match(rightOf(view, 150), /\[x\] #20 Twenty/);
|
|
1201
|
+
view.handleInput('escape');
|
|
1202
|
+
pane = rightOf(view, 150);
|
|
1203
|
+
assert.match(pane, /\[x\] #12 Twelve/);
|
|
1204
|
+
assert.doesNotMatch(pane, /#20/, 'esc leaves the list without keeping the pick');
|
|
1205
|
+
});
|
|
1206
|
+
|
|
1207
|
+
test('T20: a failed candidate read keeps the toggles and paints the error', async () => {
|
|
1208
|
+
const source = pageSource({ mine: [pullRequest(6)], review: [], involved: [] });
|
|
1209
|
+
const candidates = candidateSource([], { fail: 'rate limited' });
|
|
1210
|
+
const { view } = makeView({
|
|
1211
|
+
loadPullRequestPage: source.load,
|
|
1212
|
+
loadPullRequest: (number) => ({ ok: true, pullRequest: pullRequest(number, { permissions: EDITABLE }), comments: [] }),
|
|
1213
|
+
loadIssueCandidates: candidates.load,
|
|
1214
|
+
});
|
|
1215
|
+
await tick();
|
|
1216
|
+
view.handleInput('i');
|
|
1217
|
+
await tick();
|
|
1218
|
+
let pane = rightOf(view, 150);
|
|
1219
|
+
assert.match(pane, /\[x\] #12/);
|
|
1220
|
+
assert.match(pane, /\[x\] #14/);
|
|
1221
|
+
assert.match(pane, /issues unreadable: rate limited/);
|
|
1222
|
+
view.handleInput('n');
|
|
1223
|
+
await tick();
|
|
1224
|
+
pane = rightOf(view, 150);
|
|
1225
|
+
assert.match(pane, /issues unreadable: rate limited/);
|
|
1226
|
+
assert.match(pane, /\[x\] #12/, 'the linked toggles are still part of the draft');
|
|
1227
|
+
view.handleInput('escape');
|
|
1228
|
+
pane = rightOf(view, 150);
|
|
1229
|
+
assert.match(pane, /\[x\] #12/);
|
|
1230
|
+
});
|
|
1231
|
+
|
|
1232
|
+
test('T20: picked candidates save ONE delta and never duplicate a linked number', async () => {
|
|
1233
|
+
const applied = [];
|
|
1234
|
+
const source = pageSource({ mine: [pullRequest(6)], review: [], involved: [] });
|
|
1235
|
+
const candidates = candidateSource([{
|
|
1236
|
+
rows: [
|
|
1237
|
+
{ number: 12, title: 'Twelve', state: 'open' },
|
|
1238
|
+
{ number: 20, title: 'Twenty', state: 'open' },
|
|
1239
|
+
],
|
|
1240
|
+
hasMore: false,
|
|
1241
|
+
cursor: null,
|
|
1242
|
+
}]);
|
|
1243
|
+
const { view } = makeView({
|
|
1244
|
+
loadPullRequestPage: source.load,
|
|
1245
|
+
loadPullRequest: (number) => ({ ok: true, pullRequest: pullRequest(number, { permissions: EDITABLE, linkedIssues: [12] }), comments: [] }),
|
|
1246
|
+
loadIssueCandidates: candidates.load,
|
|
1247
|
+
actions: { editLinkedIssues: (number, delta) => { applied.push({ number, delta }); return { ok: true }; } },
|
|
1248
|
+
});
|
|
1249
|
+
await tick();
|
|
1250
|
+
view.handleInput('i');
|
|
1251
|
+
await tick();
|
|
1252
|
+
view.handleInput('n');
|
|
1253
|
+
await tick();
|
|
1254
|
+
view.handleInput('space');
|
|
1255
|
+
view.handleInput('space');
|
|
1256
|
+
view.handleInput('down');
|
|
1257
|
+
view.handleInput('space');
|
|
1258
|
+
view.handleInput('space');
|
|
1259
|
+
view.handleInput('space');
|
|
1260
|
+
view.handleInput('enter');
|
|
1261
|
+
view.handleInput('ctrl+s');
|
|
1262
|
+
await tick();
|
|
1263
|
+
assert.deepEqual(applied, [{ number: 6, delta: { add: [20], remove: [] } }]);
|
|
1264
|
+
});
|
|
1265
|
+
|
|
1044
1266
|
test('o opens the pull request on the web and r asks the list to be read again', async () => {
|
|
1045
1267
|
const opened = [];
|
|
1046
1268
|
const source = pageSource({ mine: [pullRequest(8)], review: [], involved: [] });
|
|
@@ -1460,3 +1682,126 @@ describe('prs view editors re-check their capability at save time (S2)', () => {
|
|
|
1460
1682
|
});
|
|
1461
1683
|
}
|
|
1462
1684
|
});
|
|
1685
|
+
|
|
1686
|
+
// S6 follow-up: the same link geometry answers the pointer. Pi's TUI delivers
|
|
1687
|
+
// `type: "move"` events to `handleMouse`, so hovering a linked issue number
|
|
1688
|
+
// paints exactly that number in the role the rail gives a hovered row, moving
|
|
1689
|
+
// off clears it, and a repaint happens only when the target actually changes.
|
|
1690
|
+
describe('S6: a move over a linked issue number highlights it', () => {
|
|
1691
|
+
// A theme that RECORDS which role each string was painted with and paints
|
|
1692
|
+
// every role with its own SGR code, so a frame can be read for the role
|
|
1693
|
+
// behind a token instead of an eyeballed colour.
|
|
1694
|
+
const ROLE_SGR = { accent: 96, customMessageLabel: 33, muted: 90, dim: 2, border: 34, error: 91, text: 39 };
|
|
1695
|
+
function recordingTheme() {
|
|
1696
|
+
const calls = [];
|
|
1697
|
+
const code = (role) => ROLE_SGR[role] ?? 95;
|
|
1698
|
+
return {
|
|
1699
|
+
calls,
|
|
1700
|
+
fg(role, text) {
|
|
1701
|
+
calls.push({ role, text: String(text) });
|
|
1702
|
+
return `\x1b[${code(role)}m${text}\x1b[0m`;
|
|
1703
|
+
},
|
|
1704
|
+
bold(text) {
|
|
1705
|
+
calls.push({ role: 'bold', text: String(text) });
|
|
1706
|
+
return `\x1b[1m${text}\x1b[22m`;
|
|
1707
|
+
},
|
|
1708
|
+
bg(role, text) {
|
|
1709
|
+
calls.push({ role: `bg:${role}`, text: String(text) });
|
|
1710
|
+
return String(text);
|
|
1711
|
+
},
|
|
1712
|
+
};
|
|
1713
|
+
}
|
|
1714
|
+
|
|
1715
|
+
function moveMouse(view, cell, offset = 0) {
|
|
1716
|
+
return view.handleMouse({
|
|
1717
|
+
type: 'move',
|
|
1718
|
+
button: 'none',
|
|
1719
|
+
x: cell.x + offset,
|
|
1720
|
+
y: cell.y,
|
|
1721
|
+
width: cell.widthCells,
|
|
1722
|
+
height: cell.rows,
|
|
1723
|
+
});
|
|
1724
|
+
}
|
|
1725
|
+
|
|
1726
|
+
function hoverView() {
|
|
1727
|
+
const theme = recordingTheme();
|
|
1728
|
+
const opened = [];
|
|
1729
|
+
const source = pageSource({ mine: [pullRequest(87)], review: [], involved: [] });
|
|
1730
|
+
const made = makeView({
|
|
1731
|
+
loadPullRequestPage: source.load,
|
|
1732
|
+
theme,
|
|
1733
|
+
actions: { openLinked: (target) => opened.push(target) },
|
|
1734
|
+
});
|
|
1735
|
+
return { view: made.view, paints: made.paints, theme, opened };
|
|
1736
|
+
}
|
|
1737
|
+
|
|
1738
|
+
// The roles the LAST render asked for, so an assertion is about this frame.
|
|
1739
|
+
function hoveredNumbers(view, theme, width = 150) {
|
|
1740
|
+
const mark = theme.calls.length;
|
|
1741
|
+
const lines = view.render(width);
|
|
1742
|
+
const roles = theme.calls.slice(mark)
|
|
1743
|
+
.filter((call) => call.role === 'accent' && /^#\d+$/.test(call.text))
|
|
1744
|
+
.map((call) => call.text);
|
|
1745
|
+
return { roles, lines };
|
|
1746
|
+
}
|
|
1747
|
+
|
|
1748
|
+
test('a move over one number paints exactly that range, and moving off clears it', async () => {
|
|
1749
|
+
const { view, theme } = hoverView();
|
|
1750
|
+
await tick();
|
|
1751
|
+
const linked = paneCell(view, 150, '#12');
|
|
1752
|
+
assert.deepEqual(moveMouse(view, linked), { handled: true, render: true },
|
|
1753
|
+
'the move is consumed and asks for a repaint');
|
|
1754
|
+
|
|
1755
|
+
let hovered = hoveredNumbers(view, theme);
|
|
1756
|
+
assert.deepEqual(hovered.roles, ['#12'], 'only the hovered number takes the hover role');
|
|
1757
|
+
const row = hovered.lines.find((line) => strip(line).includes('linked issues:'));
|
|
1758
|
+
assert.ok(row.includes('\x1b[96m#12'), 'the hovered number is painted with the accent role');
|
|
1759
|
+
assert.ok(!row.includes('\x1b[96m#14'), 'the other number keeps its plain text');
|
|
1760
|
+
assert.match(strip(row), /linked issues: #12, #14/, 'painting never changes the row the click expects');
|
|
1761
|
+
|
|
1762
|
+
const off = paneCell(view, 150, 'linked issues:');
|
|
1763
|
+
assert.deepEqual(moveMouse(view, off), { handled: true, render: true },
|
|
1764
|
+
'moving onto the row label is a change of target');
|
|
1765
|
+
hovered = hoveredNumbers(view, theme);
|
|
1766
|
+
assert.deepEqual(hovered.roles, [], 'nothing is highlighted once the pointer leaves the number');
|
|
1767
|
+
});
|
|
1768
|
+
|
|
1769
|
+
test('a move to another number moves the highlight with it', async () => {
|
|
1770
|
+
const { view, theme } = hoverView();
|
|
1771
|
+
await tick();
|
|
1772
|
+
assert.deepEqual(moveMouse(view, paneCell(view, 150, '#12')), { handled: true, render: true });
|
|
1773
|
+
assert.deepEqual(hoveredNumbers(view, theme).roles, ['#12']);
|
|
1774
|
+
assert.deepEqual(moveMouse(view, paneCell(view, 150, '#14')), { handled: true, render: true });
|
|
1775
|
+
assert.deepEqual(hoveredNumbers(view, theme).roles, ['#14'], 'the highlight follows the pointer');
|
|
1776
|
+
});
|
|
1777
|
+
|
|
1778
|
+
test('the same target twice does not repaint, and a move outside clears the hover', async () => {
|
|
1779
|
+
const { view, theme, paints } = hoverView();
|
|
1780
|
+
await tick();
|
|
1781
|
+
const linked = paneCell(view, 150, '#12');
|
|
1782
|
+
moveMouse(view, linked);
|
|
1783
|
+
const painted = paints.length;
|
|
1784
|
+
assert.deepEqual(moveMouse(view, linked), { handled: true, render: false },
|
|
1785
|
+
'the hovered target did not change, so no repaint is asked for');
|
|
1786
|
+
assert.equal(paints.length, painted, 'and none is issued');
|
|
1787
|
+
|
|
1788
|
+
assert.deepEqual(moveMouse(view, { ...linked, x: 3 }), { handled: true, render: true },
|
|
1789
|
+
'a move onto the list column lands on no link and clears the hover');
|
|
1790
|
+
assert.deepEqual(hoveredNumbers(view, theme).roles, []);
|
|
1791
|
+
assert.deepEqual(view.handleMouse({
|
|
1792
|
+
type: 'move', button: 'none', x: linked.x, y: linked.y, width: 100, height: linked.rows,
|
|
1793
|
+
}), { handled: true, render: false }, 'a move from another frame geometry lands nowhere');
|
|
1794
|
+
});
|
|
1795
|
+
|
|
1796
|
+
test('the same geometry serves the click and the hover', async () => {
|
|
1797
|
+
const { view, opened } = hoverView();
|
|
1798
|
+
await tick();
|
|
1799
|
+
const linked = paneCell(view, 150, '#12');
|
|
1800
|
+
assert.deepEqual(moveMouse(view, linked), { handled: true, render: true });
|
|
1801
|
+
// The cell the pointer highlighted is exactly the cell that opens #12.
|
|
1802
|
+
assert.deepEqual(click(view, linked), { handled: true, render: false });
|
|
1803
|
+
assert.deepEqual(opened, [{ kind: 'issue', number: 12 }]);
|
|
1804
|
+
assert.deepEqual(moveMouse(view, linked, 3), { handled: true, render: true },
|
|
1805
|
+
'a move onto the separator clears the hover');
|
|
1806
|
+
});
|
|
1807
|
+
});
|