v0.21.0 ef38ad0

mr.test.mjs RawHistoryFolder

1// Tests of the pure core of the merge request page (static/js/mr.js). Run with
2//   node --test 'internal/adapters/web/jstest/*.test.mjs'
3import assert from 'node:assert/strict';
4import { test } from 'node:test';
5
6globalThis.window = globalThis;
7globalThis.document = { readyState: 'complete', querySelector: () => null, querySelectorAll: () => [] };
8await import('../static/js/mr.js');
9const C = window.ermiteMR.core;
10
11test('windowOf: the start of the window of a file', () => {
12  assert.equal(C.windowOf('f1', 25), 0);
13  assert.equal(C.windowOf('f25', 25), 0);
14  assert.equal(C.windowOf('f26', 25), 25);
15  assert.equal(C.windowOf('f84', 25), 75);
16  assert.equal(C.windowOf('c3', 25), -1, 'not a file');
17  assert.equal(C.windowOf('f0', 25), -1);
18});
19
20test('menuKey: modes by number, D toggles the deletion, nothing else', () => {
21  assert.deepEqual(C.menuKey('1', 2), { mode: 0 });
22  assert.deepEqual(C.menuKey('2', 2), { mode: 1 });
23  assert.equal(C.menuKey('3', 2), null, 'no third mode');
24  assert.equal(C.menuKey('0', 2), null);
25  assert.deepEqual(C.menuKey('D', 2), { toggle: true });
26  assert.equal(C.menuKey('d', 2), null, 'd is the split layout');
27  assert.equal(C.menuKey('Enter', 2), null, 'the browser submits: the focus is on the button');
28  assert.equal(C.menuKey('M', 2), null);
29});
30
31test('step: stays in the list', () => {
32  assert.equal(C.step(0, 1, 3), 1);
33  assert.equal(C.step(2, 1, 3), 2);
34  assert.equal(C.step(0, -1, 3), 0);
35  assert.equal(C.step(-1, 1, 3), 0);
36  assert.equal(C.step(-1, -1, 3), 2);
37  assert.equal(C.step(0, 1, 0), -1);
38});

Keyboard shortcuts

Single-key shortcuts are on. ctrl k and esc work whatever this says.

ctrl k :
go to a section, branch, tag, file or repository
?
this list
j k
move the row cursor down / up
enter
open the row under the cursor; on Files, a directory opens or closes in place
↑ ↓ ← → home end
in the file tree (focus on a row): previous / next row, close / open a directory or go to its parent / first entry, first / last row. They never open a file
l h
on Files: open a directory or a file / close a directory or go up to its parent, then to the parent page. Elsewhere: into the side panel (on a merge request, its files) / back to the content; there j k move between its controls
g g G
first / last row
/
filter the list; on Files, find a file anywhere in the repository (esc clears, enter opens the best match)
b
switch branch or tag
g s g f g c g b g m g i g r g a
tabs: summary, files, commits, branches & tags, merge requests, issues, releases, actions (when available)
g h
home
w
wide mode: use the whole width of the screen, or not (remembered)
y
copy a permalink pinned to the commit
d u x
diff: split / unified / collapse or expand all
e E
diff: the whole file in view / every file, with the lines the hunks hide
n
merge request: next note in the diff
esc
close a dialog, leave a field

Branches 2

Tags 45

↑↓ moveenter openesc close