mirror of
https://github.com/RayLabsHQ/gitea-mirror.git
synced 2026-03-13 22:12:54 +03:00
* feat: add E2E testing infrastructure with fake GitHub, Playwright, and CI workflow - Add fake GitHub API server (tests/e2e/fake-github-server.ts) with management API for seeding test data - Add Playwright E2E test suite covering full mirror workflow: service health checks, user registration, config, sync, verify - Add Docker Compose for E2E Gitea instance - Add orchestrator script (run-e2e.sh) with cleanup - Add GitHub Actions workflow (e2e-tests.yml) with Gitea service container - Make GITHUB_API_URL configurable via env var for testing - Add npm scripts: test:e2e, test:e2e:ci, test:e2e:keep, test:e2e:cleanup * feat: add real git repos + backup config testing to E2E suite - Create programmatic test git repos (create-test-repos.ts) with real commits, branches (main, develop, feature/*), and tags (v1.0.0, v1.1.0) - Add git-server container to docker-compose serving bare repos via dumb HTTP protocol so Gitea can actually clone them - Update fake GitHub server to emit reachable clone_url fields pointing to the git-server container (configurable via GIT_SERVER_URL env var) - Add management endpoint POST /___mgmt/set-clone-url for runtime config - Update E2E spec with real mirroring verification: * Verify repos appear in Gitea with actual content * Check branches, tags, commits, file content * Verify 4/4 repos mirrored successfully - Add backup configuration test suite: * Enable/disable backupBeforeSync config * Toggle blockSyncOnBackupFailure * Trigger re-sync with backup enabled and verify activities * Verify config persistence across changes - Update CI workflow to use docker compose (not service containers) matching the local run-e2e.sh approach - Update cleanup.sh for git-repos directory and git-server port - All 22 tests passing with real git content verification * refactor: split E2E tests into focused files + add force-push tests Split the monolithic e2e.spec.ts (1335 lines) into 5 focused spec files and a shared helpers module: helpers.ts — constants, GiteaAPI, auth, saveConfig, utilities 01-health.spec.ts — service health checks (4 tests) 02-mirror-workflow.spec.ts — full first-mirror journey (8 tests) 03-backup.spec.ts — backup config toggling (6 tests) 04-force-push.spec.ts — force-push simulation & backup verification (9 tests) 05-sync-verification.spec.ts — dynamic repos, content integrity, reset (5 tests) The force-push tests are the critical addition: F0: Record original state (commit SHAs, file content) F1: Rewrite source repo history (simulate force-push) F2: Sync to Gitea WITHOUT backup F3: Verify data loss — LICENSE file gone, README overwritten F4: Restore source, re-mirror to clean state F5: Enable backup, force-push again, sync through app F6: Verify Gitea reflects the force-push F7: Verify backup system was invoked (snapshot activities logged) F8: Restore source repo for subsequent tests Also added to helpers.ts: - GiteaAPI.getBranch(), .getCommit(), .triggerMirrorSync() - getRepositoryIds(), triggerMirrorJobs(), triggerSyncRepo() All 32 tests passing. * Try to fix actions * Try to fix the other action * Add debug info to check why e2e action is failing * More debug info * Even more debug info * E2E fix attempt #1 * E2E fix attempt #2 * more debug again * E2E fix attempt #3 * E2E fix attempt #4 * Remove a bunch of debug info * Hopefully fix backup bug * Force backups to succeed
99 lines
2.9 KiB
TypeScript
99 lines
2.9 KiB
TypeScript
import { defineConfig, devices } from "@playwright/test";
|
||
|
||
/**
|
||
* Playwright configuration for gitea-mirror E2E tests.
|
||
*
|
||
* Expected services (started by run-e2e.sh before Playwright launches):
|
||
* - Fake GitHub API server on http://localhost:4580
|
||
* - Git HTTP server on http://localhost:4590
|
||
* - Gitea instance on http://localhost:3333
|
||
* - gitea-mirror app on http://localhost:4321
|
||
*
|
||
* Test files are numbered to enforce execution order (they share state
|
||
* via a single Gitea + app instance):
|
||
* 01-health.spec.ts – service smoke tests
|
||
* 02-mirror-workflow.spec.ts – full first-mirror journey
|
||
* 03-backup.spec.ts – backup config toggling
|
||
* 04-force-push.spec.ts – force-push simulation & backup verification
|
||
* 05-sync-verification.spec.ts – dynamic repos, content integrity, reset
|
||
*/
|
||
export default defineConfig({
|
||
testDir: ".",
|
||
testMatch: /\d+-.*\.spec\.ts$/,
|
||
|
||
/* Fail the build on CI if test.only is left in source */
|
||
forbidOnly: !!process.env.CI,
|
||
|
||
/* Retry once on CI to absorb flakiness from container startup races */
|
||
retries: process.env.CI ? 1 : 0,
|
||
|
||
/* Limit parallelism – the tests share a single Gitea + app instance */
|
||
workers: 1,
|
||
fullyParallel: false,
|
||
|
||
/* Generous timeout: mirrors involve real HTTP round-trips to Gitea */
|
||
timeout: 120_000,
|
||
expect: { timeout: 15_000 },
|
||
|
||
/* Reporter */
|
||
reporter: process.env.CI
|
||
? [
|
||
["github"],
|
||
["html", { open: "never", outputFolder: "playwright-report" }],
|
||
]
|
||
: [
|
||
["list"],
|
||
["html", { open: "on-failure", outputFolder: "playwright-report" }],
|
||
],
|
||
|
||
outputDir: "test-results",
|
||
|
||
use: {
|
||
/* Base URL of the gitea-mirror app */
|
||
baseURL: process.env.APP_URL || "http://localhost:4321",
|
||
|
||
/* Collect traces on first retry so CI failures are debuggable */
|
||
trace: "on-first-retry",
|
||
screenshot: "only-on-failure",
|
||
video: "retain-on-failure",
|
||
|
||
/* Extra HTTP headers aren't needed but keep accept consistent */
|
||
extraHTTPHeaders: {
|
||
Accept: "application/json, text/html, */*",
|
||
},
|
||
},
|
||
|
||
projects: [
|
||
{
|
||
name: "chromium",
|
||
use: { ...devices["Desktop Chrome"] },
|
||
},
|
||
],
|
||
|
||
/* We do NOT use webServer here because run-e2e.sh manages all services.
|
||
* On CI the GitHub Action workflow starts them before invoking Playwright.
|
||
* Locally, run-e2e.sh does the same.
|
||
*
|
||
* If you want Playwright to start the app for you during local dev, uncomment:
|
||
*
|
||
* webServer: [
|
||
* {
|
||
* command: "npx tsx tests/e2e/fake-github-server.ts",
|
||
* port: 4580,
|
||
* reuseExistingServer: true,
|
||
* timeout: 10_000,
|
||
* },
|
||
* {
|
||
* command: "bun run dev",
|
||
* port: 4321,
|
||
* reuseExistingServer: true,
|
||
* timeout: 30_000,
|
||
* env: {
|
||
* GITHUB_API_URL: "http://localhost:4580",
|
||
* BETTER_AUTH_SECRET: "e2e-test-secret",
|
||
* },
|
||
* },
|
||
* ],
|
||
*/
|
||
});
|