Files
gitea-nova/Tests/README.md
T
thatguygriffandClaude Opus 5 87851de921
CI / Tests (push) Successful in 36s
CI / Generated images (push) Successful in 1m1s
Support instances that serve SSH from another hostname
Discovery matched a git remote's host against the instance URL's host, so
a server answering SSH on a different name than its web UI resolved to
nothing — and said so only in a debug log.

Resolution now runs in three stages. A remote host is matched directly,
then against configured aliases, and failing both the instances are asked
for the repository: Gitea publishes its SSH hostname in a repository's
ssh_url, so the right instance identifies itself. What that turns up is
saved as a host alias, so later repositories on the same host resolve
with no lookup at all, and the mapping is visible and editable rather
than hidden. Each unknown host is probed at most once per session.

When nothing resolves the sidebar now names the unmatched host and offers
Add Host Alias, instead of showing an empty section.

Aliases can also be written by hand as "remote-host = instance URL",
accepting =, -> and =>, ignoring ports, and skipping # comments. List
preferences now merge workspace entries onto global ones rather than
letting an empty global array mask them.

Adds Tests/host-aliases.test.js covering both directions: unmatched hosts
reported and nothing persisted, a hand-written alias, detection from
ssh_url, and a later repository resolving from the stored alias without a
probe. 131 checks across three suites.

Also adds CLAUDE.md, and .gitea/workflows/ci.yml running the suites,
script syntax checks, manifest validation, and a generated-image check.
Tools/make-icons.py gains --check, which compares decompressed pixels so
a differing zlib version cannot fail it spuriously.

Co-Authored-By: Claude Opus 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01MQuusXgZC2dzwpJJ1qhtti
2026-08-28 20:10:05 -03:00

40 lines
2.3 KiB
Markdown

# Tests
Two suites that run the extension's real code under plain Node. Nova's runtime
and a Gitea server are both stubbed, so there is nothing to install and nothing
to reach over the network.
```sh
Tests/run.sh # all suites
node Tests/units.test.js
node Tests/host-aliases.test.js
node Tests/integration.test.js
```
Each exits non-zero on failure, so `Tests/run.sh` works as a CI step.
## What is here
| File | Purpose |
| --- | --- |
| `nova-stub.js` | Stands in for Nova's runtime: `nova.*`, `TreeView`, `TreeItem`, `Issue`, `IssueCollection`, `Process`, `Range`, `NotificationRequest`. Records messages, clipboard writes, and opened files on globals so assertions can inspect them. |
| `fake-gitea.js` | A canned Gitea 1.27 instance served through a `fetch()` stub — three workflow runs, two pull requests, reviews with a line comment, artifacts, secrets, and variables. Records every request it answers. |
| `assert.js` | The `Checker` used by both suites. |
| `units.test.js` | Remote URL parsing, diff-hunk arithmetic, per-file diff extraction, time formatting, preference precedence, HTTP error messages, the pre-1.24 `/actions/tasks` fallback, pagination and query building, and the no-token path. |
| `host-aliases.test.js` | Instances answering SSH on a different hostname than the web UI: alias parsing, the unmatched case, a hand-written alias, detection from a repository's `ssh_url`, and a later repository resolving from the stored alias without another probe. |
| `integration.test.js` | Activates the extension against a real throwaway git checkout, renders all four sidebar sections, and drives the commands that write files or call the API. |
`host-aliases.test.js` and `integration.test.js` create their git fixtures in a temporary directory and
remove them afterwards; nothing is written inside the repository.
## Adding a case
Fixtures live in `fake-gitea.js` — add to the exported data and, if the route is
new, to the router at the bottom of that file. Assertions use
`t.check(label, condition, detail)` or `t.equals(label, actual, expected)`;
`detail` is printed only when the check fails.
If a check fails on a value you believe is correct, confirm the expectation by
hand before changing the extension — the diff-hunk line arithmetic in
particular is easy to get wrong in a test.