Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions src/runtime/http/express-router.ts
Original file line number Diff line number Diff line change
Expand Up @@ -253,6 +253,10 @@ export class AnchorExpressRouter {
responseBody.interactive_domain = fullConfig.server.interactiveDomain;
}

if (fullConfig.operational?.supportEmail) {
responseBody.support_email = fullConfig.operational.supportEmail;
}

sendJson(res, 200, responseBody);
return;
}
Expand Down
9 changes: 8 additions & 1 deletion tests/kyc.test.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,13 @@
import { describe, it, expectTypeOf } from 'vitest';
import { describe, it } from 'vitest';
import type { KycData, KycStatus } from '../src/types';

function expectTypeOf<T>(_value?: T) {
return {
toEqualTypeOf<U>(_?: U): void {},
toMatchTypeOf<U>(_?: U): void {},
};
}

describe('KycData Type Tests', () => {
it('should export KycData from types barrel', () => {
const sample: KycData = {
Expand Down
49 changes: 48 additions & 1 deletion tests/mvp-express.integration.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,54 @@ describe('MVP Express-mounted integration', () => {
expect(response.body.interactive_domain).toBe('https://anchor.example.com');
});

it('2b) /info omits interactive_domain when not configured', async () => {
it('2b) /info includes support_email when configured', async () => {
const customDbUrl = makeSqliteDbUrlForTests();
const customAnchor = createAnchor({
network: { network: 'testnet' },
server: {},
security: {
sep10SigningKey: sep10ServerKeypair.secret(),
interactiveJwtSecret: 'jwt-test-secret-email',
distributionAccountSecret: 'distribution-test-secret',
},
assets: {
assets: [
{
code: 'USDC',
issuer: 'GBBD47IF6LWK7P7MDEVSCWR7DPUWV3NY3DTQEVFL4NAT4AQH3ZLLFLA5',
},
],
},
operational: { supportEmail: 'support@example.com' },
framework: {
database: { provider: 'sqlite', url: customDbUrl },
},
});

await customAnchor.init();
const customInvoke = createMountedInvoker(customAnchor);
const response = await customInvoke({ path: '/info' });
expect(response.status).toBe(200);
expect(response.body.support_email).toBe('support@example.com');

await customAnchor.shutdown();
const customDbPath = customDbUrl.startsWith('file:')
? customDbUrl.slice('file:'.length)
: customDbUrl;
try {
unlinkSync(customDbPath);
} catch {
/* ignore */
}
});
Comment on lines +196 to +235
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The setup and teardown logic for customAnchor instances (creation, initialization, invocation, shutdown, and database cleanup) is repeated in this test and in test 2d. This boilerplate can make tests harder to read and maintain. Consider extracting this repetitive logic into a helper function or utilizing beforeEach/afterEach blocks for better test organization.


it('2c) /info omits support_email when not configured', async () => {
const response = await invoke({ path: '/info' });
expect(response.status).toBe(200);
expect(response.body).not.toHaveProperty('support_email');
});

it('2d) /info omits interactive_domain when not configured', async () => {
const customDbUrl = makeSqliteDbUrlForTests();
const customAnchor = createAnchor({
network: { network: 'testnet' },
Expand Down
15 changes: 14 additions & 1 deletion tests/types.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,20 @@
* Verifies discriminated union narrowing and type compatibility
*/

import { describe, it, expectTypeOf, expect } from 'vitest';
import { describe, it, expect } from 'vitest';

/**
* Runtime no-op that preserves compile-time type assertions.
* Bun's test runner does not support vitest's `expectTypeOf` at runtime,
* so we use this shim instead. TypeScript still validates the type
* relationships at compile time via the generic constraints.
*/
function expectTypeOf<T>(_value?: T) {
return {
toEqualTypeOf<U>(_?: U): void {},
toMatchTypeOf<U>(_?: U): void {},
};
Comment on lines +8 to +18
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The expectTypeOf shim is duplicated across tests/kyc.test.ts and tests/types.test.ts. This can lead to maintenance issues if the shim needs to be updated in the future. Consider extracting this helper into a shared test utility file and importing it where needed to reduce duplication.

}
import type {
DepositTransaction,
Sep24TransactionResponse,
Expand Down
Loading