-
-
Notifications
You must be signed in to change notification settings - Fork 85
Open
Labels
component/cliCLI tools relatedCLI tools relatedcomponent/webfingerWebFinger relatedWebFinger relateddifficulty/intermediateIntermediate levelIntermediate levelhelp wantedExtra attention is neededExtra attention is neededtype/bugSomething isn't workingSomething isn't workingtype/testTesting relatedTesting related
Milestone
Description
The test for lookupSingleWebFinger in packages/cli/src/webfinger/mod.test.ts is flaky because it depends on the external remote server hollo.social. When this server is temporarily unavailable, the test fails with:
Error [NotFoundError]: Resource not found: @[email protected]
at lookupSingleWebFinger (/home/runner/work/fedify/fedify/packages/cli/src/webfinger/action.ts:28:5)
at process.processTicksAndRejections (node:internal/process/task_queues:105:5) {
resource: '@[email protected]'
}
Current implementation
The test (lines 73-79) makes real HTTP requests to external servers:
test("Test lookupSingleWebFinger", async () => {
const aliases = (await Array.fromAsync(
RESOURCES,
(resource) => lookupSingleWebFinger({ resource }),
)).map((w) => w?.aliases?.[0]);
assert.deepEqual(aliases, ALIASES);
});Where RESOURCES includes (lines 9-12):
Problem
This approach has several issues:
- Unreliability: External servers may be temporarily unavailable, causing intermittent test failures
- Network dependency: Tests require internet connectivity and DNS resolution
- Slowness: Real HTTP requests significantly slow down the test suite
- Brittleness: Changes to the external server's configuration or data can break tests unexpectedly
Proposed solution
The test should be refactored to use one of the following approaches:
- Mock server: Spin up a local HTTP server that responds to WebFinger queries with known test data
- Mock HTTP client: Mock the underlying HTTP fetch calls to return pre-determined responses
- Use @fedify/testing utilities: Leverage existing testing utilities from the
@fedify/testingpackage if available
The ideal solution would be to create a minimal local ActivityPub/WebFinger server for testing purposes, ensuring tests are:
- Fast (no real network I/O)
- Reliable (no external dependencies)
- Deterministic (known test data)
Additional context
- This issue only affects the
nextbranch (Fedify 2.0) - The test is located at
packages/cli/src/webfinger/mod.test.ts:73 - The implementation being tested is in
packages/cli/src/webfinger/action.ts
Metadata
Metadata
Assignees
Labels
component/cliCLI tools relatedCLI tools relatedcomponent/webfingerWebFinger relatedWebFinger relateddifficulty/intermediateIntermediate levelIntermediate levelhelp wantedExtra attention is neededExtra attention is neededtype/bugSomething isn't workingSomething isn't workingtype/testTesting relatedTesting related