v0.36.0 1fb2421

summary-navigation.test.mjs RawHistoryFolder

1// SPDX-License-Identifier: AGPL-3.0-or-later
2
3import assert from 'node:assert/strict';
4import { readFileSync } from 'node:fs';
5import { test } from 'node:test';
6import { runInNewContext } from 'node:vm';
7import { el, installDom } from './dom.mjs';
8
9const source = readFileSync(new URL('../static/js/ermite.js', import.meta.url), 'utf8');
10
11test('main navigation ignores rail rows, but still drives main tables', () => {
12  const doc = installDom();
13  const main = el('main', { id: 'main' });
14  const recent = el('tr');
15  const rail = el('aside', { cls: 'rail' }, el('tbody', { attrs: { 'data-rows': '' } }, recent));
16  doc.body.append(main, rail);
17  const scrolls = [];
18  main.scrollBy = (_, y) => scrolls.push(['main-by', y]);
19  main.scrollTo = (_, y) => scrolls.push(['main-to', y]);
20  const context = {
21    window: { ermiteRail: { step: () => false } },
22    $: (s) => doc.querySelector(s),
23    $$: (s) => {
24      const child = s.startsWith('[data-rows] > ') ? s.slice('[data-rows] > '.length) : null;
25      if (child) return [...doc.querySelectorAll('[data-rows]')].flatMap((table) => table.children.filter((row) => row.matches(child)));
26      return [...doc.querySelectorAll(s)];
27    },
28    body: () => doc.body,
29    flash() {}, setTimeout() {},
30    scrollBy: (_, y) => scrolls.push(['page-by', y]),
31    scrollTo: (_, y) => scrolls.push(['page-to', y]),
32  };
33  runInNewContext(source.slice(source.indexOf('  const visibleRows ='), source.indexOf('  window.ermite = ermite;')) + '\nwindow.ermite = ermite;', context);
34  const E = context.window.ermite;
35  E.move(1); E.move(-1); E.edge(false); E.edge(true);
36  assert.deepEqual(scrolls, [['page-by', 180], ['main-by', 180], ['page-by', -180], ['main-by', -180], ['page-to', 0], ['main-to', 0], ['page-to', 1e9], ['main-to', 1e9]]);
37  assert.equal(recent.hasAttribute('data-cursor'), false);
38  const first = el('tr');
39  const last = el('tr');
40  main.append(el('tbody', { attrs: { 'data-rows': '' } }, first, last));
41  E.move(1);
42  assert.equal(first.hasAttribute('data-cursor'), true);
43  E.edge(true);
44  assert.equal(last.hasAttribute('data-cursor'), true);
45  assert.equal(first.hasAttribute('data-cursor'), false);
46  assert.equal(recent.hasAttribute('data-cursor'), false);
47});

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 4

Tags 45

↑↓ moveenter openesc close