mirror of
https://github.com/kikootwo/ReadMeABook.git
synced 2026-06-02 20:30:10 +00:00
d3dc6cf76d
Add a volume-mapping guide and surface build/version metadata throughout the project. Changes included: - documentation: Add documentation/deployment/volume-mapping.md and update TABLEOFCONTENTS.md and README to reference it (helps users align download client and RMAB paths). - CI: Capture package.json version in .github/workflows/build-unified-image.yml, pass APP_VERSION as a build-arg, and update the Discord notification to show the semantic version and pull `:latest`. - Docker: Declare ARG APP_VERSION and expose NEXT_PUBLIC_APP_VERSION / APP_VERSION / GIT_COMMIT env vars in dockerfile.unified so runtime and client can read the semantic version and commit. - App API/UI: Update src/app/api/version/route.ts and src/components/ui/VersionBadge.tsx to prefer semantic app version (APP_VERSION / NEXT_PUBLIC_APP_VERSION), include fullVersion and commit info, show commit in tooltip, and adjust fallback/dev labels. - Tests: Update tests (system.routes.test.ts and VersionBadge.test.tsx) to reflect the new version/commit fields and behavior. - Audible integration: Add ipRedirectOverride query param to multiple Audible requests to avoid IP-based region redirects. - Misc: Bump package.json version to 1.0.0. These changes make version information consistent between build, runtime, and UI, improve CI notifications, add user guidance for common volume-mapping issues, and harden Audible scraping against region redirects.
74 lines
2.1 KiB
TypeScript
74 lines
2.1 KiB
TypeScript
/**
|
|
* Component: System API Route Tests
|
|
* Documentation: documentation/testing.md
|
|
*/
|
|
|
|
import { beforeEach, describe, expect, it, vi } from 'vitest';
|
|
import { createPrismaMock } from '../helpers/prisma';
|
|
|
|
const prismaMock = createPrismaMock();
|
|
const schedulerMock = vi.hoisted(() => ({
|
|
start: vi.fn(),
|
|
}));
|
|
|
|
vi.mock('@/lib/db', () => ({
|
|
prisma: prismaMock,
|
|
}));
|
|
|
|
vi.mock('@/lib/services/scheduler.service', () => ({
|
|
getSchedulerService: () => schedulerMock,
|
|
}));
|
|
|
|
describe('System routes', () => {
|
|
beforeEach(() => {
|
|
vi.clearAllMocks();
|
|
});
|
|
|
|
it('returns healthy status when database is reachable', async () => {
|
|
prismaMock.$queryRaw.mockResolvedValueOnce(1);
|
|
const { GET } = await import('@/app/api/health/route');
|
|
|
|
const response = await GET();
|
|
const payload = await response.json();
|
|
|
|
expect(payload.status).toBe('healthy');
|
|
expect(payload.database).toBe('connected');
|
|
});
|
|
|
|
it('returns unhealthy status on database error', async () => {
|
|
prismaMock.$queryRaw.mockRejectedValueOnce(new Error('db down'));
|
|
const { GET } = await import('@/app/api/health/route');
|
|
|
|
const response = await GET();
|
|
const payload = await response.json();
|
|
|
|
expect(response.status).toBe(503);
|
|
expect(payload.status).toBe('unhealthy');
|
|
});
|
|
|
|
it('initializes scheduler on init endpoint', async () => {
|
|
const { GET } = await import('@/app/api/init/route');
|
|
|
|
const response = await GET({} as any);
|
|
const payload = await response.json();
|
|
|
|
expect(payload.success).toBe(true);
|
|
expect(schedulerMock.start).toHaveBeenCalled();
|
|
});
|
|
|
|
it('returns version info from environment', async () => {
|
|
process.env.APP_VERSION = '1.0.0';
|
|
process.env.GIT_COMMIT = 'abcdef123456';
|
|
process.env.BUILD_DATE = '2025-01-01';
|
|
|
|
const { GET } = await import('@/app/api/version/route');
|
|
const response = await GET();
|
|
const payload = await response.json();
|
|
|
|
expect(payload.version).toBe('v1.0.0');
|
|
expect(payload.fullVersion).toBe('1.0.0');
|
|
expect(payload.commit).toBe('abcdef123456');
|
|
expect(payload.buildDate).toBe('2025-01-01');
|
|
});
|
|
});
|