- API: GET /app/android/latest reads the latest Gitea release (ANDROID_RELEASES_URL, optional token for a private repo) with the APK's SHA-256 from SHA256SUMS; GET /app/android/apk/:name streams that APK. - App (modules/updater): downloads in the background, checks the SHA-256, and installs through PackageInstaller: quietly once when leaving the app (Android 12+), otherwise from the feed banner or Settings > App version. F-Droid builds leave it out and drop the install permissions. - CI: the release notes come from the fastlane changelog; the app shows the part above ---. - Settings: Create-account and Link Spotify buttons for Last.fm and ListenBrainz. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
57 lines
2.2 KiB
TypeScript
57 lines
2.2 KiB
TypeScript
import { generateKeyPairSync } from 'node:crypto';
|
|
import { defineConfig } from 'vitest/config';
|
|
|
|
// Throwaway MusicKit-style key so Apple developer tokens can be signed and verified in tests.
|
|
const appleKey = generateKeyPairSync('ec', { namedCurve: 'P-256' });
|
|
|
|
/**
|
|
* Tests run against a dedicated Postgres database and Redis DB index, never
|
|
* the dev ones (test/helpers.ts refuses to wipe anything else). Override with
|
|
* TEST_DATABASE_URL / TEST_REDIS_URL, e.g. in CI.
|
|
*/
|
|
const testEnv = {
|
|
NODE_ENV: 'test',
|
|
DATABASE_URL: process.env.TEST_DATABASE_URL ?? 'postgres://musicshare:musicshare@localhost:5447/musicshare_test',
|
|
REDIS_URL: process.env.TEST_REDIS_URL ?? 'redis://localhost:6380/1',
|
|
TOKEN_ENCRYPTION_KEY: Buffer.alloc(32, 7).toString('base64'),
|
|
WEB_URL: 'http://web.test',
|
|
API_PUBLIC_URL: 'https://api.test',
|
|
ALLOW_PRIVATE_SERVER_URLS: 'false',
|
|
LASTFM_API_KEY: 'test-lastfm-key',
|
|
LASTFM_SHARED_SECRET: 'test-lastfm-secret',
|
|
SPOTIFY_CLIENT_ID: 'test-spotify-id',
|
|
SPOTIFY_CLIENT_SECRET: 'test-spotify-secret',
|
|
ODESLI_API_KEY: '',
|
|
ANDROID_RELEASES_URL: 'https://git.test/api/v1/repos/me/musicshare/releases/latest',
|
|
ANDROID_RELEASES_TOKEN: 'test-release-token',
|
|
// Never send real email from tests (apps/api/.env may hold real SMTP settings).
|
|
SMTP_HOST: '',
|
|
APPLE_TEAM_ID: 'TEAMID1234',
|
|
APPLE_MUSICKIT_KEY_ID: 'KEYID12345',
|
|
APPLE_MUSICKIT_PRIVATE_KEY: appleKey.privateKey.export({ type: 'pkcs8', format: 'pem' }).toString().replace(/\n/g, '\\n'),
|
|
APPLE_TEST_PUBLIC_KEY: appleKey.publicKey.export({ type: 'spki', format: 'pem' }).toString(),
|
|
};
|
|
|
|
export default defineConfig({
|
|
test: {
|
|
env: testEnv,
|
|
projects: [
|
|
{
|
|
test: { name: 'unit', include: ['src/**/*.test.ts'] },
|
|
},
|
|
{
|
|
test: {
|
|
name: 'integration',
|
|
include: ['test/**/*.test.ts'],
|
|
globalSetup: ['test/global-setup.ts'],
|
|
// one shared database: run files one at a time
|
|
fileParallelism: false,
|
|
hookTimeout: 30_000,
|
|
// Password hashing is deliberately slow; tests that create many accounts need headroom on busy machines.
|
|
testTimeout: 20_000,
|
|
},
|
|
},
|
|
],
|
|
},
|
|
});
|