pi-odd-worktree 2.1.0 → 3.0.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/README.md +54 -319
- package/extensions/odd-worktree-tools.ts +4182 -2539
- package/lib/bash-activity.js +1166 -0
- package/lib/bash-design.js +684 -0
- package/lib/bash-destructive.js +559 -0
- package/lib/bash-frame.js +205 -0
- package/lib/card-content.js +23 -0
- package/lib/card-style.js +175 -0
- package/lib/checkout-facts.js +30 -70
- package/lib/codegraph-card-preview.js +628 -0
- package/lib/codegraph-card.js +515 -0
- package/lib/codegraph-compaction.js +76 -0
- package/lib/codegraph-daemon.js +246 -0
- package/lib/codegraph-edit-sync.js +182 -0
- package/lib/codegraph-guard-target.js +337 -0
- package/lib/codegraph-guard.js +211 -0
- package/lib/codegraph-index.js +1020 -0
- package/lib/codegraph-lock.js +607 -0
- package/lib/codegraph-mcp-config.js +134 -0
- package/lib/codegraph-mcp.js +123 -0
- package/lib/codegraph-paths.js +69 -0
- package/lib/codegraph-prompt/explore.md +11 -0
- package/lib/codegraph-prompt/fix.md +6 -0
- package/lib/codegraph-prompt/generic.md +8 -0
- package/lib/codegraph-prompt/judge.md +9 -0
- package/lib/codegraph-prompt/orchestrator.md +17 -0
- package/lib/codegraph-prompt/verify.md +10 -0
- package/lib/codegraph-prompt/worker.md +7 -0
- package/lib/codegraph-role.js +55 -0
- package/lib/codegraph-rules.js +146 -0
- package/lib/codegraph-session.js +303 -383
- package/lib/codegraph-warmup.js +139 -0
- package/lib/file-card-markdown.js +141 -0
- package/lib/file-card-resolver.js +245 -0
- package/lib/file-card.js +659 -0
- package/lib/files-index.js +387 -0
- package/lib/files-insert.js +81 -0
- package/lib/files-orders.js +326 -0
- package/lib/files-picker-view.js +1421 -0
- package/lib/files-preview.js +338 -0
- package/lib/files-scope-detail.js +171 -0
- package/lib/files-scope-view.js +507 -0
- package/lib/gh-issues.js +323 -15
- package/lib/issue-preview.js +26 -7
- package/lib/issues-bash-mutation.js +206 -0
- package/lib/issues-cache-store.js +261 -0
- package/lib/issues-section.js +710 -0
- package/lib/issues-view.js +649 -52
- package/lib/odd-prompt/odd-worktrees.md +21 -0
- package/lib/odd-worktrees-prompt.js +10 -28
- package/lib/related-issues-cache.js +210 -0
- package/lib/shell-card.js +825 -0
- package/lib/skill-odd-card.js +183 -0
- package/lib/tui-paint.js +4 -5
- package/lib/warp-create-panel.js +538 -250
- package/lib/warp-create-picker.js +56 -9
- package/lib/warp-delete-confirm.js +19 -28
- package/lib/warp-selector-view.js +160 -82
- package/lib/which-command.js +90 -0
- package/lib/worktree-card.js +267 -897
- package/lib/worktree-cards.js +383 -0
- package/lib/worktree-create.js +287 -0
- package/lib/worktree-git.js +3 -3
- package/lib/worktree-guard.js +548 -0
- package/lib/worktree-hooks.js +421 -712
- package/lib/worktree-list.js +120 -0
- package/lib/worktree-registry.js +162 -879
- package/lib/{worktree-close-herdr.js → worktree-remove.js} +9 -11
- package/lib/worktree-setup-runner.js +376 -0
- package/lib/worktree-setup.js +140 -0
- package/lib/worktree-warp-busy.js +462 -85
- package/lib/worktree-warp-sessions.js +1 -2
- package/package.json +2 -2
- package/tools/bash-activity.test.js +1420 -0
- package/tools/bash-design.test.js +1093 -0
- package/tools/bash-destructive.test.js +139 -0
- package/tools/card-content.test.js +44 -0
- package/tools/card-style.test.js +298 -0
- package/tools/codegraph-card-preview.test.js +254 -0
- package/tools/codegraph-card.test.js +1080 -0
- package/tools/codegraph-compaction.test.js +378 -0
- package/tools/codegraph-daemon.test.js +248 -0
- package/tools/codegraph-edit-sync.test.js +295 -0
- package/tools/codegraph-guard-target.test.js +174 -0
- package/tools/codegraph-guard.test.js +238 -0
- package/tools/codegraph-index.test.js +1948 -0
- package/tools/codegraph-lock.test.js +932 -0
- package/tools/codegraph-mcp-config.test.js +181 -0
- package/tools/codegraph-mcp.test.js +194 -0
- package/tools/codegraph-paths.test.js +44 -0
- package/tools/codegraph-role.test.js +30 -0
- package/tools/codegraph-rules.test.js +250 -0
- package/tools/codegraph-session.test.js +660 -391
- package/tools/codegraph-warmup.test.js +316 -0
- package/tools/commands.test.js +510 -31
- package/tools/file-card-markdown.test.js +188 -0
- package/tools/file-card.test.js +1289 -0
- package/tools/files-bridge.test.js +575 -0
- package/tools/files-command.test.js +613 -0
- package/tools/files-index.test.js +473 -0
- package/tools/files-insert.test.js +139 -0
- package/tools/files-orders.test.js +597 -0
- package/tools/files-picker-view.test.js +1889 -0
- package/tools/files-preview.test.js +452 -0
- package/tools/files-scope-detail.test.js +264 -0
- package/tools/files-scope-view.test.js +614 -0
- package/tools/fixtures/card-codegraph-outputs.js +110 -0
- package/tools/fixtures/codegraph-cli-stub.js +16 -0
- package/tools/fixtures/codegraph-init-process.js +28 -0
- package/tools/fixtures/codegraph-lock-worker.js +117 -0
- package/tools/fixtures/daemon-fake.js +98 -0
- package/tools/fixtures/daemon-mcp-server.js +39 -0
- package/tools/fixtures/daemon-warmup-worker.js +12 -0
- package/tools/fixtures/load-extension.js +136 -3
- package/tools/gh-issues-feedback.test.js +31 -7
- package/tools/gh-issues.test.js +417 -1
- package/tools/issue-preview.test.js +44 -7
- package/tools/issues-bash-mutation.test.js +101 -0
- package/tools/issues-cache-store.test.js +222 -0
- package/tools/issues-command.test.js +1517 -67
- package/tools/issues-open-guard.test.js +1096 -0
- package/tools/issues-section.test.js +4235 -0
- package/tools/issues-seed-query-regression.test.js +67 -0
- package/tools/issues-view.test.js +1489 -60
- package/tools/odd-worktrees-prompt.test.js +98 -65
- package/tools/package-surface.test.js +431 -36
- package/tools/related-issues-cache.test.js +324 -0
- package/tools/shell-card.test.js +834 -0
- package/tools/skill-odd-card.test.js +200 -0
- package/tools/t5-session-identity.test.js +44 -22
- package/tools/warp-busy-guard.test.js +2565 -309
- package/tools/warp-create-panel.test.js +499 -74
- package/tools/warp-create-picker.test.js +101 -5
- package/tools/warp-delete-confirm.test.js +49 -15
- package/tools/warp-empty-session.test.js +0 -1
- package/tools/warp-fallback-regression.test.js +533 -0
- package/tools/warp-selector-view.test.js +460 -196
- package/tools/which-command.test.js +126 -0
- package/tools/worktree-card.test.js +551 -0
- package/tools/worktree-cards.test.js +845 -0
- package/tools/worktree-changes.test.js +4 -5
- package/tools/worktree-create.test.js +489 -0
- package/tools/worktree-guard.test.js +823 -0
- package/tools/worktree-hooks.test.js +905 -0
- package/tools/worktree-list.test.js +170 -0
- package/tools/worktree-registry.test.js +89 -230
- package/tools/worktree-remove-async.test.js +318 -0
- package/tools/worktree-setup-runner.test.js +276 -0
- package/tools/worktree-setup.test.js +140 -0
- package/tools/worktree-tools.test.js +419 -199
- package/lib/codegraph-commands.js +0 -165
- package/lib/odd-prompt/odd-worktrees.with-codegraph.md +0 -19
- package/lib/odd-prompt/odd-worktrees.without-codegraph.md +0 -15
- package/lib/worktree-model-result.js +0 -291
- package/tools/codegraph-commands.test.js +0 -371
- package/tools/herdr-free-create.test.js +0 -161
- package/tools/worktree-close-herdr-async.test.js +0 -204
- package/tools/worktree-odd-migration.test.js +0 -224
- package/tools/worktree-registry-cache.test.js +0 -163
- package/tools/worktree-registry-odd.test.js +0 -231
|
@@ -527,8 +527,9 @@ describe('issues view right pane', () => {
|
|
|
527
527
|
describe('round3: every tab is read at open, and a switch never refetches', { concurrency: false }, () => {
|
|
528
528
|
// The reported defect: opening Issues showed `All (0)` while the repository
|
|
529
529
|
// had open issues, and each tab refetched on every switch. The reader must
|
|
530
|
-
// read
|
|
531
|
-
// them while switching.
|
|
530
|
+
// read the three scoped buckets ONCE when it opens, show their real totals,
|
|
531
|
+
// and reuse them while switching. `All` is no tab: it is read the first time
|
|
532
|
+
// the shortcut enters it (issues-all-toggle S1/S2).
|
|
532
533
|
function serverView(extra = {}) {
|
|
533
534
|
const requests = [];
|
|
534
535
|
const queue = [];
|
|
@@ -555,11 +556,12 @@ describe('round3: every tab is read at open, and a switch never refetches', { co
|
|
|
555
556
|
entry.resolve({ ok: true, issues: numbers.map((n) => ({ ...issue(n), cursor: `c${n}` })), total, hasNextPage: false });
|
|
556
557
|
}
|
|
557
558
|
|
|
558
|
-
test('
|
|
559
|
+
test('the three scoped buckets are requested when the view opens, never All', async () => {
|
|
559
560
|
const { view, requests } = serverView();
|
|
560
561
|
view.render(120);
|
|
561
562
|
await tick();
|
|
562
|
-
assert.deepEqual(requests.map((entry) => entry.bucketId).sort(), ['
|
|
563
|
+
assert.deepEqual(requests.map((entry) => entry.bucketId).sort(), ['assigned', 'involved', 'mine'],
|
|
564
|
+
'opening the reader reads the three scoped tabs and stops (S2)');
|
|
563
565
|
});
|
|
564
566
|
|
|
565
567
|
test('an unvisited tab shows its real total instead of a false zero, and switching reads nothing', async () => {
|
|
@@ -571,24 +573,36 @@ describe('round3: every tab is read at open, and a switch never refetches', { co
|
|
|
571
573
|
answer(queue, 'mine', [1]);
|
|
572
574
|
answer(queue, 'assigned', []);
|
|
573
575
|
answer(queue, 'involved', []);
|
|
574
|
-
answer(queue, 'all', [1], 1);
|
|
575
576
|
await tick();
|
|
576
577
|
const frame = bodyOf(view, 160);
|
|
577
|
-
assert.match(frame, /All \(1\)/, `All reports the repository total: ${frame.split('\n')[2]}`);
|
|
578
578
|
assert.match(frame, /My issues \(1\)/, 'the active bucket keeps its own count');
|
|
579
|
+
assert.match(frame, /Assigned \(0\)/, 'an answered bucket names its own total');
|
|
579
580
|
const before = requests.length;
|
|
580
581
|
for (let step = 0; step < 3; step += 1) {
|
|
581
582
|
view.handleInput('tab');
|
|
582
583
|
await tick();
|
|
583
584
|
}
|
|
584
585
|
assert.equal(requests.length, before, 'switching between loaded tabs reads nothing again');
|
|
586
|
+
// S1/S2: `All` left the bar and is read when the shortcut first enters it.
|
|
587
|
+
view.handleInput('g');
|
|
588
|
+
await tick();
|
|
589
|
+
assert.deepEqual(requests.slice(before).map((entry) => entry.bucketId), ['all'],
|
|
590
|
+
'the first entry into All is what reads it');
|
|
591
|
+
answer(queue, 'all', [1], 1);
|
|
592
|
+
await tick();
|
|
593
|
+
assert.match(bodyOf(view, 160), /▸ All \(1\)/, 'All reports the repository total once it is asked for');
|
|
594
|
+
const asked = requests.length;
|
|
595
|
+
view.handleInput('g');
|
|
596
|
+
view.handleInput('g');
|
|
597
|
+
await tick();
|
|
598
|
+
assert.equal(requests.length, asked, 're-entering All reuses the page it read');
|
|
585
599
|
});
|
|
586
600
|
|
|
587
601
|
test('a bucket that has not answered yet is unknown, never a zero', async () => {
|
|
588
602
|
const { view, queue } = serverView();
|
|
589
603
|
view.render(120);
|
|
590
604
|
await tick();
|
|
591
|
-
// The active bucket answers; the other
|
|
605
|
+
// The active bucket answers; the other two are still in flight.
|
|
592
606
|
answer(queue, 'mine', [1]);
|
|
593
607
|
await tick();
|
|
594
608
|
const tabs = bodyOf(view, 160).split('\n').find((line) => line.includes('My issues')) ?? '';
|
|
@@ -1165,11 +1179,11 @@ describe('issues view detail assignees (adopted reference idea 1)', () => {
|
|
|
1165
1179
|
});
|
|
1166
1180
|
|
|
1167
1181
|
describe('issues view preview metadata (S9)', () => {
|
|
1168
|
-
test('shows every assignee, projects and
|
|
1182
|
+
test('shows every assignee, projects and the linked PR list, and omits empty metadata', async () => {
|
|
1169
1183
|
const full = issue(5, {
|
|
1170
1184
|
assignees: [{ login: 'ann' }, { login: 'bob' }],
|
|
1171
1185
|
projects: [{ title: 'Roadmap', url: 'https://example.test/p/1' }],
|
|
1172
|
-
|
|
1186
|
+
linkedPullRequests: [69, 77],
|
|
1173
1187
|
});
|
|
1174
1188
|
const rich = makeView({
|
|
1175
1189
|
pages: pagesOf([[full], [], []]),
|
|
@@ -1180,9 +1194,9 @@ describe('issues view preview metadata (S9)', () => {
|
|
|
1180
1194
|
const body = bodyOf(rich.view, 120);
|
|
1181
1195
|
assert.match(body, /assignees: ann, bob/, 'every assigned person is shown');
|
|
1182
1196
|
assert.match(body, /projects: Roadmap/, 'the associated project is shown');
|
|
1183
|
-
assert.match(body, /linked PRs:
|
|
1197
|
+
assert.match(body, /linked PRs: #69, #77/, 'every linked PR is named by number');
|
|
1184
1198
|
|
|
1185
|
-
const bare = issue(6, {
|
|
1199
|
+
const bare = issue(6, { unavailable: ['projects'] });
|
|
1186
1200
|
const empty = makeView({
|
|
1187
1201
|
pages: pagesOf([[bare], [], []]),
|
|
1188
1202
|
issues: [bare],
|
|
@@ -1191,9 +1205,9 @@ describe('issues view preview metadata (S9)', () => {
|
|
|
1191
1205
|
await tick();
|
|
1192
1206
|
const thin = bodyOf(empty.view, 120);
|
|
1193
1207
|
assert.ok(!/projects?:/i.test(thin), 'an issue without projects names none');
|
|
1194
|
-
assert.ok(!/linked PR/i.test(thin), '
|
|
1208
|
+
assert.ok(!/linked PR/i.test(thin), 'an empty linked-PR list is omitted, never rendered as "0 PR"');
|
|
1195
1209
|
assert.ok(!/read:project|scope/i.test(thin), 'no scope text leaks into the compact preview');
|
|
1196
|
-
assert.
|
|
1210
|
+
assert.ok(!/metadata/i.test(thin), 'a lost relation is never announced: the pane stays quiet about it');
|
|
1197
1211
|
});
|
|
1198
1212
|
});
|
|
1199
1213
|
|
|
@@ -1279,7 +1293,8 @@ describe('issues view comment discard confirmation (adopted reference idea 4)',
|
|
|
1279
1293
|
for (const ch of 'keep me') view.handleInput(ch);
|
|
1280
1294
|
view.handleInput('escape');
|
|
1281
1295
|
assert.equal(view.state.mode, 'comment', 'still editing after the first esc');
|
|
1282
|
-
assert.match(bodyOf(view, 100), /Discard this draft
|
|
1296
|
+
assert.match(bodyOf(view, 100), /Discard this draft\?/, 'the ask names what is at stake');
|
|
1297
|
+
assert.doesNotMatch(bodyOf(view, 100), /Discard this draft\? \(/, 'and carries no parenthetical key list (S10)');
|
|
1283
1298
|
view.handleInput('n');
|
|
1284
1299
|
assert.equal(view.state.mode, 'comment', 'n returns to editing');
|
|
1285
1300
|
assert.equal(view.state.commentText, 'keep me', 'the draft survives the round trip');
|
|
@@ -2240,7 +2255,9 @@ describe('issues close/reopen permission gate', () => {
|
|
|
2240
2255
|
await tick();
|
|
2241
2256
|
view.handleInput('l');
|
|
2242
2257
|
assert.equal(view.state.mode, 'labels', 'triage permission alone still opens the editor');
|
|
2243
|
-
|
|
2258
|
+
// S10: the title is the sub-mode's name alone; the keys are on the footer
|
|
2259
|
+
// row, and the create key follows the WRITE capability the create row does.
|
|
2260
|
+
assert.match(bodyOf(view, 120), /Labels/, 'the existing labels are listed');
|
|
2244
2261
|
const editor = bodyOf(view, 120);
|
|
2245
2262
|
assert.ok(!editor.includes('n new'), 'the editor names no create keybinding');
|
|
2246
2263
|
assert.ok(!editor.includes('create new'), 'no create row is listed');
|
|
@@ -2567,7 +2584,7 @@ describe('issues left list width, wrapping and fresh pages (S3/S5/D1/D3)', () =>
|
|
|
2567
2584
|
// Every request is a public input: the loader receives
|
|
2568
2585
|
// {bucketId, cursor, limit, query}.
|
|
2569
2586
|
describe('issues view All tab, tab cache and server search (S9/S13/S15)', () => {
|
|
2570
|
-
test('the
|
|
2587
|
+
test('the shortcut lists every open issue of the repository with no dedup', async () => {
|
|
2571
2588
|
const requests = [];
|
|
2572
2589
|
const { view } = makeView({
|
|
2573
2590
|
rows: 24,
|
|
@@ -2585,16 +2602,18 @@ describe('issues view All tab, tab cache and server search (S9/S13/S15)', () =>
|
|
|
2585
2602
|
assert.match(tabs, /▸ My issues \(1\)/, 'the default bucket is still first');
|
|
2586
2603
|
assert.match(tabs, /Assigned \(–\)/);
|
|
2587
2604
|
assert.match(tabs, /Involved \(–\)/);
|
|
2588
|
-
assert.
|
|
2605
|
+
assert.ok(!tabs.includes('All'), 'All is no longer a tab');
|
|
2589
2606
|
assert.equal(requests.length, 1, 'only the default bucket was read');
|
|
2590
2607
|
assert.equal(requests[0].bucketId, 'mine');
|
|
2591
|
-
view.handleInput('
|
|
2592
|
-
view.handleInput('tab');
|
|
2593
|
-
view.handleInput('tab');
|
|
2608
|
+
view.handleInput('g');
|
|
2594
2609
|
await tick();
|
|
2595
|
-
assert.equal(view.state.page, 3, '
|
|
2610
|
+
assert.equal(view.state.page, 3, 'the shortcut moves to the All view');
|
|
2596
2611
|
assert.equal(requests[requests.length - 1].bucketId, 'all', 'All reads the whole open repository');
|
|
2597
|
-
|
|
2612
|
+
const allTabs = strip(view.render(100)[2]);
|
|
2613
|
+
assert.match(allTabs, /▸ All \(2\)/, 'the All view counts the whole open repository');
|
|
2614
|
+
for (const label of ['My issues', 'Assigned', 'Involved']) {
|
|
2615
|
+
assert.ok(!allTabs.includes(label), `the bar reads only All: ${allTabs}`);
|
|
2616
|
+
}
|
|
2598
2617
|
const left = leftColumn(view, 100);
|
|
2599
2618
|
assert.match(left, /belt and braces/, 'an issue that also lists under My issues lists here too');
|
|
2600
2619
|
assert.match(left, /issue title 77/, 'the other open issue is listed');
|
|
@@ -2656,7 +2675,11 @@ describe('issues view All tab, tab cache and server search (S9/S13/S15)', () =>
|
|
|
2656
2675
|
assert.equal(requests.length, 1, 'typing only schedules the read');
|
|
2657
2676
|
clock.fire();
|
|
2658
2677
|
await tick();
|
|
2659
|
-
assert.
|
|
2678
|
+
assert.deepEqual(
|
|
2679
|
+
requests.slice(1).map((entry) => [entry.bucketId, entry.query]),
|
|
2680
|
+
[['mine', 'label:bug'], ['assigned', 'label:bug'], ['involved', 'label:bug']],
|
|
2681
|
+
'the settled burst reads every scoped bucket once, at the head of its own result set',
|
|
2682
|
+
);
|
|
2660
2683
|
assert.deepEqual(
|
|
2661
2684
|
requests[1],
|
|
2662
2685
|
{ bucketId: 'mine', cursor: null, limit: 18, query: 'label:bug' },
|
|
@@ -2666,15 +2689,16 @@ describe('issues view All tab, tab cache and server search (S9/S13/S15)', () =>
|
|
|
2666
2689
|
leftColumn(view, 100);
|
|
2667
2690
|
view.handleInput(']');
|
|
2668
2691
|
await tick();
|
|
2692
|
+
const append = requests.at(-1);
|
|
2669
2693
|
assert.deepEqual(
|
|
2670
|
-
|
|
2694
|
+
append,
|
|
2671
2695
|
{ bucketId: 'mine', cursor: 'q1', limit: 18, query: 'label:bug' },
|
|
2672
2696
|
'the appended read continues after the last loaded row of the same query',
|
|
2673
2697
|
);
|
|
2674
2698
|
view.handleInput('r');
|
|
2675
2699
|
await tick();
|
|
2676
2700
|
assert.deepEqual(
|
|
2677
|
-
requests
|
|
2701
|
+
requests.at(-1),
|
|
2678
2702
|
{ bucketId: 'mine', cursor: null, limit: 18, query: 'label:bug' },
|
|
2679
2703
|
'r re-reads the list from the head of the current query',
|
|
2680
2704
|
);
|
|
@@ -2700,13 +2724,19 @@ describe('issues view All tab, tab cache and server search (S9/S13/S15)', () =>
|
|
|
2700
2724
|
view.handleInput('T');
|
|
2701
2725
|
view.handleInput('a');
|
|
2702
2726
|
clock.fire();
|
|
2703
|
-
assert.deepEqual(pending.slice(1).map((entry) => entry.request.query), ['a'
|
|
2727
|
+
assert.deepEqual(pending.slice(1).map((entry) => entry.request.query), ['a', 'a', 'a'],
|
|
2728
|
+
'the settled query is read by the three scoped tabs');
|
|
2704
2729
|
view.handleInput('b');
|
|
2705
2730
|
clock.fire();
|
|
2706
|
-
assert.deepEqual(pending.slice(1).map((entry) => entry.request.query), ['a', '
|
|
2707
|
-
|
|
2731
|
+
assert.deepEqual(pending.slice(1).map((entry) => entry.request.query), ['a', 'a', 'a', 'ab', 'ab', 'ab'],
|
|
2732
|
+
'the next settled query reads its own three buckets');
|
|
2733
|
+
for (const entry of pending.filter((item) => item.request.query === 'ab')) {
|
|
2734
|
+
entry.entry.resolve(pageResult([cursorRow('n1', issue(2, { title: 'ab match' }))], { total: 1 }));
|
|
2735
|
+
}
|
|
2708
2736
|
await tick();
|
|
2709
|
-
pending
|
|
2737
|
+
for (const entry of pending.filter((item) => item.request.query === 'a')) {
|
|
2738
|
+
entry.entry.resolve(pageResult([cursorRow('o1', issue(3, { title: 'a only match' }))], { total: 1 }));
|
|
2739
|
+
}
|
|
2710
2740
|
await tick();
|
|
2711
2741
|
const left = leftColumn(view, 100);
|
|
2712
2742
|
assert.match(left, /ab match/, 'the newest query answer paints');
|
|
@@ -2771,6 +2801,483 @@ describe('issues view All tab, tab cache and server search (S9/S13/S15)', () =>
|
|
|
2771
2801
|
});
|
|
2772
2802
|
});
|
|
2773
2803
|
|
|
2804
|
+
// S1-S5/D1-D3 (issues-all-toggle): `All` leaves the tab bar and becomes a
|
|
2805
|
+
// shortcut key, so opening `/issues` reads only the three scoped buckets; a
|
|
2806
|
+
// typed filter is read by ALL three scoped tabs (each count is the FILTERED
|
|
2807
|
+
// total) and travels into `All`, whose read is the exact repository connection
|
|
2808
|
+
// when unfiltered and a search GitHub caps when filtered.
|
|
2809
|
+
describe('issues All shortcut and the filter across the scoped tabs (S1/S2/S3/S4/S5)', () => {
|
|
2810
|
+
// The buckets the extension mounts: the three scoped tabs plus the LAZY `All`
|
|
2811
|
+
// page (`lazy: true`), every read through the one cursor-page seam. Each
|
|
2812
|
+
// bucket answers a known number of rows unfiltered and filtered, so a test can
|
|
2813
|
+
// tell a FILTERED total from the unfiltered one instead of reading the same
|
|
2814
|
+
// number twice.
|
|
2815
|
+
const TOTALS = {
|
|
2816
|
+
mine: { open: 2, filtered: 1, base: 10 },
|
|
2817
|
+
assigned: { open: 1, filtered: 1, base: 20 },
|
|
2818
|
+
involved: { open: 3, filtered: 2, base: 30 },
|
|
2819
|
+
all: { open: 6, filtered: 3, base: 40 },
|
|
2820
|
+
};
|
|
2821
|
+
|
|
2822
|
+
function bucketPage(request) {
|
|
2823
|
+
const spec = TOTALS[request.bucketId] || { open: 0, filtered: 0, base: 0 };
|
|
2824
|
+
const query = String(request.query || '');
|
|
2825
|
+
const count = query === '' ? spec.open : spec.filtered;
|
|
2826
|
+
const rows = Array.from({ length: count }, (_, at) => cursorRow(
|
|
2827
|
+
`${request.bucketId}-${at}`,
|
|
2828
|
+
issue(spec.base + at, { title: `${request.bucketId} row ${at + 1}${query === '' ? '' : ` ${query}`}` }),
|
|
2829
|
+
));
|
|
2830
|
+
return pageResult(rows, { total: count });
|
|
2831
|
+
}
|
|
2832
|
+
|
|
2833
|
+
// `count` cursor rows titled `<prefix> row <n>`, so a test can tell a row of
|
|
2834
|
+
// one query from a row of another by the text it paints alone.
|
|
2835
|
+
function rowsOf(prefix, count, base = 100) {
|
|
2836
|
+
return Array.from({ length: count }, (_, at) => cursorRow(
|
|
2837
|
+
`${prefix}-${at}`,
|
|
2838
|
+
issue(base + at, { title: `${prefix} row ${at + 1}` }),
|
|
2839
|
+
));
|
|
2840
|
+
}
|
|
2841
|
+
|
|
2842
|
+
function serverView(overrides = {}) {
|
|
2843
|
+
const requests = [];
|
|
2844
|
+
const view = createIssuesView({
|
|
2845
|
+
helpers,
|
|
2846
|
+
theme: plainTheme,
|
|
2847
|
+
prefetchBuckets: true,
|
|
2848
|
+
rowsAvailable: () => 24,
|
|
2849
|
+
requestRender: () => {},
|
|
2850
|
+
done: () => {},
|
|
2851
|
+
pages: [
|
|
2852
|
+
{ id: 'mine', label: 'My issues', issues: null },
|
|
2853
|
+
{ id: 'assigned', label: 'Assigned', issues: null },
|
|
2854
|
+
{ id: 'involved', label: 'Involved', issues: null },
|
|
2855
|
+
{ id: 'all', label: 'All', issues: null, lazy: true },
|
|
2856
|
+
],
|
|
2857
|
+
loadIssuePage: (request) => {
|
|
2858
|
+
requests.push(request);
|
|
2859
|
+
return overrides.serve ? overrides.serve(request) : bucketPage(request);
|
|
2860
|
+
},
|
|
2861
|
+
loadIssue: overrides.loadIssue || ((n) => ({ ok: true, issue: issue(n), comments: [] })),
|
|
2862
|
+
loadAssignees: overrides.loadAssignees,
|
|
2863
|
+
scheduleQuery: overrides.scheduleQuery,
|
|
2864
|
+
cancelSchedule: overrides.cancelSchedule,
|
|
2865
|
+
});
|
|
2866
|
+
return { view, requests };
|
|
2867
|
+
}
|
|
2868
|
+
|
|
2869
|
+
const tabRow = (view, width = 120) => strip(view.render(width)[2]);
|
|
2870
|
+
const noteRow = (view, width = 120) => strip(view.render(width)[3]);
|
|
2871
|
+
const footerOf = (view, width = 200) => strip(view.render(width).at(-2));
|
|
2872
|
+
|
|
2873
|
+
// Type a filter, settle its debounce and leave the box, so the following keys
|
|
2874
|
+
// reach the reading interaction instead of the search widget.
|
|
2875
|
+
async function typeFilter(view, clock, text) {
|
|
2876
|
+
view.handleInput('T');
|
|
2877
|
+
for (const ch of text) view.handleInput(ch);
|
|
2878
|
+
clock.fire();
|
|
2879
|
+
view.handleInput('enter');
|
|
2880
|
+
await tick();
|
|
2881
|
+
}
|
|
2882
|
+
|
|
2883
|
+
test('the tab bar reads the three scoped tabs and never All (S1)', async () => {
|
|
2884
|
+
const { view } = serverView();
|
|
2885
|
+
view.render(120);
|
|
2886
|
+
await tick();
|
|
2887
|
+
const tabs = tabRow(view);
|
|
2888
|
+
assert.match(tabs, /▸ My issues \(2\)/, `the active scoped tab carries its own count: ${tabs}`);
|
|
2889
|
+
assert.match(tabs, /Assigned \(1\)/, 'every scoped tab keeps its count');
|
|
2890
|
+
assert.match(tabs, /Involved \(3\)/, 'the third scoped tab keeps its count');
|
|
2891
|
+
assert.ok(!/\bAll\b/.test(tabs), `All is not a tab any more: ${tabs}`);
|
|
2892
|
+
});
|
|
2893
|
+
|
|
2894
|
+
test('opening the panel reads only the three scoped buckets (S2)', async () => {
|
|
2895
|
+
const { view, requests } = serverView();
|
|
2896
|
+
view.render(120);
|
|
2897
|
+
await tick();
|
|
2898
|
+
assert.deepEqual(
|
|
2899
|
+
requests.map((entry) => entry.bucketId),
|
|
2900
|
+
['mine', 'assigned', 'involved'],
|
|
2901
|
+
'opening costs the three scoped reads and no more',
|
|
2902
|
+
);
|
|
2903
|
+
assert.ok(!requests.some((entry) => entry.bucketId === 'all'), 'the lazy All bucket is not read at open');
|
|
2904
|
+
});
|
|
2905
|
+
|
|
2906
|
+
test('the shortcut enters the All view, where the bar and the hint both say so (S1/D1)', async () => {
|
|
2907
|
+
const { view, requests } = serverView();
|
|
2908
|
+
view.render(120);
|
|
2909
|
+
await tick();
|
|
2910
|
+
assert.match(footerOf(view), /g all issues/, 'outside All the shortcut teaches what it opens');
|
|
2911
|
+
view.handleInput('g');
|
|
2912
|
+
await tick();
|
|
2913
|
+
assert.equal(view.state.page, 3, 'the shortcut moves to the All view');
|
|
2914
|
+
assert.deepEqual(
|
|
2915
|
+
requests.map((entry) => entry.bucketId),
|
|
2916
|
+
['mine', 'assigned', 'involved', 'all'],
|
|
2917
|
+
'the first entry into All is what reads it',
|
|
2918
|
+
);
|
|
2919
|
+
const tabs = tabRow(view);
|
|
2920
|
+
assert.match(tabs, /▸ All \(6\)/, `the All view names its own count: ${tabs}`);
|
|
2921
|
+
for (const label of ['My issues', 'Assigned', 'Involved']) {
|
|
2922
|
+
assert.ok(!tabs.includes(label), `the scoped tabs leave the bar inside All: ${tabs}`);
|
|
2923
|
+
}
|
|
2924
|
+
assert.match(footerOf(view), /g related issues/, 'inside All the same key says it goes back');
|
|
2925
|
+
assert.ok(!footerOf(view).includes('g all issues'), 'the outbound label is gone inside the All view');
|
|
2926
|
+
});
|
|
2927
|
+
|
|
2928
|
+
test('the same key returns to the tab that was active when the reader entered (D2)', async () => {
|
|
2929
|
+
const { view } = serverView();
|
|
2930
|
+
view.render(120);
|
|
2931
|
+
await tick();
|
|
2932
|
+
view.handleInput('tab');
|
|
2933
|
+
assert.equal(view.state.page, 1, 'Assigned is the active tab');
|
|
2934
|
+
view.handleInput('g');
|
|
2935
|
+
await tick();
|
|
2936
|
+
assert.equal(view.state.page, 3, 'the shortcut enters All from there');
|
|
2937
|
+
view.handleInput('g');
|
|
2938
|
+
await tick();
|
|
2939
|
+
assert.equal(view.state.page, 1, 'the same key returns to Assigned, not to the first tab');
|
|
2940
|
+
assert.match(tabRow(view), /▸ Assigned \(1\)/, 'and the bar says so');
|
|
2941
|
+
});
|
|
2942
|
+
|
|
2943
|
+
test('the cycling keys do nothing in the All view (S1)', async () => {
|
|
2944
|
+
const { view, requests } = serverView();
|
|
2945
|
+
view.render(120);
|
|
2946
|
+
await tick();
|
|
2947
|
+
view.handleInput('g');
|
|
2948
|
+
await tick();
|
|
2949
|
+
const asked = requests.length;
|
|
2950
|
+
for (const key of ['tab', 'shift+tab', 'left', 'right']) {
|
|
2951
|
+
view.handleInput(key);
|
|
2952
|
+
await tick();
|
|
2953
|
+
assert.equal(view.state.page, 3, `${key} never leaves the one view`);
|
|
2954
|
+
}
|
|
2955
|
+
assert.equal(requests.length, asked, 'and none of them reads another bucket');
|
|
2956
|
+
assert.match(tabRow(view), /▸ All \(6\)/, 'the bar still reads only All');
|
|
2957
|
+
});
|
|
2958
|
+
|
|
2959
|
+
test('All is read on first entry and reused when the reader comes back (S2)', async () => {
|
|
2960
|
+
const { view, requests } = serverView();
|
|
2961
|
+
view.render(120);
|
|
2962
|
+
await tick();
|
|
2963
|
+
view.handleInput('g');
|
|
2964
|
+
await tick();
|
|
2965
|
+
assert.deepEqual(
|
|
2966
|
+
requests.filter((entry) => entry.bucketId === 'all').map((entry) => entry.query),
|
|
2967
|
+
[''],
|
|
2968
|
+
'the unfiltered All read is the one connection read',
|
|
2969
|
+
);
|
|
2970
|
+
const read = requests.length;
|
|
2971
|
+
view.handleInput('g');
|
|
2972
|
+
await tick();
|
|
2973
|
+
assert.equal(view.state.page, 0, 'the shortcut returned to the tab it came from');
|
|
2974
|
+
view.handleInput('g');
|
|
2975
|
+
await tick();
|
|
2976
|
+
assert.equal(requests.length, read, 're-entering All reuses the page it already read');
|
|
2977
|
+
assert.match(leftColumn(view, 120), /all row 1/, 'and paints the rows it holds');
|
|
2978
|
+
});
|
|
2979
|
+
|
|
2980
|
+
test('the settled filter is read by the three scoped tabs and every count is the FILTERED total (S3)', async () => {
|
|
2981
|
+
const clock = manualScheduler();
|
|
2982
|
+
const { view, requests } = serverView({ scheduleQuery: clock.schedule, cancelSchedule: clock.cancel });
|
|
2983
|
+
view.render(120);
|
|
2984
|
+
await tick();
|
|
2985
|
+
const mount = requests.length;
|
|
2986
|
+
view.handleInput('T');
|
|
2987
|
+
for (const ch of 'label:bug') view.handleInput(ch);
|
|
2988
|
+
assert.equal(requests.length, mount, 'typing only schedules the read');
|
|
2989
|
+
clock.fire();
|
|
2990
|
+
await tick();
|
|
2991
|
+
assert.deepEqual(
|
|
2992
|
+
requests.slice(mount).map((entry) => [entry.bucketId, entry.query]),
|
|
2993
|
+
[['mine', 'label:bug'], ['assigned', 'label:bug'], ['involved', 'label:bug']],
|
|
2994
|
+
'the settled filter is read by all three scoped tabs, not only the one on screen',
|
|
2995
|
+
);
|
|
2996
|
+
const tabs = tabRow(view);
|
|
2997
|
+
assert.match(tabs, /▸ My issues \(1\)/, `the active tab names the FILTERED total: ${tabs}`);
|
|
2998
|
+
assert.match(tabs, /Assigned \(1\)/, 'the tab that answered names its own filtered total');
|
|
2999
|
+
assert.match(tabs, /Involved \(2\)/, 'a tab that is not on screen carries the filtered total too');
|
|
3000
|
+
assert.ok(!tabs.includes('Involved (3)'), 'no unfiltered number survives next to the filtered list');
|
|
3001
|
+
assert.match(leftColumn(view, 120), /mine row 1 label:bug/, 'the rows on screen match the filter');
|
|
3002
|
+
});
|
|
3003
|
+
|
|
3004
|
+
test('the filter survives a tab switch and travels into All (S4)', async () => {
|
|
3005
|
+
const clock = manualScheduler();
|
|
3006
|
+
const { view, requests } = serverView({ scheduleQuery: clock.schedule, cancelSchedule: clock.cancel });
|
|
3007
|
+
view.render(120);
|
|
3008
|
+
await tick();
|
|
3009
|
+
await typeFilter(view, clock, 'bug');
|
|
3010
|
+
view.handleInput('tab');
|
|
3011
|
+
await tick();
|
|
3012
|
+
assert.match(tabRow(view), /▸ Assigned \(1\)/, 'the switched-to tab keeps the filtered total');
|
|
3013
|
+
assert.match(tabRow(view), /Involved \(2\)/, 'and so does the tab next to it');
|
|
3014
|
+
assert.match(strip(view.render(120)[1]), /› bug/, 'the filter survives the tab switch');
|
|
3015
|
+
const before = requests.length;
|
|
3016
|
+
view.handleInput('g');
|
|
3017
|
+
await tick();
|
|
3018
|
+
assert.deepEqual(
|
|
3019
|
+
requests.slice(before).map((entry) => [entry.bucketId, entry.query]),
|
|
3020
|
+
[['all', 'bug']],
|
|
3021
|
+
'the All read is issued WITH the filter',
|
|
3022
|
+
);
|
|
3023
|
+
});
|
|
3024
|
+
|
|
3025
|
+
test('a filter change invalidates the All page so it never shows another filter rows (D3)', async () => {
|
|
3026
|
+
const clock = manualScheduler();
|
|
3027
|
+
const { view, requests } = serverView({ scheduleQuery: clock.schedule, cancelSchedule: clock.cancel });
|
|
3028
|
+
view.render(120);
|
|
3029
|
+
await tick();
|
|
3030
|
+
view.handleInput('g');
|
|
3031
|
+
await tick();
|
|
3032
|
+
assert.match(leftColumn(view, 120), /all row 1\b/, 'the unfiltered All lists the connection rows');
|
|
3033
|
+
view.handleInput('g');
|
|
3034
|
+
await tick();
|
|
3035
|
+
assert.equal(view.state.page, 0, 'back on the first scoped tab');
|
|
3036
|
+
await typeFilter(view, clock, 'bug');
|
|
3037
|
+
const before = requests.length;
|
|
3038
|
+
view.handleInput('g');
|
|
3039
|
+
await tick();
|
|
3040
|
+
assert.deepEqual(
|
|
3041
|
+
requests.slice(before).map((entry) => [entry.bucketId, entry.query]),
|
|
3042
|
+
[['all', 'bug']],
|
|
3043
|
+
'the All page is read again, with the filter that invalidated it',
|
|
3044
|
+
);
|
|
3045
|
+
const left = leftColumn(view, 120);
|
|
3046
|
+
assert.match(left, /all row 1 bug/, 'the filtered rows are the rows on screen');
|
|
3047
|
+
assert.ok(!/all row 4/.test(left), 'no row of the previous filter survives in the All view');
|
|
3048
|
+
});
|
|
3049
|
+
|
|
3050
|
+
test('a filtered All reads through the search path and never claims an exact total (S5)', async () => {
|
|
3051
|
+
const clock = manualScheduler();
|
|
3052
|
+
const { view, requests } = serverView({ scheduleQuery: clock.schedule, cancelSchedule: clock.cancel });
|
|
3053
|
+
view.render(120);
|
|
3054
|
+
await tick();
|
|
3055
|
+
view.handleInput('g');
|
|
3056
|
+
await tick();
|
|
3057
|
+
assert.match(tabRow(view), /▸ All \(6\)/, 'the unfiltered connection total is exact, with no mark');
|
|
3058
|
+
assert.match(noteRow(view), /via connection/, 'the frame names the read on screen');
|
|
3059
|
+
const before = requests.length;
|
|
3060
|
+
view.handleInput('T');
|
|
3061
|
+
for (const ch of 'bug') view.handleInput(ch);
|
|
3062
|
+
clock.fire();
|
|
3063
|
+
await tick();
|
|
3064
|
+
assert.equal(requests.at(-1).bucketId, 'all', 'the All view re-reads itself under the filter');
|
|
3065
|
+
assert.equal(requests.at(-1).query, 'bug', 'and the read carries the filter');
|
|
3066
|
+
assert.ok(requests.length > before, 'the filtered All read went out');
|
|
3067
|
+
assert.match(tabRow(view), /▸ All \(3\+\)/, 'a filtered All never claims an exact total');
|
|
3068
|
+
assert.match(noteRow(view), /via search/, 'and the frame says which read is on screen');
|
|
3069
|
+
});
|
|
3070
|
+
|
|
3071
|
+
test('clearing the filter re-reads everything that is loaded (S4/S5)', async () => {
|
|
3072
|
+
const clock = manualScheduler();
|
|
3073
|
+
const { view, requests } = serverView({ scheduleQuery: clock.schedule, cancelSchedule: clock.cancel });
|
|
3074
|
+
view.render(120);
|
|
3075
|
+
await tick();
|
|
3076
|
+
view.handleInput('g');
|
|
3077
|
+
await tick();
|
|
3078
|
+
await typeFilter(view, clock, 'bug');
|
|
3079
|
+
view.handleInput('T');
|
|
3080
|
+
const before = requests.length;
|
|
3081
|
+
view.handleInput('delete');
|
|
3082
|
+
assert.equal(requests.length, before, 'clearing only schedules the read, like any query edit');
|
|
3083
|
+
clock.fire();
|
|
3084
|
+
await tick();
|
|
3085
|
+
assert.deepEqual(
|
|
3086
|
+
requests.slice(before).map((entry) => [entry.bucketId, entry.query]),
|
|
3087
|
+
[['mine', ''], ['assigned', ''], ['involved', ''], ['all', '']],
|
|
3088
|
+
'clearing the filter reads every bucket that is loaded, the All view included',
|
|
3089
|
+
);
|
|
3090
|
+
assert.match(tabRow(view), /▸ All \(6\)/, 'the exact connection total comes back');
|
|
3091
|
+
assert.match(noteRow(view), /via connection/, 'and the frame names the read again');
|
|
3092
|
+
});
|
|
3093
|
+
|
|
3094
|
+
// S5: the `+` means "inexact or truncated", so it may ONLY mark a fact that
|
|
3095
|
+
// makes the total inexact. A connection read reports the exact total even
|
|
3096
|
+
// when it arrives with more pages still to page through; a capped search, a
|
|
3097
|
+
// bucket whose read says it is bounded and a total the view does not know all
|
|
3098
|
+
// stay marked.
|
|
3099
|
+
test('an exact connection total wears no mark, even with more pages to page through (S5)', async () => {
|
|
3100
|
+
const { view } = serverView({
|
|
3101
|
+
serve: (request) => (request.bucketId === 'all'
|
|
3102
|
+
? pageResult(rowsOf('all', 18), { total: 40, hasNextPage: true })
|
|
3103
|
+
: bucketPage(request)),
|
|
3104
|
+
});
|
|
3105
|
+
view.render(120);
|
|
3106
|
+
await tick();
|
|
3107
|
+
view.handleInput('g');
|
|
3108
|
+
await tick();
|
|
3109
|
+
const tabs = tabRow(view);
|
|
3110
|
+
assert.match(tabs, /▸ All \(40\)/, `a connection read reports an exact total, unmarked: ${tabs}`);
|
|
3111
|
+
assert.ok(!tabs.includes('(40+)'), `more pages to page through is not an inexact total: ${tabs}`);
|
|
3112
|
+
assert.match(noteRow(view), /via connection \(exact total\)/, 'and the frame names the exact read');
|
|
3113
|
+
});
|
|
3114
|
+
|
|
3115
|
+
test('the + still marks a capped search, a bounded bucket and an unknown total (S5)', async () => {
|
|
3116
|
+
const clock = manualScheduler();
|
|
3117
|
+
const { view } = serverView({
|
|
3118
|
+
scheduleQuery: clock.schedule,
|
|
3119
|
+
cancelSchedule: clock.cancel,
|
|
3120
|
+
serve: (request) => {
|
|
3121
|
+
if (request.bucketId === 'mine' && request.query === '') {
|
|
3122
|
+
return pageResult(rowsOf('mine', 18), { total: 40, hasNextPage: true });
|
|
3123
|
+
}
|
|
3124
|
+
if (request.bucketId === 'all' && request.query === '') {
|
|
3125
|
+
// A page that reports rows and NO total at all: the view can only
|
|
3126
|
+
// count what it holds, so its count is never claimed exact.
|
|
3127
|
+
return { ok: true, issues: rowsOf('all', 5), hasNextPage: false };
|
|
3128
|
+
}
|
|
3129
|
+
if (request.bucketId === 'all') return pageResult(rowsOf('all', 3), { total: 3 });
|
|
3130
|
+
return bucketPage(request);
|
|
3131
|
+
},
|
|
3132
|
+
});
|
|
3133
|
+
view.render(120);
|
|
3134
|
+
await tick();
|
|
3135
|
+
assert.match(tabRow(view), /▸ My issues \(40\+\)/, 'a bucket whose read reports it bounded keeps its mark');
|
|
3136
|
+
view.handleInput('g');
|
|
3137
|
+
await tick();
|
|
3138
|
+
assert.match(tabRow(view), /▸ All \(5\+\)/, 'a total the view does not know is never claimed exact');
|
|
3139
|
+
await typeFilter(view, clock, 'bug');
|
|
3140
|
+
assert.match(tabRow(view), /▸ All \(3\+\)/, 'a capped search read keeps its mark');
|
|
3141
|
+
assert.match(noteRow(view), /via search \(total capped\)/, 'and the frame names the search read');
|
|
3142
|
+
});
|
|
3143
|
+
|
|
3144
|
+
// S5: the dead line was a whitespace-only filter — the extension trims the
|
|
3145
|
+
// query, takes the CONNECTION read, and the view then told the reader it was
|
|
3146
|
+
// on the search path. A trimmed query that is empty is NO filter, and both the
|
|
3147
|
+
// route and the note have to read that one fact.
|
|
3148
|
+
test('a whitespace-only filter is no filter, so the frame names the connection read (S5)', async () => {
|
|
3149
|
+
const clock = manualScheduler();
|
|
3150
|
+
const { view, requests } = serverView({ scheduleQuery: clock.schedule, cancelSchedule: clock.cancel });
|
|
3151
|
+
view.render(120);
|
|
3152
|
+
await tick();
|
|
3153
|
+
view.handleInput('g');
|
|
3154
|
+
await tick();
|
|
3155
|
+
assert.match(noteRow(view), /via connection \(exact total\)/, 'the unfiltered All view names the connection');
|
|
3156
|
+
view.handleInput('T');
|
|
3157
|
+
view.handleInput(' ');
|
|
3158
|
+
clock.fire();
|
|
3159
|
+
await tick();
|
|
3160
|
+
assert.equal(requests.at(-1).query, ' ', 'the read still carries the raw query it was asked for');
|
|
3161
|
+
assert.match(noteRow(view), /via connection \(exact total\)/,
|
|
3162
|
+
'whitespace is no filter, so the connection read is what is on screen');
|
|
3163
|
+
assert.ok(!/\(\d+\+\)/.test(tabRow(view)), `and the count claims no inexact total: ${tabRow(view)}`);
|
|
3164
|
+
view.handleInput('delete');
|
|
3165
|
+
for (const ch of 'bug') view.handleInput(ch);
|
|
3166
|
+
clock.fire();
|
|
3167
|
+
await tick();
|
|
3168
|
+
assert.match(noteRow(view), /via search \(total capped\)/, 'a real filter names the search read');
|
|
3169
|
+
assert.match(tabRow(view), /▸ All \(\d+\+\)/, 'and its count is marked inexact');
|
|
3170
|
+
view.handleInput('delete');
|
|
3171
|
+
clock.fire();
|
|
3172
|
+
await tick();
|
|
3173
|
+
assert.equal(view.state.query, '', 'Delete clears the whole query');
|
|
3174
|
+
assert.match(noteRow(view), /via connection \(exact total\)/, 'clearing returns to the connection read');
|
|
3175
|
+
assert.ok(!/\(\d+\+\)/.test(tabRow(view)), `and the exact total is unmarked again: ${tabRow(view)}`);
|
|
3176
|
+
});
|
|
3177
|
+
|
|
3178
|
+
// S3/D3: a settled filter re-reads the scoped tabs. While the tab ON SCREEN
|
|
3179
|
+
// waits for its own filtered answer, the rows it still holds answer the
|
|
3180
|
+
// PREVIOUS query — painting them would read as matches for the new filter.
|
|
3181
|
+
test('a pending filter never paints another query rows on the scoped tab on screen (S3)', async () => {
|
|
3182
|
+
const clock = manualScheduler();
|
|
3183
|
+
const gate = deferred();
|
|
3184
|
+
const { view } = serverView({
|
|
3185
|
+
scheduleQuery: clock.schedule,
|
|
3186
|
+
cancelSchedule: clock.cancel,
|
|
3187
|
+
serve: (request) => {
|
|
3188
|
+
if (request.query === '') return bucketPage(request);
|
|
3189
|
+
if (request.bucketId === 'mine') return bucketPage(request);
|
|
3190
|
+
return gate.promise;
|
|
3191
|
+
},
|
|
3192
|
+
});
|
|
3193
|
+
view.render(120);
|
|
3194
|
+
await tick();
|
|
3195
|
+
assert.match(leftColumn(view, 120), /mine row 1/, 'the first tab holds its unfiltered rows');
|
|
3196
|
+
view.handleInput('T');
|
|
3197
|
+
view.handleInput('z');
|
|
3198
|
+
clock.fire();
|
|
3199
|
+
await tick();
|
|
3200
|
+
view.handleInput('enter');
|
|
3201
|
+
view.handleInput('tab');
|
|
3202
|
+
await tick();
|
|
3203
|
+
const tabs = tabRow(view);
|
|
3204
|
+
assert.match(tabs, /▸ Assigned \(–\)/, `the count of the query on screen is unknown while it loads: ${tabs}`);
|
|
3205
|
+
const left = leftColumn(view, 120);
|
|
3206
|
+
assert.ok(!left.includes('assigned row 1'), `the previous query rows are not this query result: ${left}`);
|
|
3207
|
+
assert.ok(!left.includes('▸ '), `and nothing among them is selected: ${left}`);
|
|
3208
|
+
assert.match(bodyOf(view, 120), /loading issues/, 'the frame paints the loading state it already uses');
|
|
3209
|
+
gate.resolve(bucketPage({ bucketId: 'assigned', query: 'z' }));
|
|
3210
|
+
await tick();
|
|
3211
|
+
assert.match(tabRow(view), /▸ Assigned \(1\)/, 'the filtered total lands with its own rows');
|
|
3212
|
+
assert.match(leftColumn(view, 120), /assigned row 1 z/, 'and the rows on screen are the filtered ones');
|
|
3213
|
+
});
|
|
3214
|
+
|
|
3215
|
+
// S3: the anti-flash behavior that exists at base is untouched — a reload of
|
|
3216
|
+
// the SAME query keeps the rows already read while the fresh page is in flight.
|
|
3217
|
+
test('an unchanged query keeps its rows while it reloads (S3)', async () => {
|
|
3218
|
+
const gate = deferred();
|
|
3219
|
+
let reads = 0;
|
|
3220
|
+
const { view } = serverView({
|
|
3221
|
+
serve: (request) => {
|
|
3222
|
+
reads += 1;
|
|
3223
|
+
if (reads > 3 && request.bucketId === 'mine') return gate.promise;
|
|
3224
|
+
return bucketPage(request);
|
|
3225
|
+
},
|
|
3226
|
+
});
|
|
3227
|
+
view.render(120);
|
|
3228
|
+
await tick();
|
|
3229
|
+
view.handleInput('r');
|
|
3230
|
+
await tick();
|
|
3231
|
+
const left = leftColumn(view, 120);
|
|
3232
|
+
assert.match(left, /mine row 1/, 'a reload of the SAME query keeps the rows already read');
|
|
3233
|
+
assert.match(tabRow(view), /▸ My issues \(2\)/, 'and the count that describes those rows');
|
|
3234
|
+
gate.resolve(bucketPage({ bucketId: 'mine', query: '' }));
|
|
3235
|
+
await tick();
|
|
3236
|
+
assert.match(leftColumn(view, 120), /mine row 1/, 'the answer paints its rows again');
|
|
3237
|
+
});
|
|
3238
|
+
|
|
3239
|
+
test('no other key moves: a still assigns, and g types inside the search box (S6)', async () => {
|
|
3240
|
+
const { view } = serverView({
|
|
3241
|
+
loadIssue: (n) => ({ ok: true, issue: issue(n, { permissions: EDITABLE }), comments: [] }),
|
|
3242
|
+
loadAssignees: () => ({ ok: true, users: [{ login: 'ann', name: 'Ann' }] }),
|
|
3243
|
+
});
|
|
3244
|
+
view.render(120);
|
|
3245
|
+
await tick();
|
|
3246
|
+
assert.match(footerOf(view), /a assign/, 'a still names the assignee editor');
|
|
3247
|
+
view.handleInput('a');
|
|
3248
|
+
assert.equal(view.state.mode, 'assignees', 'a opens the assignee editor, never the All view');
|
|
3249
|
+
view.handleInput('escape');
|
|
3250
|
+
assert.equal(view.state.mode, 'list');
|
|
3251
|
+
assert.equal(view.state.page, 0, 'a moved no view');
|
|
3252
|
+
view.handleInput('T');
|
|
3253
|
+
view.handleInput('g');
|
|
3254
|
+
assert.equal(view.state.query, 'g', 'g is a letter of the query inside the search box');
|
|
3255
|
+
assert.equal(view.state.page, 0, 'and it never switches the view from there');
|
|
3256
|
+
});
|
|
3257
|
+
|
|
3258
|
+
test('the shortcut hint rides the one-row legend at every width the reader gets (D1)', async () => {
|
|
3259
|
+
const { view } = serverView();
|
|
3260
|
+
view.render(200);
|
|
3261
|
+
await tick();
|
|
3262
|
+
for (const width of [40, 60, 80, 120, 200]) {
|
|
3263
|
+
const lines = view.render(width);
|
|
3264
|
+
for (const line of lines) {
|
|
3265
|
+
assert.equal(helpers.visibleWidth(line), width, `${width}: the frame stays cell-exact`);
|
|
3266
|
+
}
|
|
3267
|
+
const legend = lines.map(strip).filter((line) => /esc close/.test(line));
|
|
3268
|
+
assert.equal(legend.length, 1, `${width}: exactly one footer row`);
|
|
3269
|
+
// Below 60 cells the one legend row has room for the movement keys, the
|
|
3270
|
+
// bucket switch and `esc close` only — the same entries it already dropped
|
|
3271
|
+
// there — so the shortcut is taught from 60 cells up.
|
|
3272
|
+
if (width >= 60) assert.match(legend[0], /\bg\b/, `${width}: the shortcut hint survives the drop: ${legend[0]}`);
|
|
3273
|
+
}
|
|
3274
|
+
assert.match(strip(view.render(120).at(-2)), /g all issues/, 'outside All the hint reads all issues');
|
|
3275
|
+
view.handleInput('g');
|
|
3276
|
+
await tick();
|
|
3277
|
+
assert.match(strip(view.render(120).at(-2)), /g related issues/, 'inside All it reads related issues');
|
|
3278
|
+
});
|
|
3279
|
+
});
|
|
3280
|
+
|
|
2774
3281
|
// S3: the pager and its position marker are gone. The search row carries the
|
|
2775
3282
|
// widget alone, in every state, and the list spends its whole body budget on
|
|
2776
3283
|
// issues.
|
|
@@ -3131,7 +3638,7 @@ describe('issues remote search scheduling (S9)', () => {
|
|
|
3131
3638
|
return { ...made, requests };
|
|
3132
3639
|
}
|
|
3133
3640
|
|
|
3134
|
-
test('a burst of typing schedules ONE read for
|
|
3641
|
+
test('a burst of typing schedules ONE read for each scoped bucket when it settles', async () => {
|
|
3135
3642
|
const clock = manualScheduler();
|
|
3136
3643
|
const { view, requests, paints } = scheduledServerView(clock, () => pageResult([cursorRow('m1', issue(1))], { total: 1 }));
|
|
3137
3644
|
await tick();
|
|
@@ -3152,7 +3659,11 @@ describe('issues remote search scheduling (S9)', () => {
|
|
|
3152
3659
|
assert.ok(clock.live()[0].delayMs >= 100 && clock.live()[0].delayMs <= 250,
|
|
3153
3660
|
`a short fixed debounce delay: ${clock.live()[0].delayMs}`);
|
|
3154
3661
|
clock.fire();
|
|
3155
|
-
assert.
|
|
3662
|
+
assert.deepEqual(
|
|
3663
|
+
requests.slice(1).map((entry) => [entry.bucketId, entry.query]),
|
|
3664
|
+
[['mine', 'crash'], ['assigned', 'crash'], ['involved', 'crash']],
|
|
3665
|
+
'the settled query is read once per scoped bucket, never once per keystroke',
|
|
3666
|
+
);
|
|
3156
3667
|
assert.deepEqual(requests[1], { bucketId: 'mine', cursor: null, limit: 18, query: 'crash' });
|
|
3157
3668
|
assert.equal(view.state.searchPending, false, 'the wait ends when the read starts');
|
|
3158
3669
|
});
|
|
@@ -3176,7 +3687,7 @@ describe('issues remote search scheduling (S9)', () => {
|
|
|
3176
3687
|
leftColumn(view, 100);
|
|
3177
3688
|
view.handleInput('T');
|
|
3178
3689
|
view.handleInput('a');
|
|
3179
|
-
view.handleInput('enter'); // the 'a'
|
|
3690
|
+
view.handleInput('enter'); // the 'a' reads are in flight
|
|
3180
3691
|
assert.deepEqual(pending[1].request, { bucketId: 'mine', cursor: null, limit: 18, query: 'a' });
|
|
3181
3692
|
view.handleInput('T');
|
|
3182
3693
|
view.handleInput('b'); // 'ab' waits, so 'a' is already stale
|
|
@@ -3186,10 +3697,12 @@ describe('issues remote search scheduling (S9)', () => {
|
|
|
3186
3697
|
assert.match(waiting, /mount row/, 'the rows on screen are the ones the reader last saw');
|
|
3187
3698
|
assert.ok(!waiting.includes('a only match'), 'the answer for the superseded query never paints');
|
|
3188
3699
|
clock.fire();
|
|
3189
|
-
pending
|
|
3700
|
+
for (const entry of pending.filter((item) => item.request.query === 'ab')) {
|
|
3701
|
+
entry.entry.resolve(pageResult([cursorRow('n1', issue(3, { title: 'ab match' }))], { total: 1 }));
|
|
3702
|
+
}
|
|
3190
3703
|
await tick();
|
|
3191
3704
|
assert.match(leftColumn(view, 100), /ab match/, 'only the newest query answer paints');
|
|
3192
|
-
assert.equal(pending.length,
|
|
3705
|
+
assert.equal(pending.length, 7, 'the mount read, the flushed three and the settled three');
|
|
3193
3706
|
});
|
|
3194
3707
|
|
|
3195
3708
|
test('leaving the box reads the pending query once and never twice', async () => {
|
|
@@ -3201,15 +3714,15 @@ describe('issues remote search scheduling (S9)', () => {
|
|
|
3201
3714
|
assert.equal(requests.length, 1, 'typing waits for the debounce');
|
|
3202
3715
|
view.handleInput('enter');
|
|
3203
3716
|
assert.equal(view.state.searching, false);
|
|
3204
|
-
assert.equal(requests.length,
|
|
3717
|
+
assert.equal(requests.length, 4, 'leaving the box issues the three scoped reads now');
|
|
3205
3718
|
assert.deepEqual(requests[1], { bucketId: 'mine', cursor: null, limit: 18, query: 'bug' });
|
|
3206
3719
|
assert.equal(clock.live().length, 0, 'the pending callback is cancelled, not left to fire');
|
|
3207
3720
|
clock.fire();
|
|
3208
|
-
assert.equal(requests.length,
|
|
3721
|
+
assert.equal(requests.length, 4, 'a cancelled callback never reads');
|
|
3209
3722
|
view.handleInput('T');
|
|
3210
3723
|
view.handleInput('x');
|
|
3211
3724
|
view.handleInput('escape');
|
|
3212
|
-
assert.equal(requests.length,
|
|
3725
|
+
assert.equal(requests.length, 7, 'escape keeps the filter and reads it once per scoped bucket too');
|
|
3213
3726
|
assert.equal(view.state.query, 'bugx', 'escape never changes the typed query');
|
|
3214
3727
|
assert.equal(clock.live().length, 0);
|
|
3215
3728
|
});
|
|
@@ -3223,11 +3736,11 @@ describe('issues remote search scheduling (S9)', () => {
|
|
|
3223
3736
|
view.handleInput('enter');
|
|
3224
3737
|
leftColumn(view, 100);
|
|
3225
3738
|
view.handleInput('r');
|
|
3226
|
-
assert.equal(requests.length,
|
|
3227
|
-
assert.deepEqual(requests
|
|
3739
|
+
assert.equal(requests.length, 5, 'the explicit refresh reads the current page of the current query once');
|
|
3740
|
+
assert.deepEqual(requests.at(-1), { bucketId: 'mine', cursor: null, limit: 18, query: 'lab' },
|
|
3228
3741
|
'never an old cursor, never the previous query');
|
|
3229
3742
|
clock.fire();
|
|
3230
|
-
assert.equal(requests.length,
|
|
3743
|
+
assert.equal(requests.length, 5, 'no second request from a cancelled callback');
|
|
3231
3744
|
});
|
|
3232
3745
|
|
|
3233
3746
|
test('static local search stays immediate and never schedules', async () => {
|
|
@@ -3296,7 +3809,7 @@ describe('issues remote search scheduling (S9)', () => {
|
|
|
3296
3809
|
view.handleInput('z');
|
|
3297
3810
|
view.handleInput('enter');
|
|
3298
3811
|
await tick();
|
|
3299
|
-
assert.equal(requests.length,
|
|
3812
|
+
assert.equal(requests.length, 4, 'the settled search reads the three scoped buckets');
|
|
3300
3813
|
assert.deepEqual(requests[1], { bucketId: 'mine', cursor: null, limit: 18, query: 'z' });
|
|
3301
3814
|
const body = bodyOf(view, 100);
|
|
3302
3815
|
assert.match(body, /failed to load issues: GitHub issue search exceeds 1000 matches; narrow the filter/,
|
|
@@ -3351,8 +3864,14 @@ describe('issues remote search scheduling (S9)', () => {
|
|
|
3351
3864
|
assert.ok(!bodyOf(view, 100).includes('mine row'), 'the failing bucket lost its rows');
|
|
3352
3865
|
view.handleInput('tab');
|
|
3353
3866
|
await tick();
|
|
3354
|
-
|
|
3355
|
-
|
|
3867
|
+
// S3: the rows this bucket still holds answer the PREVIOUS query and its
|
|
3868
|
+
// read for the new one is in flight, so none of them is painted. The
|
|
3869
|
+
// failure next door still cleared only its own bucket: this one keeps its
|
|
3870
|
+
// own read state, which is why the count says unknown rather than zero.
|
|
3871
|
+
assert.ok(!leftColumn(view, 100).includes('assigned row'),
|
|
3872
|
+
'the previous query rows are not painted while this query reads');
|
|
3873
|
+
assert.match(strip(view.render(100)[2]), /▸ Assigned \(–\)/,
|
|
3874
|
+
'the count of the query on screen is unknown while it loads');
|
|
3356
3875
|
assigned.resolve(pageResult([cursorRow('a2', issue(5, { title: 'assigned match' }))], { total: 1 }));
|
|
3357
3876
|
await tick();
|
|
3358
3877
|
assert.match(leftColumn(view, 100), /assigned match/, 'and its own answer paints when it lands');
|
|
@@ -3374,12 +3893,10 @@ describe('issues remote search scheduling (S9)', () => {
|
|
|
3374
3893
|
return pageResult([cursorRow('m1', issue(40, { title: 'mine row' }))], { total: 1 });
|
|
3375
3894
|
});
|
|
3376
3895
|
await tick();
|
|
3377
|
-
view.handleInput('
|
|
3378
|
-
view.handleInput('tab');
|
|
3379
|
-
view.handleInput('tab');
|
|
3896
|
+
view.handleInput('g');
|
|
3380
3897
|
await tick();
|
|
3381
|
-
assert.equal(view.state.page, 3, '
|
|
3382
|
-
assert.match(strip(view.render(100)[2]), /▸ All \(2
|
|
3898
|
+
assert.equal(view.state.page, 3, 'the shortcut enters the All view');
|
|
3899
|
+
assert.match(strip(view.render(100)[2]), /▸ All \(2\)/, 'All names the connection total');
|
|
3383
3900
|
assert.match(leftColumn(view, 100), /all connection row/, 'All paints the connection rows');
|
|
3384
3901
|
view.handleInput('T');
|
|
3385
3902
|
view.handleInput('z');
|
|
@@ -3400,7 +3917,7 @@ describe('issues remote search scheduling (S9)', () => {
|
|
|
3400
3917
|
assert.equal(requests.at(-1).query, '', 'the cleared query reads the connection source again');
|
|
3401
3918
|
body = bodyOf(view, 100);
|
|
3402
3919
|
assert.match(body, /all connection row/, 'the connection rows come back with the query cleared');
|
|
3403
|
-
assert.match(strip(view.render(100)[2]), /▸ All \(2
|
|
3920
|
+
assert.match(strip(view.render(100)[2]), /▸ All \(2\)/, 'and its own count comes back with them');
|
|
3404
3921
|
assert.ok(!body.includes('failed to load issues'), 'the failure is gone once a read answers');
|
|
3405
3922
|
});
|
|
3406
3923
|
|
|
@@ -3473,13 +3990,19 @@ describe('issues remote search scheduling (S9)', () => {
|
|
|
3473
3990
|
view.handleInput('T');
|
|
3474
3991
|
view.handleInput('b');
|
|
3475
3992
|
clock.fire();
|
|
3476
|
-
assert.deepEqual(pending[
|
|
3993
|
+
assert.deepEqual(pending[4].request, { bucketId: 'mine', cursor: null, limit: 18, query: 'ab' });
|
|
3477
3994
|
pending[1].entry.resolve({ ok: false, error: 'GitHub issue search exceeds 1000 matches' });
|
|
3478
3995
|
await tick();
|
|
3479
3996
|
const waiting = leftColumn(view, 100);
|
|
3480
|
-
|
|
3997
|
+
// S3: the query on screen (`ab`) is what the rows must answer, and the rows
|
|
3998
|
+
// still held answer the mount's — so none is painted. The stale failure
|
|
3999
|
+
// changed nothing: no error repaints and the next answer is the only one.
|
|
4000
|
+
assert.ok(!waiting.includes('mount row'),
|
|
4001
|
+
'the previous query rows are not painted while the new query reads');
|
|
3481
4002
|
assert.ok(!strip(view.render(100).join('\n')).includes('1000 matches'), 'and its error never paints');
|
|
3482
|
-
pending
|
|
4003
|
+
for (const entry of pending.filter((item) => item.request.query === 'ab')) {
|
|
4004
|
+
entry.entry.resolve(pageResult([cursorRow('n1', issue(3, { title: 'ab match' }))], { total: 1 }));
|
|
4005
|
+
}
|
|
3483
4006
|
await tick();
|
|
3484
4007
|
assert.match(leftColumn(view, 100), /ab match/, 'only the newest query answer paints');
|
|
3485
4008
|
});
|
|
@@ -3572,7 +4095,7 @@ describe('issues preview shares lib/issue-preview.js (S16)', () => {
|
|
|
3572
4095
|
labels: [{ name: 'bug' }, { name: 'urgent' }],
|
|
3573
4096
|
assignees: [{ login: 'ann' }, { login: 'bob' }],
|
|
3574
4097
|
projects: [{ title: 'Roadmap' }],
|
|
3575
|
-
|
|
4098
|
+
linkedPullRequests: [69, 77],
|
|
3576
4099
|
reactions: { plusOne: 4 },
|
|
3577
4100
|
commentsCount: 2,
|
|
3578
4101
|
body: 'the body the preview renders',
|
|
@@ -4106,7 +4629,7 @@ describe('issues continuous list scrolling instead of pages (S3)', () => {
|
|
|
4106
4629
|
assert.match(left, /issue title 2/);
|
|
4107
4630
|
});
|
|
4108
4631
|
|
|
4109
|
-
test('the All
|
|
4632
|
+
test('the All view still lists the repository and keeps the query', async () => {
|
|
4110
4633
|
const calls = [];
|
|
4111
4634
|
const clock = manualScheduler();
|
|
4112
4635
|
const { view } = makeView({
|
|
@@ -4121,11 +4644,9 @@ describe('issues continuous list scrolling instead of pages (S3)', () => {
|
|
|
4121
4644
|
});
|
|
4122
4645
|
await tick();
|
|
4123
4646
|
const tabs = strip(view.render(120)[2]);
|
|
4124
|
-
assert.
|
|
4125
|
-
view.handleInput('
|
|
4126
|
-
view.
|
|
4127
|
-
view.handleInput('tab');
|
|
4128
|
-
assert.equal(view.state.page, 3, 'tab reaches the All bucket');
|
|
4647
|
+
assert.ok(!/\bAll\b/.test(tabs), `All is a shortcut, not the fourth tab (S1): ${tabs}`);
|
|
4648
|
+
view.handleInput('g');
|
|
4649
|
+
assert.equal(view.state.page, 3, 'the shortcut enters the All bucket');
|
|
4129
4650
|
await tick();
|
|
4130
4651
|
assert.equal(calls.at(-1).bucketId, 'all', 'All reads its own bucket');
|
|
4131
4652
|
assert.match(leftColumn(view, 120, 20), /all tab hit/);
|
|
@@ -4340,7 +4861,7 @@ describe('issues preview renders styled markdown (S12)', () => {
|
|
|
4340
4861
|
|
|
4341
4862
|
test('the markdown roles come from the theme, like the ODD document pane', async () => {
|
|
4342
4863
|
const theme = recordingTheme();
|
|
4343
|
-
|
|
4864
|
+
await viewFor('## Steps\n\nuse `gh` now', { theme });
|
|
4344
4865
|
assert.ok(theme.calls.some((call) => call.role === 'mdHeading' && call.text.includes('Steps')),
|
|
4345
4866
|
'a heading is painted mdHeading');
|
|
4346
4867
|
assert.ok(theme.calls.some((call) => call.role === 'dim' && call.text.includes('gh')),
|
|
@@ -4399,3 +4920,911 @@ describe('issues preview renders styled markdown (S12)', () => {
|
|
|
4399
4920
|
assert.equal(readerPanes(100).right, pane.right);
|
|
4400
4921
|
});
|
|
4401
4922
|
});
|
|
4923
|
+
|
|
4924
|
+
// S7 (issues-all-toggle): the panel can open on ONE issue. `/issues <n>` mounts
|
|
4925
|
+
// the same reader with an initial bucket (`assigned`) and an initial issue, so
|
|
4926
|
+
// the view opens on that tab, selects the matching row and shows its detail —
|
|
4927
|
+
// or says honestly that the number is not in that view. The selection is ONE
|
|
4928
|
+
// shot: later filters, refreshes and paging never move the reader back to it.
|
|
4929
|
+
describe('issues view opens on one issue (S7)', () => {
|
|
4930
|
+
// A cursor-paged server seam over one ordered row list per bucket: the cursor
|
|
4931
|
+
// is the last row's position, so the next request continues after it exactly
|
|
4932
|
+
// like the real `loadIssuePage` contract. `pagesRead` lets a test count how
|
|
4933
|
+
// many requests a bucket cost.
|
|
4934
|
+
function pagedView(rowsByBucket, extra = {}) {
|
|
4935
|
+
const requests = [];
|
|
4936
|
+
const details = [];
|
|
4937
|
+
const view = createIssuesView({
|
|
4938
|
+
helpers,
|
|
4939
|
+
prefetchBuckets: true,
|
|
4940
|
+
rowsAvailable: () => 24,
|
|
4941
|
+
requestRender: () => {},
|
|
4942
|
+
done: () => {},
|
|
4943
|
+
loadIssuePage: (request) => {
|
|
4944
|
+
requests.push({ ...request });
|
|
4945
|
+
const rows = rowsByBucket[request.bucketId] || [];
|
|
4946
|
+
const start = request.cursor == null ? 0 : Number(String(request.cursor).replace(/^r/, '')) + 1;
|
|
4947
|
+
const asked = Number(request.limit);
|
|
4948
|
+
const first = Number.isFinite(asked) ? asked : rows.length;
|
|
4949
|
+
const page = rows.slice(start, start + first);
|
|
4950
|
+
return {
|
|
4951
|
+
ok: true,
|
|
4952
|
+
issues: page.map((number, at) => ({ ...issue(number), cursor: `r${start + at}` })),
|
|
4953
|
+
total: rows.length,
|
|
4954
|
+
hasNextPage: start + page.length < rows.length,
|
|
4955
|
+
};
|
|
4956
|
+
},
|
|
4957
|
+
loadIssue: (number) => {
|
|
4958
|
+
details.push(number);
|
|
4959
|
+
return { ok: true, issue: issue(number), comments: [] };
|
|
4960
|
+
},
|
|
4961
|
+
...extra,
|
|
4962
|
+
});
|
|
4963
|
+
return { view, requests, details };
|
|
4964
|
+
}
|
|
4965
|
+
|
|
4966
|
+
const assignedReads = (requests) => requests.filter((request) => request.bucketId === 'assigned');
|
|
4967
|
+
|
|
4968
|
+
test('opens on Assigned with that row selected and its detail requested', async () => {
|
|
4969
|
+
const { view, requests, details } = pagedView({ mine: [1], assigned: [51, 52], involved: [3] }, {
|
|
4970
|
+
initialBucket: 'assigned',
|
|
4971
|
+
initialIssue: 51,
|
|
4972
|
+
});
|
|
4973
|
+
await tick();
|
|
4974
|
+
assert.equal(requests[0].bucketId, 'assigned', 'the panel opens on the Assigned bucket');
|
|
4975
|
+
const bar = bodyOf(view, 160).split('\n').find((line) => line.includes('My issues')) ?? '';
|
|
4976
|
+
assert.match(bar, /▸ Assigned/, 'the Assigned tab is the one painted as active');
|
|
4977
|
+
assert.match(leftColumn(view, 160), /▸ issue title 51/, 'the matching row is the focused one');
|
|
4978
|
+
assert.deepEqual(details, [51], 'the requested issue is the one whose detail is read');
|
|
4979
|
+
assert.match(rightRows(view, 160).join('\n'), /#51/, 'the detail pane shows the requested issue');
|
|
4980
|
+
});
|
|
4981
|
+
|
|
4982
|
+
test('an issue on a later page is found by paging and selected', async () => {
|
|
4983
|
+
const assigned = [...Array.from({ length: 18 }, (_, at) => at + 1), 51];
|
|
4984
|
+
const { view, requests, details } = pagedView({ assigned }, {
|
|
4985
|
+
initialBucket: 'assigned',
|
|
4986
|
+
initialIssue: 51,
|
|
4987
|
+
});
|
|
4988
|
+
await tick();
|
|
4989
|
+
const reads = assignedReads(requests);
|
|
4990
|
+
assert.deepEqual(reads.map((request) => request.cursor), [null, 'r17'],
|
|
4991
|
+
'the first page is read, then the one after it');
|
|
4992
|
+
assert.match(leftColumn(view, 160), /▸ issue title 51/, 'the found row is selected');
|
|
4993
|
+
assert.equal(details.at(-1), 51, 'and its detail is what gets read last');
|
|
4994
|
+
});
|
|
4995
|
+
|
|
4996
|
+
test('a number nowhere in Assigned leaves the first row and says so', async () => {
|
|
4997
|
+
const { view, requests, details } = pagedView({ assigned: [1, 2] }, {
|
|
4998
|
+
initialBucket: 'assigned',
|
|
4999
|
+
initialIssue: 51,
|
|
5000
|
+
});
|
|
5001
|
+
await tick();
|
|
5002
|
+
assert.equal(assignedReads(requests).length, 1, 'an exhausted bucket is read once');
|
|
5003
|
+
assert.match(leftColumn(view, 160), /▸ issue title 1/, 'the first row stays selected');
|
|
5004
|
+
assert.deepEqual(details, [1], 'as a plain open would, its detail is read');
|
|
5005
|
+
assert.match(bodyOf(view, 160), /#51 is not in Assigned/, 'the note row says so');
|
|
5006
|
+
});
|
|
5007
|
+
|
|
5008
|
+
test('paging for a missing number stops at five pages', async () => {
|
|
5009
|
+
const assigned = Array.from({ length: 200 }, (_, at) => at + 1);
|
|
5010
|
+
const { view, requests } = pagedView({ assigned }, {
|
|
5011
|
+
initialBucket: 'assigned',
|
|
5012
|
+
initialIssue: 999,
|
|
5013
|
+
});
|
|
5014
|
+
await tick();
|
|
5015
|
+
assert.equal(assignedReads(requests).length, 5, 'the bound is five Assigned pages in total');
|
|
5016
|
+
assert.match(bodyOf(view, 160), /#999 is not in Assigned/, 'and the panel discloses it');
|
|
5017
|
+
assert.match(leftColumn(view, 160), /▸ issue title 1/, 'the first row stays selected');
|
|
5018
|
+
});
|
|
5019
|
+
|
|
5020
|
+
test('the selection is not re-applied after a refresh, a filter or paging', async () => {
|
|
5021
|
+
const scheduler = manualScheduler();
|
|
5022
|
+
const { view, details } = pagedView({ mine: [51], assigned: [1, 51, 2], involved: [] }, {
|
|
5023
|
+
initialBucket: 'assigned',
|
|
5024
|
+
initialIssue: 51,
|
|
5025
|
+
scheduleQuery: scheduler.schedule,
|
|
5026
|
+
cancelSchedule: scheduler.cancel,
|
|
5027
|
+
});
|
|
5028
|
+
await tick();
|
|
5029
|
+
assert.match(leftColumn(view, 160), /▸ issue title 51/, 'the opening selection landed');
|
|
5030
|
+
view.handleInput('home');
|
|
5031
|
+
view.render(160);
|
|
5032
|
+
assert.match(leftColumn(view, 160), /▸ issue title 1/, 'the reader moved away from it');
|
|
5033
|
+
const beforeRefresh = details.length;
|
|
5034
|
+
view.handleInput('r');
|
|
5035
|
+
await tick();
|
|
5036
|
+
view.render(160);
|
|
5037
|
+
assert.match(leftColumn(view, 160), /▸ issue title 1/, 'a refresh keeps the reader’s own selection');
|
|
5038
|
+
assert.ok(!details.slice(beforeRefresh).includes(51), 'and never reads #51 on its own again');
|
|
5039
|
+
view.handleInput('t');
|
|
5040
|
+
for (const ch of 'issue') view.handleInput(ch);
|
|
5041
|
+
scheduler.fire();
|
|
5042
|
+
await tick();
|
|
5043
|
+
view.handleInput('enter');
|
|
5044
|
+
await tick();
|
|
5045
|
+
view.render(160);
|
|
5046
|
+
assert.ok(!leftColumn(view, 160).includes('▸ issue title 51'), 'a filter change never re-selects the opening issue');
|
|
5047
|
+
});
|
|
5048
|
+
|
|
5049
|
+
// S9 (T10): the pre-dispatch proof lived in the rail and is gone, so a number
|
|
5050
|
+
// the requested bucket does not hold is still worth one look in the OTHER
|
|
5051
|
+
// bucket of the pair before the reader is told it is absent. The command has
|
|
5052
|
+
// already picked a bucket when the cache knows one; a cold cache leaves this
|
|
5053
|
+
// fallback to answer, and the reader lands on the tab that actually has it.
|
|
5054
|
+
test('a number that is only in My issues falls back to that bucket instead of reporting a miss', async () => {
|
|
5055
|
+
const { view, requests } = pagedView({ mine: [61], assigned: [51, 52], involved: [] }, {
|
|
5056
|
+
initialBucket: 'assigned',
|
|
5057
|
+
initialIssue: 61,
|
|
5058
|
+
});
|
|
5059
|
+
await tick();
|
|
5060
|
+
const frame = bodyOf(view, 160);
|
|
5061
|
+
const bar = frame.split('\n').find((line) => line.includes('Assigned')) ?? '';
|
|
5062
|
+
assert.match(bar, /▸ My issues/, 'the reader lands on the bucket that holds the issue');
|
|
5063
|
+
assert.match(leftColumn(view, 160), /▸ issue title 61/, 'and focuses it there');
|
|
5064
|
+
assert.ok(!frame.includes('is not in'), 'no miss is reported when the other bucket has it');
|
|
5065
|
+
assert.equal(assignedReads(requests)[0].cursor, null,
|
|
5066
|
+
'the requested bucket is searched first, as the command asked');
|
|
5067
|
+
assert.ok(requests.some((request) => request.bucketId === 'mine'),
|
|
5068
|
+
'and the other bucket of the pair is tried before the miss');
|
|
5069
|
+
});
|
|
5070
|
+
|
|
5071
|
+
test('a number nowhere in the pair still reports the miss for the requested bucket', async () => {
|
|
5072
|
+
const { view } = pagedView({ mine: [61], assigned: [51, 52], involved: [] }, {
|
|
5073
|
+
initialBucket: 'assigned',
|
|
5074
|
+
initialIssue: 999,
|
|
5075
|
+
});
|
|
5076
|
+
await tick();
|
|
5077
|
+
const frame = bodyOf(view, 160);
|
|
5078
|
+
assert.match(frame, /#999 is not in Assigned/, 'the miss names the bucket the open requested');
|
|
5079
|
+
assert.match(leftColumn(view, 160), /▸ issue title 51/,
|
|
5080
|
+
'and the reader is left on the requested bucket, not on the one it tried second');
|
|
5081
|
+
});
|
|
5082
|
+
|
|
5083
|
+
// S9 (T10) part 2: the first frame of a numbered open shows what the rail
|
|
5084
|
+
// already knows — number, title, state, labels, assignees, author — through
|
|
5085
|
+
// the ONE pending rendering `lib/issue-preview.js` already owns. A bare
|
|
5086
|
+
// `loading…` pane is the defect this pins: the body may still be on its way,
|
|
5087
|
+
// but the identity of the issue never waits for it.
|
|
5088
|
+
test('the first frame of a numbered open carries the known facts instead of a bare loading… pane', async () => {
|
|
5089
|
+
const held = new Promise(() => {});
|
|
5090
|
+
const seeded = {
|
|
5091
|
+
...issue(51, {
|
|
5092
|
+
title: 'Seeded fifty-one',
|
|
5093
|
+
assignees: [{ login: 'ana' }, { login: 'beto' }],
|
|
5094
|
+
}),
|
|
5095
|
+
};
|
|
5096
|
+
const view = createIssuesView({
|
|
5097
|
+
helpers,
|
|
5098
|
+
rowsAvailable: () => 24,
|
|
5099
|
+
requestRender: () => {},
|
|
5100
|
+
done: () => {},
|
|
5101
|
+
prefetchBuckets: false,
|
|
5102
|
+
pages: [{ id: 'assigned', label: 'Assigned', issues: [seeded] }],
|
|
5103
|
+
loadIssuePage: () => held,
|
|
5104
|
+
loadIssue: () => held,
|
|
5105
|
+
initialBucket: 'assigned',
|
|
5106
|
+
initialIssue: 51,
|
|
5107
|
+
});
|
|
5108
|
+
await tick();
|
|
5109
|
+
const right = rightRows(view, 160);
|
|
5110
|
+
const pane = right.join('\n');
|
|
5111
|
+
assert.match(pane, /#51 Seeded fifty-one/, 'the number and title are on screen');
|
|
5112
|
+
assert.match(pane, /\[open\]/, 'and the state the row already carried');
|
|
5113
|
+
assert.match(pane, /labels: bug/, 'and the labels');
|
|
5114
|
+
assert.match(pane, /assignees: ana, beto/, 'and the assignees the rail cached');
|
|
5115
|
+
assert.match(pane, /by octo/, 'and the author');
|
|
5116
|
+
// S9: the pane opens ON the issue, never on a bare placeholder. The body
|
|
5117
|
+
// marker may still name the read — but only UNDER those facts.
|
|
5118
|
+
const painted = right.filter((row) => row.length > 0);
|
|
5119
|
+
assert.match(painted[0] ?? '', /#51 Seeded fifty-one/, `the pane opens on the issue, not on a placeholder: ${JSON.stringify(painted.slice(0, 2))}`);
|
|
5120
|
+
assert.match(pane, /loading…/, 'the body read still names itself under the facts');
|
|
5121
|
+
assert.ok(pane.indexOf('#51 Seeded fifty-one') < pane.indexOf('loading…'),
|
|
5122
|
+
'the facts come first and the read is named below them — never a bare loading pane');
|
|
5123
|
+
});
|
|
5124
|
+
|
|
5125
|
+
test('a plain open still starts on My issues with nothing selected by number', async () => {
|
|
5126
|
+
const { view, requests, details } = pagedView({ mine: [1, 2], assigned: [51], involved: [] });
|
|
5127
|
+
await tick();
|
|
5128
|
+
assert.equal(requests[0].bucketId, 'mine', 'a plain open reads My issues first');
|
|
5129
|
+
const bar = bodyOf(view, 160).split('\n').find((line) => line.includes('Assigned')) ?? '';
|
|
5130
|
+
assert.match(bar, /▸ My issues/, 'My issues is the active tab');
|
|
5131
|
+
assert.match(leftColumn(view, 160), /▸ issue title 1/, 'the first row is selected');
|
|
5132
|
+
assert.deepEqual(details, [1], 'and only its detail is read');
|
|
5133
|
+
assert.ok(!bodyOf(view, 160).includes('is not in'), 'no initial-issue note appears');
|
|
5134
|
+
});
|
|
5135
|
+
});
|
|
5136
|
+
|
|
5137
|
+
// E18 (issues-sidebar S4, verify round 5 blocker b): a SEEDED page puts rows on
|
|
5138
|
+
// screen before its own answer arrives. A numbered open (`/issues 22`, which the
|
|
5139
|
+
// rail's row click dispatches) must therefore select #22 from the SEEDED rows —
|
|
5140
|
+
// the first frame is the one a `c`, `ctrl+s` can act on — and while the asked
|
|
5141
|
+
// number is neither found nor excluded, no mutation may reach any other row.
|
|
5142
|
+
//
|
|
5143
|
+
// E18 (blocker c): a seeded page was never stamped with the query it answers, so
|
|
5144
|
+
// it kept painting itself (and its exact counts) under a filter it had never
|
|
5145
|
+
// been read for. Its rows answer the EMPTY query, exactly like a freshly loaded
|
|
5146
|
+
// page's do, and stop painting the moment a filter is typed.
|
|
5147
|
+
describe('a seeded bucket never lends its rows to the wrong issue (E18)', () => {
|
|
5148
|
+
// The page seam: every request is answered by the test, so "still in flight"
|
|
5149
|
+
// is exactly the window the findings lived in.
|
|
5150
|
+
function heldReads() {
|
|
5151
|
+
const requests = [];
|
|
5152
|
+
const byBucket = new Map();
|
|
5153
|
+
return {
|
|
5154
|
+
requests,
|
|
5155
|
+
loadIssuePage(request) {
|
|
5156
|
+
const entry = deferred();
|
|
5157
|
+
requests.push({ ...request, entry });
|
|
5158
|
+
if (!byBucket.has(request.bucketId)) byBucket.set(request.bucketId, []);
|
|
5159
|
+
byBucket.get(request.bucketId).push(entry);
|
|
5160
|
+
return entry.promise;
|
|
5161
|
+
},
|
|
5162
|
+
latest(bucketId) {
|
|
5163
|
+
const list = byBucket.get(bucketId) || [];
|
|
5164
|
+
return list.length > 0 ? list[list.length - 1] : null;
|
|
5165
|
+
},
|
|
5166
|
+
count(bucketId) {
|
|
5167
|
+
return (byBucket.get(bucketId) || []).length;
|
|
5168
|
+
},
|
|
5169
|
+
};
|
|
5170
|
+
}
|
|
5171
|
+
|
|
5172
|
+
// The three scoped buckets the panel mounts with, `assigned` seeded exactly as
|
|
5173
|
+
// the rail's cache hands it over: rows, no read behind them yet.
|
|
5174
|
+
function seededPages(assignedRows, mineRows = [issue(11), issue(12)]) {
|
|
5175
|
+
return [
|
|
5176
|
+
{ id: 'mine', label: 'My issues', issues: mineRows, total: mineRows.length },
|
|
5177
|
+
{ id: 'assigned', label: 'Assigned', issues: assignedRows, total: assignedRows.length },
|
|
5178
|
+
{ id: 'involved', label: 'Involved', issues: [], total: 0 },
|
|
5179
|
+
];
|
|
5180
|
+
}
|
|
5181
|
+
|
|
5182
|
+
test('a numbered open selects the asked issue FROM the seeded rows, so c then ctrl+s names it', async () => {
|
|
5183
|
+
const reads = heldReads();
|
|
5184
|
+
const details = [];
|
|
5185
|
+
const comments = [];
|
|
5186
|
+
const view = createIssuesView({
|
|
5187
|
+
helpers,
|
|
5188
|
+
rowsAvailable: () => 24,
|
|
5189
|
+
requestRender: () => {},
|
|
5190
|
+
done: () => {},
|
|
5191
|
+
pages: seededPages([issue(21), issue(22)]),
|
|
5192
|
+
loadIssuePage: reads.loadIssuePage,
|
|
5193
|
+
loadIssue: (number) => {
|
|
5194
|
+
details.push(number);
|
|
5195
|
+
return { ok: true, issue: issue(number, { permissions: EDITABLE }), comments: [] };
|
|
5196
|
+
},
|
|
5197
|
+
actions: {
|
|
5198
|
+
postComment: (number, text) => { comments.push([number, text]); return { ok: true }; },
|
|
5199
|
+
},
|
|
5200
|
+
initialBucket: 'assigned',
|
|
5201
|
+
initialIssue: 22,
|
|
5202
|
+
});
|
|
5203
|
+
await tick();
|
|
5204
|
+
|
|
5205
|
+
// No answer has arrived: the seeded rows are the whole screen.
|
|
5206
|
+
assert.equal(reads.count('assigned'), 1, 'the numbered open issued its own Assigned read');
|
|
5207
|
+
assert.match(leftColumn(view, 160), /▸ issue title 22/,
|
|
5208
|
+
'the seeded row the number names is the focused one, before any answer');
|
|
5209
|
+
assert.deepEqual(details, [22], 'and the detail read is that issue');
|
|
5210
|
+
|
|
5211
|
+
// The verifier's exact scenario: `c`, then `ctrl+s`, inside that window.
|
|
5212
|
+
view.handleInput('c');
|
|
5213
|
+
for (const ch of 'lgtm') view.handleInput(ch);
|
|
5214
|
+
view.handleInput('ctrl+s');
|
|
5215
|
+
await tick();
|
|
5216
|
+
assert.deepEqual(comments, [[22, 'lgtm']],
|
|
5217
|
+
'the mutation names the issue the human asked for, never the seeded row beside it');
|
|
5218
|
+
});
|
|
5219
|
+
|
|
5220
|
+
test('a number the seeded rows do not hold lets no mutation run until its own answer decides', async () => {
|
|
5221
|
+
const reads = heldReads();
|
|
5222
|
+
const comments = [];
|
|
5223
|
+
const view = createIssuesView({
|
|
5224
|
+
helpers,
|
|
5225
|
+
rowsAvailable: () => 24,
|
|
5226
|
+
requestRender: () => {},
|
|
5227
|
+
done: () => {},
|
|
5228
|
+
pages: seededPages([issue(21)]),
|
|
5229
|
+
loadIssuePage: reads.loadIssuePage,
|
|
5230
|
+
loadIssue: (number) => ({ ok: true, issue: issue(number, { permissions: EDITABLE }), comments: [] }),
|
|
5231
|
+
actions: {
|
|
5232
|
+
postComment: (number, text) => { comments.push([number, text]); return { ok: true }; },
|
|
5233
|
+
},
|
|
5234
|
+
initialBucket: 'assigned',
|
|
5235
|
+
initialIssue: 22,
|
|
5236
|
+
});
|
|
5237
|
+
await tick();
|
|
5238
|
+
assert.match(leftColumn(view, 160), /▸ issue title 21/, 'the seeded first row is what is on screen');
|
|
5239
|
+
|
|
5240
|
+
view.handleInput('c');
|
|
5241
|
+
for (const ch of 'lgtm') view.handleInput(ch);
|
|
5242
|
+
view.handleInput('ctrl+s');
|
|
5243
|
+
await tick();
|
|
5244
|
+
assert.deepEqual(comments, [], 'nothing is written while #22 is neither found nor excluded');
|
|
5245
|
+
assert.match(bodyOf(view, 160), /#22 has not been found in Assigned yet/,
|
|
5246
|
+
'the refusal says so instead of changing another issue');
|
|
5247
|
+
assert.equal(view.state.mode, 'comment', 'and the draft is kept for when the answer arrives');
|
|
5248
|
+
|
|
5249
|
+
// The answer lands holding #22: the selection moves to it, and the same
|
|
5250
|
+
// draft now reaches exactly that issue.
|
|
5251
|
+
reads.latest('assigned').resolve(pageResult([issue(21), issue(22)]));
|
|
5252
|
+
await tick();
|
|
5253
|
+
assert.match(leftColumn(view, 160), /▸ issue title 22/,
|
|
5254
|
+
'the answer moves the selection to the issue that was asked for');
|
|
5255
|
+
view.handleInput('ctrl+s');
|
|
5256
|
+
await tick();
|
|
5257
|
+
assert.deepEqual(comments, [[22, 'lgtm']], 'and from then on the mutation reaches #22 only');
|
|
5258
|
+
});
|
|
5259
|
+
|
|
5260
|
+
test('a movement the reader makes before the answer still allows a mutation on the row it shows afterwards', async () => {
|
|
5261
|
+
// Preserve: the SAME rule for a plain (unnumbered) seeded open. No number
|
|
5262
|
+
// is asked for, so no proof exists and every mutation reaches the row the
|
|
5263
|
+
// reader is looking at, exactly as before.
|
|
5264
|
+
const reads = heldReads();
|
|
5265
|
+
const comments = [];
|
|
5266
|
+
const opened = [];
|
|
5267
|
+
const view = createIssuesView({
|
|
5268
|
+
helpers,
|
|
5269
|
+
rowsAvailable: () => 24,
|
|
5270
|
+
requestRender: () => {},
|
|
5271
|
+
done: () => {},
|
|
5272
|
+
pages: seededPages([issue(21), issue(22)]),
|
|
5273
|
+
loadIssuePage: reads.loadIssuePage,
|
|
5274
|
+
loadIssue: (number) => ({ ok: true, issue: issue(number, { permissions: EDITABLE }), comments: [] }),
|
|
5275
|
+
actions: {
|
|
5276
|
+
postComment: (number, text) => { comments.push([number, text]); return { ok: true }; },
|
|
5277
|
+
openBrowser: (number) => { opened.push(number); return { ok: true }; },
|
|
5278
|
+
},
|
|
5279
|
+
});
|
|
5280
|
+
await tick();
|
|
5281
|
+
assert.match(leftColumn(view, 160), /▸ issue title 11/, 'the seeded first row is selected as always');
|
|
5282
|
+
|
|
5283
|
+
view.handleInput('c');
|
|
5284
|
+
for (const ch of 'ok') view.handleInput(ch);
|
|
5285
|
+
view.handleInput('ctrl+s');
|
|
5286
|
+
await tick();
|
|
5287
|
+
assert.deepEqual(comments, [[11, 'ok']], 'a plain open writes on the row it shows');
|
|
5288
|
+
view.handleInput('o');
|
|
5289
|
+
assert.deepEqual(opened, [11], 'and `o web` opens that same row');
|
|
5290
|
+
});
|
|
5291
|
+
|
|
5292
|
+
test('seeded rows stop painting under a filter they were never read for, and the answer paints', async () => {
|
|
5293
|
+
const scheduler = manualScheduler();
|
|
5294
|
+
const reads = heldReads();
|
|
5295
|
+
const view = createIssuesView({
|
|
5296
|
+
helpers,
|
|
5297
|
+
rowsAvailable: () => 24,
|
|
5298
|
+
requestRender: () => {},
|
|
5299
|
+
done: () => {},
|
|
5300
|
+
pages: seededPages([issue(21), issue(22)]),
|
|
5301
|
+
loadIssuePage: reads.loadIssuePage,
|
|
5302
|
+
loadIssue: (number) => ({ ok: true, issue: issue(number), comments: [] }),
|
|
5303
|
+
initialBucket: 'assigned',
|
|
5304
|
+
scheduleQuery: scheduler.schedule,
|
|
5305
|
+
cancelSchedule: scheduler.cancel,
|
|
5306
|
+
});
|
|
5307
|
+
await tick();
|
|
5308
|
+
assert.match(leftColumn(view, 160), /issue title 21/, 'the seeded rows paint while the query is the empty one');
|
|
5309
|
+
assert.match(bodyOf(view, 160), /Assigned \(2\)/, 'and their count is the count they hold');
|
|
5310
|
+
|
|
5311
|
+
// A filter the seeded rows were never read for.
|
|
5312
|
+
view.handleInput('t');
|
|
5313
|
+
for (const ch of 'label:bug') view.handleInput(ch);
|
|
5314
|
+
scheduler.fire();
|
|
5315
|
+
await tick();
|
|
5316
|
+
assert.ok(!leftColumn(view, 160).includes('issue title 21'),
|
|
5317
|
+
'the seeded rows stop painting under a filter they never answered');
|
|
5318
|
+
assert.ok(!leftColumn(view, 160).includes('issue title 22'));
|
|
5319
|
+
assert.match(bodyOf(view, 160), /Assigned \(–\)/,
|
|
5320
|
+
'and the count is unknown until the filtered answer arrives, exactly like a freshly loaded page');
|
|
5321
|
+
|
|
5322
|
+
reads.latest('assigned').resolve(pageResult([issue(30)]));
|
|
5323
|
+
await tick();
|
|
5324
|
+
assert.match(leftColumn(view, 160), /issue title 30/, 'the filtered answer paints');
|
|
5325
|
+
assert.ok(!leftColumn(view, 160).includes('issue title 21'), 'and the seeded rows never come back');
|
|
5326
|
+
assert.match(bodyOf(view, 160), /Assigned \(1\)/, 'the count follows the answer');
|
|
5327
|
+
});
|
|
5328
|
+
|
|
5329
|
+
test('the same seeded page with no filter keeps painting instantly', async () => {
|
|
5330
|
+
// Preserve: stamping the seeded rows with the query they answer must not
|
|
5331
|
+
// cost the instant first frame the cache exists for.
|
|
5332
|
+
const reads = heldReads();
|
|
5333
|
+
const view = createIssuesView({
|
|
5334
|
+
helpers,
|
|
5335
|
+
rowsAvailable: () => 24,
|
|
5336
|
+
requestRender: () => {},
|
|
5337
|
+
done: () => {},
|
|
5338
|
+
pages: seededPages([issue(21), issue(22)]),
|
|
5339
|
+
loadIssuePage: reads.loadIssuePage,
|
|
5340
|
+
loadIssue: (number) => ({ ok: true, issue: issue(number), comments: [] }),
|
|
5341
|
+
initialBucket: 'assigned',
|
|
5342
|
+
});
|
|
5343
|
+
await tick();
|
|
5344
|
+
assert.equal(reads.count('assigned'), 1, 'the mount read the visible bucket, and it is still in flight');
|
|
5345
|
+
assert.match(leftColumn(view, 160), /issue title 21/, 'the seeded rows paint before any answer');
|
|
5346
|
+
assert.match(leftColumn(view, 160), /issue title 22/);
|
|
5347
|
+
assert.match(bodyOf(view, 160), /Assigned \(2\)/, 'with the count they hold');
|
|
5348
|
+
});
|
|
5349
|
+
});
|
|
5350
|
+
|
|
5351
|
+
// T12 (S10): a sub-mode's keys belong to the footer, and only there. The
|
|
5352
|
+
// editors' titles are the sub-mode's name alone; while a sub-mode holds the
|
|
5353
|
+
// keyboard the ONE footer row carries that sub-mode's keys instead of the
|
|
5354
|
+
// reading legend, in the same place on screen, and leaving the sub-mode puts
|
|
5355
|
+
// the legend back.
|
|
5356
|
+
//
|
|
5357
|
+
// T13 (S11): the footer only offers what works now. The five hints that act on
|
|
5358
|
+
// the selected issue need an issue that is both focused and loaded, and the
|
|
5359
|
+
// three repository actions keep their literal-`true` capability gate.
|
|
5360
|
+
// Everything that still works — movement, the bucket switch, the search key,
|
|
5361
|
+
// the `All` shortcut and the escape — stays on the row.
|
|
5362
|
+
describe('S10/S11: the footer offers only the keys that work now', () => {
|
|
5363
|
+
const footerOf = (view, width) => strip(view.render(width).at(-2));
|
|
5364
|
+
const READ_LEGEND = ['↑↓ move', '←→ bucket', 'c comment', 'o web', 't search', 'g all issues', 'esc close'];
|
|
5365
|
+
const ISSUE_ACTIONS = ['l labels', 'a assign', 'c comment', 'x close', 'o web'];
|
|
5366
|
+
|
|
5367
|
+
async function opened(opts = {}) {
|
|
5368
|
+
const { view } = makeView({
|
|
5369
|
+
pages: pagesOf([[issue(1)], [], []]),
|
|
5370
|
+
issues: [issue(1)],
|
|
5371
|
+
loadIssue: (n) => ({ ok: true, issue: issue(n, { permissions: EDITABLE }), comments: [] }),
|
|
5372
|
+
...opts,
|
|
5373
|
+
});
|
|
5374
|
+
await tick();
|
|
5375
|
+
return view;
|
|
5376
|
+
}
|
|
5377
|
+
|
|
5378
|
+
test('the labels editor title is its name alone', async () => {
|
|
5379
|
+
const view = await opened({
|
|
5380
|
+
labels: [{ name: 'bug' }],
|
|
5381
|
+
loadLabels: () => ({ ok: true, labels: [{ name: 'bug' }] }),
|
|
5382
|
+
});
|
|
5383
|
+
view.handleInput('l');
|
|
5384
|
+
await tick();
|
|
5385
|
+
const rows = rightRows(view, 160);
|
|
5386
|
+
assert.ok(rows.some((row) => row.trim() === 'Labels'), `the title is the sub-mode's name: ${JSON.stringify(rows.slice(0, 2))}`);
|
|
5387
|
+
assert.ok(!rows[0].includes('space toggle'), 'the title carries no parenthetical key list');
|
|
5388
|
+
assert.ok(!rows[0].includes('ctrl+s'), 'and no save key either');
|
|
5389
|
+
});
|
|
5390
|
+
|
|
5391
|
+
test('while the labels editor is open the footer carries its keys instead of the legend', async () => {
|
|
5392
|
+
const view = await opened({
|
|
5393
|
+
labels: [{ name: 'bug' }],
|
|
5394
|
+
loadLabels: () => ({ ok: true, labels: [{ name: 'bug' }] }),
|
|
5395
|
+
});
|
|
5396
|
+
const legend = footerOf(view, 200);
|
|
5397
|
+
for (const token of READ_LEGEND) assert.ok(legend.includes(token), `the legend names ${token} before the editor: ${legend}`);
|
|
5398
|
+
|
|
5399
|
+
view.handleInput('l');
|
|
5400
|
+
await tick();
|
|
5401
|
+
const footer = footerOf(view, 200);
|
|
5402
|
+
for (const token of ['space toggle', 'n new', 'ctrl+s apply', 'esc back']) {
|
|
5403
|
+
assert.ok(footer.includes(token), `the labels keys are on the footer row: ${token} in ${footer}`);
|
|
5404
|
+
}
|
|
5405
|
+
for (const token of ['↑↓ move', '←→ bucket', 'l labels', 'a assign', 'c comment', 'x close', 'o web', 't search', 'g all issues', 'esc close']) {
|
|
5406
|
+
assert.ok(!footer.includes(token), `the reading legend left the row: ${token} in ${footer}`);
|
|
5407
|
+
}
|
|
5408
|
+
assert.equal(view.render(200).map(strip).filter((line) => /space toggle/.test(line)).length, 1,
|
|
5409
|
+
'exactly one row names the editor keys');
|
|
5410
|
+
});
|
|
5411
|
+
|
|
5412
|
+
test('leaving the labels editor restores the reading legend', async () => {
|
|
5413
|
+
const view = await opened({
|
|
5414
|
+
labels: [{ name: 'bug' }],
|
|
5415
|
+
loadLabels: () => ({ ok: true, labels: [{ name: 'bug' }] }),
|
|
5416
|
+
});
|
|
5417
|
+
view.handleInput('l');
|
|
5418
|
+
await tick();
|
|
5419
|
+
view.handleInput('escape');
|
|
5420
|
+
const footer = footerOf(view, 200);
|
|
5421
|
+
assert.equal(view.state.mode, 'list', 'esc backs out of the editor');
|
|
5422
|
+
for (const token of READ_LEGEND) assert.ok(footer.includes(token), `the legend is back: ${token} in ${footer}`);
|
|
5423
|
+
assert.ok(!footer.includes('space toggle'), 'the editor keys left with the editor');
|
|
5424
|
+
assert.ok(!footer.includes('ctrl+s apply'), 'and so did the save key');
|
|
5425
|
+
});
|
|
5426
|
+
|
|
5427
|
+
test('the assignees editor title is its name alone and its keys ride the footer', async () => {
|
|
5428
|
+
const view = await opened({ loadAssignees: () => ({ ok: true, users: [{ login: 'ann' }] }) });
|
|
5429
|
+
view.handleInput('a');
|
|
5430
|
+
await tick();
|
|
5431
|
+
const rows = rightRows(view, 160);
|
|
5432
|
+
assert.ok(rows.some((row) => row.trim() === 'Assignees'), `the title is the sub-mode's name: ${JSON.stringify(rows.slice(0, 2))}`);
|
|
5433
|
+
assert.ok(!rows[0].includes('space toggle'), 'the title carries no parenthetical key list');
|
|
5434
|
+
const footer = footerOf(view, 200);
|
|
5435
|
+
for (const token of ['space toggle', 'ctrl+s apply', 'esc back']) assert.ok(footer.includes(token), `the assignee keys are on the footer row: ${token} in ${footer}`);
|
|
5436
|
+
for (const token of ['↑↓ move', '←→ bucket', 'o web', 't search', 'g all issues', 'esc close']) {
|
|
5437
|
+
assert.ok(!footer.includes(token), `the reading legend left the row: ${token} in ${footer}`);
|
|
5438
|
+
}
|
|
5439
|
+
view.handleInput('escape');
|
|
5440
|
+
for (const token of READ_LEGEND) assert.ok(footerOf(view, 200).includes(token), `the legend is back: ${token}`);
|
|
5441
|
+
});
|
|
5442
|
+
|
|
5443
|
+
test('the comment editor title is its name alone and its keys ride the footer', async () => {
|
|
5444
|
+
const view = await opened();
|
|
5445
|
+
view.handleInput('c');
|
|
5446
|
+
const rows = rightRows(view, 160);
|
|
5447
|
+
assert.ok(rows.some((row) => row.trim() === 'Leave a comment…'), `the title is the sub-mode's name: ${JSON.stringify(rows.slice(0, 2))}`);
|
|
5448
|
+
assert.ok(!rows[0].includes('enter newline'), 'the title carries no parenthetical key list');
|
|
5449
|
+
const footer = footerOf(view, 200);
|
|
5450
|
+
for (const token of ['enter newline', 'ctrl+s post', 'esc discard']) assert.ok(footer.includes(token), `the comment keys are on the footer row: ${token} in ${footer}`);
|
|
5451
|
+
for (const token of ['↑↓ move', '←→ bucket', 'l labels', 'c comment', 'o web', 't search', 'g all issues', 'esc close']) {
|
|
5452
|
+
assert.ok(!footer.includes(token), `the reading legend left the row: ${token} in ${footer}`);
|
|
5453
|
+
}
|
|
5454
|
+
view.handleInput('escape');
|
|
5455
|
+
assert.equal(view.state.mode, 'list', 'an empty draft leaves without asking');
|
|
5456
|
+
for (const token of READ_LEGEND) assert.ok(footerOf(view, 200).includes(token), `the legend is back: ${token}`);
|
|
5457
|
+
});
|
|
5458
|
+
|
|
5459
|
+
test('the search box keeps its own footer while a legend waits behind it', async () => {
|
|
5460
|
+
const view = await opened();
|
|
5461
|
+
view.handleInput('t');
|
|
5462
|
+
const footer = footerOf(view, 200);
|
|
5463
|
+
assert.match(footer, /enter\/esc keep/, 'the search keys own the row in the box');
|
|
5464
|
+
assert.ok(!footer.includes('↑↓ move'), 'and the reading legend is not on it');
|
|
5465
|
+
view.handleInput('escape');
|
|
5466
|
+
assert.match(footerOf(view, 200), /↑↓ move/, 'leaving the box restores the reading legend');
|
|
5467
|
+
});
|
|
5468
|
+
|
|
5469
|
+
test('the label-creation sub-mode puts its keys on the footer, not in the row', async () => {
|
|
5470
|
+
const view = await opened({
|
|
5471
|
+
labels: [{ name: 'bug' }],
|
|
5472
|
+
loadLabels: () => ({ ok: true, labels: [{ name: 'bug' }] }),
|
|
5473
|
+
});
|
|
5474
|
+
view.handleInput('l');
|
|
5475
|
+
await tick();
|
|
5476
|
+
view.handleInput('n');
|
|
5477
|
+
const creation = rightRows(view, 160).find((row) => row.includes('new:')) ?? '';
|
|
5478
|
+
assert.match(creation, /new: █/, 'the creation row is the field alone');
|
|
5479
|
+
assert.ok(!creation.includes('enter add'), `the row carries no parenthetical key list: ${creation}`);
|
|
5480
|
+
assert.ok(!creation.includes('esc cancel'), `and no cancel key either: ${creation}`);
|
|
5481
|
+
|
|
5482
|
+
const footer = footerOf(view, 200);
|
|
5483
|
+
for (const token of ['enter add', 'esc cancel']) assert.ok(footer.includes(token), `the creation keys are on the footer row: ${token} in ${footer}`);
|
|
5484
|
+
for (const token of ['space toggle', 'n new', 'ctrl+s apply', 'esc back']) {
|
|
5485
|
+
assert.ok(!footer.includes(token), `the parent editor keys left the row: ${token} in ${footer}`);
|
|
5486
|
+
}
|
|
5487
|
+
|
|
5488
|
+
view.handleInput('escape');
|
|
5489
|
+
assert.equal(view.state.labelCreating, false, 'esc cancels the creation');
|
|
5490
|
+
for (const token of ['space toggle', 'ctrl+s apply', 'esc back']) {
|
|
5491
|
+
assert.ok(footerOf(view, 200).includes(token), `cancelling restores the editor keys: ${token}`);
|
|
5492
|
+
}
|
|
5493
|
+
});
|
|
5494
|
+
|
|
5495
|
+
test('the comment-discard sub-mode puts its keys on the footer, not in the ask', async () => {
|
|
5496
|
+
const view = await opened();
|
|
5497
|
+
view.handleInput('c');
|
|
5498
|
+
for (const ch of 'keep me') view.handleInput(ch);
|
|
5499
|
+
view.handleInput('escape');
|
|
5500
|
+
const ask = rightRows(view, 160).find((row) => row.includes('Discard this draft?')) ?? '';
|
|
5501
|
+
assert.ok(!ask.includes('y discard'), `the ask carries no parenthetical key list: ${ask}`);
|
|
5502
|
+
assert.ok(!ask.includes('keep editing'), `and no keep key either: ${ask}`);
|
|
5503
|
+
|
|
5504
|
+
const footer = footerOf(view, 200);
|
|
5505
|
+
for (const token of ['y discard', 'n/esc keep editing']) {
|
|
5506
|
+
assert.ok(footer.includes(token), `the discard keys are on the footer row: ${token} in ${footer}`);
|
|
5507
|
+
}
|
|
5508
|
+
for (const token of ['enter newline', 'ctrl+s post', 'esc discard']) {
|
|
5509
|
+
assert.ok(!footer.includes(token), `the editor keys left the row: ${token} in ${footer}`);
|
|
5510
|
+
}
|
|
5511
|
+
|
|
5512
|
+
view.handleInput('n');
|
|
5513
|
+
assert.equal(view.state.discardAsk, false, 'n returns to editing');
|
|
5514
|
+
for (const token of ['enter newline', 'ctrl+s post', 'esc discard']) {
|
|
5515
|
+
assert.ok(footerOf(view, 200).includes(token), `returning restores the editor keys: ${token}`);
|
|
5516
|
+
}
|
|
5517
|
+
});
|
|
5518
|
+
|
|
5519
|
+
test('while the labels editor loads, the footer offers only the exit that works', async () => {
|
|
5520
|
+
const gate = deferred();
|
|
5521
|
+
const view = await opened({ loadLabels: () => gate.promise });
|
|
5522
|
+
view.handleInput('l');
|
|
5523
|
+
await tick();
|
|
5524
|
+
assert.equal(view.state.mode, 'labels', 'the editor is open while its list is in flight');
|
|
5525
|
+
const footer = footerOf(view, 200);
|
|
5526
|
+
assert.ok(footer.includes('esc back'), `esc back is the one key accepted then: ${footer}`);
|
|
5527
|
+
for (const token of ['space toggle', 'n new', 'ctrl+s apply']) {
|
|
5528
|
+
assert.ok(!footer.includes(token), `the loading editor cannot ${token}: ${footer}`);
|
|
5529
|
+
}
|
|
5530
|
+
|
|
5531
|
+
gate.resolve({ ok: true, labels: [{ name: 'bug' }] });
|
|
5532
|
+
await tick();
|
|
5533
|
+
for (const token of ['space toggle', 'n new', 'ctrl+s apply', 'esc back']) {
|
|
5534
|
+
assert.ok(footerOf(view, 200).includes(token), `the keys arrive with the list: ${token}`);
|
|
5535
|
+
}
|
|
5536
|
+
});
|
|
5537
|
+
|
|
5538
|
+
test('while the assignees editor loads, the footer offers only the exit that works', async () => {
|
|
5539
|
+
const gate = deferred();
|
|
5540
|
+
const view = await opened({ loadAssignees: () => gate.promise });
|
|
5541
|
+
view.handleInput('a');
|
|
5542
|
+
await tick();
|
|
5543
|
+
assert.equal(view.state.mode, 'assignees', 'the editor is open while its list is in flight');
|
|
5544
|
+
const footer = footerOf(view, 200);
|
|
5545
|
+
assert.ok(footer.includes('esc back'), `esc back is the one key accepted then: ${footer}`);
|
|
5546
|
+
for (const token of ['space toggle', 'ctrl+s apply']) {
|
|
5547
|
+
assert.ok(!footer.includes(token), `the loading editor cannot ${token}: ${footer}`);
|
|
5548
|
+
}
|
|
5549
|
+
|
|
5550
|
+
gate.resolve({ ok: true, users: [{ login: 'ann' }] });
|
|
5551
|
+
await tick();
|
|
5552
|
+
for (const token of ['space toggle', 'ctrl+s apply', 'esc back']) {
|
|
5553
|
+
assert.ok(footerOf(view, 200).includes(token), `the keys arrive with the list: ${token}`);
|
|
5554
|
+
}
|
|
5555
|
+
});
|
|
5556
|
+
|
|
5557
|
+
test('an empty bucket offers none of the five issue hints and keeps the rest', async () => {
|
|
5558
|
+
const { view } = makeView({
|
|
5559
|
+
pages: pagesOf([[], [issue(9)], []]),
|
|
5560
|
+
issues: [],
|
|
5561
|
+
loadIssue: (n) => ({ ok: true, issue: issue(n), comments: [] }),
|
|
5562
|
+
});
|
|
5563
|
+
await tick();
|
|
5564
|
+
const footer = footerOf(view, 220);
|
|
5565
|
+
for (const token of ISSUE_ACTIONS) assert.ok(!footer.includes(token), `nothing is focused, so ${token} is absent: ${footer}`);
|
|
5566
|
+
for (const token of ['↑↓ move', '←→ bucket', 't search', 'g all issues', 'esc close']) {
|
|
5567
|
+
assert.ok(footer.includes(token), `the key that still works stays: ${token} in ${footer}`);
|
|
5568
|
+
}
|
|
5569
|
+
});
|
|
5570
|
+
|
|
5571
|
+
test('a failed read offers none of the five issue hints and keeps the rest', async () => {
|
|
5572
|
+
const { view } = makeView({
|
|
5573
|
+
pages: pagesOf([[issue(1)], [], []]),
|
|
5574
|
+
issues: [issue(1)],
|
|
5575
|
+
loadIssue: () => ({ ok: false, error: 'gh issue view failed: HTTP 500' }),
|
|
5576
|
+
});
|
|
5577
|
+
await tick();
|
|
5578
|
+
const footer = footerOf(view, 220);
|
|
5579
|
+
for (const token of ISSUE_ACTIONS) assert.ok(!footer.includes(token), `an unreadable issue offers ${token}: ${footer}`);
|
|
5580
|
+
for (const token of ['↑↓ move', '←→ bucket', 't search', 'g all issues', 'esc close']) {
|
|
5581
|
+
assert.ok(footer.includes(token), `the key that still works stays: ${token} in ${footer}`);
|
|
5582
|
+
}
|
|
5583
|
+
});
|
|
5584
|
+
|
|
5585
|
+
test('an issue still loading offers none of the five issue hints', async () => {
|
|
5586
|
+
const gate = deferred();
|
|
5587
|
+
const { view } = makeView({
|
|
5588
|
+
pages: pagesOf([[issue(1)], [], []]),
|
|
5589
|
+
issues: [issue(1)],
|
|
5590
|
+
loadIssue: () => gate.promise,
|
|
5591
|
+
});
|
|
5592
|
+
await tick();
|
|
5593
|
+
const footer = footerOf(view, 220);
|
|
5594
|
+
for (const token of ISSUE_ACTIONS) assert.ok(!footer.includes(token), `a pending issue offers ${token}: ${footer}`);
|
|
5595
|
+
for (const token of ['↑↓ move', '←→ bucket', 't search', 'g all issues', 'esc close']) {
|
|
5596
|
+
assert.ok(footer.includes(token), `the key that still works stays: ${token} in ${footer}`);
|
|
5597
|
+
}
|
|
5598
|
+
gate.resolve({ ok: true, issue: issue(1, { permissions: EDITABLE }), comments: [] });
|
|
5599
|
+
await tick();
|
|
5600
|
+
for (const token of ISSUE_ACTIONS) assert.ok(footerOf(view, 220).includes(token), `the loaded issue offers ${token}`);
|
|
5601
|
+
});
|
|
5602
|
+
|
|
5603
|
+
test('a focused issue with no TRIAGE keeps c and o web but not l, a or x', async () => {
|
|
5604
|
+
const { view } = makeView({
|
|
5605
|
+
pages: pagesOf([[issue(1)], [], []]),
|
|
5606
|
+
issues: [issue(1)],
|
|
5607
|
+
loadIssue: (n) => ({ ok: true, issue: issue(n, { permissions: { canEditLabels: false, canEditAssignees: false, canCloseIssues: false } }), comments: [] }),
|
|
5608
|
+
});
|
|
5609
|
+
await tick();
|
|
5610
|
+
const footer = footerOf(view, 220);
|
|
5611
|
+
assert.ok(footer.includes('c comment'), `commenting needs read access only: ${footer}`);
|
|
5612
|
+
assert.ok(footer.includes('o web'), `the browser needs read access only: ${footer}`);
|
|
5613
|
+
for (const token of ['l labels', 'a assign', 'x close']) {
|
|
5614
|
+
assert.ok(!footer.includes(token), `no capability, no ${token}: ${footer}`);
|
|
5615
|
+
}
|
|
5616
|
+
for (const token of ['↑↓ move', '←→ bucket', 't search', 'g all issues', 'esc close']) {
|
|
5617
|
+
assert.ok(footer.includes(token), `the key that still works stays: ${token} in ${footer}`);
|
|
5618
|
+
}
|
|
5619
|
+
});
|
|
5620
|
+
|
|
5621
|
+
test('a focused issue the repository role permits offers all five', async () => {
|
|
5622
|
+
const view = await opened();
|
|
5623
|
+
const footer = footerOf(view, 220);
|
|
5624
|
+
for (const token of ISSUE_ACTIONS) assert.ok(footer.includes(token), `the permitted issue offers ${token}: ${footer}`);
|
|
5625
|
+
});
|
|
5626
|
+
|
|
5627
|
+
test('a stale hint can never fire: the key handlers keep their own guards', async () => {
|
|
5628
|
+
const calls = [];
|
|
5629
|
+
const { view } = makeView({
|
|
5630
|
+
pages: pagesOf([[], [issue(9)], []]),
|
|
5631
|
+
issues: [],
|
|
5632
|
+
loadIssue: (n) => ({ ok: true, issue: issue(n), comments: [] }),
|
|
5633
|
+
actions: {
|
|
5634
|
+
postComment: (_n, text) => { calls.push(['comment', text]); return { ok: true }; },
|
|
5635
|
+
openBrowser: (n) => { calls.push(['browser', n]); return { ok: true }; },
|
|
5636
|
+
setState: (n, state) => { calls.push(['state', n, state]); return { ok: true }; },
|
|
5637
|
+
},
|
|
5638
|
+
});
|
|
5639
|
+
await tick();
|
|
5640
|
+
view.handleInput('c');
|
|
5641
|
+
await tick();
|
|
5642
|
+
assert.equal(view.state.mode, 'list', 'c opens no editor with nothing focused');
|
|
5643
|
+
view.handleInput('o');
|
|
5644
|
+
view.handleInput('x');
|
|
5645
|
+
await tick();
|
|
5646
|
+
assert.deepEqual(calls, [], 'and no action ran');
|
|
5647
|
+
});
|
|
5648
|
+
});
|
|
5649
|
+
|
|
5650
|
+
// S21 (T17): the human's own words — «me la asigne a mi o me quite la
|
|
5651
|
+
// asignacion … no se refresca altiro los tabs … actualmente eso demora o no
|
|
5652
|
+
// refrezca de hecho hasta que lo cierro y abro panel». A save that changed the
|
|
5653
|
+
// VIEWER's own assignment changed which bucket of this panel holds the issue:
|
|
5654
|
+
// `assigned` gains or loses the row while `mine` (authored) and `involved`
|
|
5655
|
+
// (excludes the viewer's own issues) are untouched. The page the reader holds is
|
|
5656
|
+
// answered by the bucket's OLD read, so it kept painting the pre-write row and
|
|
5657
|
+
// count. The write's own answer names the fact (`self`), and the stale page is
|
|
5658
|
+
// read again through the same seam — never patched with a row invented here.
|
|
5659
|
+
describe('S21: a self-assignment repaints the panel without reopening it', () => {
|
|
5660
|
+
const serverPage = (issues) => ({ ok: true, issues, total: issues.length, hasNextPage: false });
|
|
5661
|
+
|
|
5662
|
+
function assignmentView(state) {
|
|
5663
|
+
const requests = [];
|
|
5664
|
+
const details = { assignees: state.detailAssignees };
|
|
5665
|
+
const view = createIssuesView({
|
|
5666
|
+
helpers,
|
|
5667
|
+
pages: [
|
|
5668
|
+
{ id: 'mine', label: 'My issues', issues: state.mine, total: state.mine.length },
|
|
5669
|
+
{ id: 'assigned', label: 'Assigned', issues: state.assigned, total: state.assigned.length },
|
|
5670
|
+
{ id: 'involved', label: 'Involved', issues: [], total: 0 },
|
|
5671
|
+
],
|
|
5672
|
+
rowsAvailable: () => 24,
|
|
5673
|
+
requestRender: () => {},
|
|
5674
|
+
done: () => {},
|
|
5675
|
+
loadIssuePage: (request) => {
|
|
5676
|
+
requests.push(request.bucketId);
|
|
5677
|
+
if (request.bucketId === 'assigned') return serverPage(state.assigned);
|
|
5678
|
+
if (request.bucketId === 'mine') return serverPage(state.mine);
|
|
5679
|
+
return serverPage([]);
|
|
5680
|
+
},
|
|
5681
|
+
loadIssue: (n) => ({
|
|
5682
|
+
ok: true,
|
|
5683
|
+
issue: issue(n, { permissions: EDITABLE, assignees: details.assignees.map((login) => ({ login })) }),
|
|
5684
|
+
comments: [],
|
|
5685
|
+
}),
|
|
5686
|
+
loadAssignees: () => ({ ok: true, users: [{ login: 'me', name: '' }, { login: 'bob', name: 'Bob' }] }),
|
|
5687
|
+
actions: {
|
|
5688
|
+
editAssignees: (number, changes) => {
|
|
5689
|
+
requests.push(['write', number, changes]);
|
|
5690
|
+
return state.onWrite(number, changes);
|
|
5691
|
+
},
|
|
5692
|
+
},
|
|
5693
|
+
});
|
|
5694
|
+
return { view, requests };
|
|
5695
|
+
}
|
|
5696
|
+
|
|
5697
|
+
test('assigning yourself adds the row to Assigned and its count follows', async () => {
|
|
5698
|
+
const state = {
|
|
5699
|
+
mine: [cursorRow('c1', issue(1))],
|
|
5700
|
+
assigned: [],
|
|
5701
|
+
detailAssignees: [],
|
|
5702
|
+
onWrite: (number, changes) => {
|
|
5703
|
+
if (changes.add.includes('me')) state.assigned = [cursorRow('c2', issue(number))];
|
|
5704
|
+
return { ok: true, changed: true, self: true };
|
|
5705
|
+
},
|
|
5706
|
+
};
|
|
5707
|
+
const { view, requests } = assignmentView(state);
|
|
5708
|
+
view.render(160);
|
|
5709
|
+
await tick();
|
|
5710
|
+
assert.match(bodyOf(view, 160), /Assigned \(0\)/, 'the bucket starts empty');
|
|
5711
|
+
view.handleInput('a');
|
|
5712
|
+
await tick();
|
|
5713
|
+
view.handleInput('space');
|
|
5714
|
+
const before = requests.length;
|
|
5715
|
+
view.handleInput('ctrl+s');
|
|
5716
|
+
await tick();
|
|
5717
|
+
await tick();
|
|
5718
|
+
assert.deepEqual(requests.slice(before).filter((entry) => typeof entry === 'string'), ['assigned'],
|
|
5719
|
+
'the write invalidated the Assigned page, so that bucket is read again');
|
|
5720
|
+
assert.match(bodyOf(view, 160), /Assigned \(1\)/, 'and its count follows at once, without a tab switch');
|
|
5721
|
+
view.handleInput('tab');
|
|
5722
|
+
await tick();
|
|
5723
|
+
assert.equal(leftColumn(view, 160).match(/issue title 1(?!\d)/g).length, 1,
|
|
5724
|
+
'the row is in the Assigned tab, once');
|
|
5725
|
+
});
|
|
5726
|
+
|
|
5727
|
+
test('removing your own assignment takes the row and its count off the Assigned tab at once', async () => {
|
|
5728
|
+
const state = {
|
|
5729
|
+
mine: [],
|
|
5730
|
+
assigned: [cursorRow('c1', issue(21))],
|
|
5731
|
+
detailAssignees: ['me'],
|
|
5732
|
+
onWrite: (_number, changes) => {
|
|
5733
|
+
if (changes.remove.includes('me')) state.assigned = [];
|
|
5734
|
+
return { ok: true, changed: true, self: true };
|
|
5735
|
+
},
|
|
5736
|
+
};
|
|
5737
|
+
const { view } = assignmentView(state);
|
|
5738
|
+
view.render(160);
|
|
5739
|
+
await tick();
|
|
5740
|
+
view.handleInput('tab');
|
|
5741
|
+
await tick();
|
|
5742
|
+
assert.match(bodyOf(view, 160), /Assigned \(1\)/, 'the row is on the Assigned tab before the write');
|
|
5743
|
+
view.handleInput('a');
|
|
5744
|
+
await tick();
|
|
5745
|
+
view.handleInput('space');
|
|
5746
|
+
view.handleInput('ctrl+s');
|
|
5747
|
+
await tick();
|
|
5748
|
+
await tick();
|
|
5749
|
+
const body = bodyOf(view, 160);
|
|
5750
|
+
assert.match(body, /Assigned \(0\)/, 'the count follows the removal on the tab itself');
|
|
5751
|
+
assert.ok(!leftColumn(view, 160).includes('issue title 21'), 'and the row is gone, not just unmarked');
|
|
5752
|
+
});
|
|
5753
|
+
|
|
5754
|
+
test('an issue you authored appears once in each tab it belongs to', async () => {
|
|
5755
|
+
const state = {
|
|
5756
|
+
mine: [cursorRow('c1', issue(12))],
|
|
5757
|
+
assigned: [],
|
|
5758
|
+
detailAssignees: [],
|
|
5759
|
+
onWrite: (number, changes) => {
|
|
5760
|
+
if (changes.add.includes('me')) state.assigned = [cursorRow('c2', issue(number))];
|
|
5761
|
+
return { ok: true, changed: true, self: true };
|
|
5762
|
+
},
|
|
5763
|
+
};
|
|
5764
|
+
const { view } = assignmentView(state);
|
|
5765
|
+
view.render(160);
|
|
5766
|
+
await tick();
|
|
5767
|
+
view.handleInput('a');
|
|
5768
|
+
await tick();
|
|
5769
|
+
view.handleInput('space');
|
|
5770
|
+
view.handleInput('ctrl+s');
|
|
5771
|
+
await tick();
|
|
5772
|
+
await tick();
|
|
5773
|
+
assert.equal(leftColumn(view, 160).match(/issue title 12(?!\d)/g).length, 1,
|
|
5774
|
+
'the authored issue stays in My issues, exactly once');
|
|
5775
|
+
view.handleInput('tab');
|
|
5776
|
+
await tick();
|
|
5777
|
+
assert.equal(leftColumn(view, 160).match(/issue title 12(?!\d)/g).length, 1,
|
|
5778
|
+
'and it is in Assigned too, exactly once');
|
|
5779
|
+
});
|
|
5780
|
+
|
|
5781
|
+
test('an assignee save that is not the viewer\'s reads no bucket again', async () => {
|
|
5782
|
+
const state = {
|
|
5783
|
+
mine: [cursorRow('c1', issue(1))],
|
|
5784
|
+
assigned: [],
|
|
5785
|
+
detailAssignees: [],
|
|
5786
|
+
onWrite: () => ({ ok: true, changed: true, self: false }),
|
|
5787
|
+
};
|
|
5788
|
+
const { view, requests } = assignmentView(state);
|
|
5789
|
+
view.render(160);
|
|
5790
|
+
await tick();
|
|
5791
|
+
view.handleInput('a');
|
|
5792
|
+
await tick();
|
|
5793
|
+
view.handleInput('down');
|
|
5794
|
+
view.handleInput('space');
|
|
5795
|
+
const before = requests.length;
|
|
5796
|
+
view.handleInput('ctrl+s');
|
|
5797
|
+
await tick();
|
|
5798
|
+
await tick();
|
|
5799
|
+
assert.deepEqual(requests.slice(before).filter((entry) => typeof entry === 'string'), [],
|
|
5800
|
+
'a write that leaves the viewer\'s own assignment alone repaints no bucket');
|
|
5801
|
+
assert.match(bodyOf(view, 160), /Assigned \(0\)/, 'and no count moved');
|
|
5802
|
+
});
|
|
5803
|
+
|
|
5804
|
+
test('a rejected assignee save leaves the old rows and count exactly as they were', async () => {
|
|
5805
|
+
const state = {
|
|
5806
|
+
mine: [],
|
|
5807
|
+
assigned: [cursorRow('c1', issue(21))],
|
|
5808
|
+
detailAssignees: ['me'],
|
|
5809
|
+
onWrite: () => ({ ok: false, error: 'permission denied by GitHub' }),
|
|
5810
|
+
};
|
|
5811
|
+
const { view, requests } = assignmentView(state);
|
|
5812
|
+
view.render(160);
|
|
5813
|
+
await tick();
|
|
5814
|
+
view.handleInput('tab');
|
|
5815
|
+
await tick();
|
|
5816
|
+
view.handleInput('a');
|
|
5817
|
+
await tick();
|
|
5818
|
+
view.handleInput('space');
|
|
5819
|
+
const before = requests.length;
|
|
5820
|
+
view.handleInput('ctrl+s');
|
|
5821
|
+
await tick();
|
|
5822
|
+
await tick();
|
|
5823
|
+
assert.deepEqual(requests.slice(before).filter((entry) => typeof entry === 'string'), [],
|
|
5824
|
+
'a failed write invalidates nothing');
|
|
5825
|
+
assert.match(bodyOf(view, 100), /permission denied by GitHub/, 'the rejection is visible');
|
|
5826
|
+
assert.equal(view.state.mode, 'assignees', 'the editor keeps the draft');
|
|
5827
|
+
assert.match(bodyOf(view, 160), /Assigned \(1\)/, 'the count is the pre-write one');
|
|
5828
|
+
assert.ok(leftColumn(view, 160).includes('issue title 21'), 'and the row is still there');
|
|
5829
|
+
});
|
|
5830
|
+
});
|