85 lines
3.3 KiB
TypeScript
85 lines
3.3 KiB
TypeScript
import { defineConfig } from "@playwright/test";
|
|
import fs from "node:fs";
|
|
import os from "node:os";
|
|
import path from "node:path";
|
|
|
|
// Separate real-HTTP contract suite. Neither process uses the normal browser-suite ports.
|
|
const apiUrl = "http://127.0.0.1:15313";
|
|
const providerUrl = "http://127.0.0.1:18133";
|
|
const productionApiUrl = "http://127.0.0.1:15314";
|
|
const dataRoot = process.env.CV_AI_READINESS_DATA_ROOT ??= fs.mkdtempSync(path.join(os.tmpdir(), "jobtracker-cv-ai-readiness-"));
|
|
process.env.CV_AI_READINESS_API_URL = apiUrl;
|
|
process.env.CV_AI_READINESS_PROVIDER_URL = providerUrl;
|
|
process.env.CV_AI_READINESS_PRODUCTION_API_URL = productionApiUrl;
|
|
const quote = (value: string) => `"${value.replaceAll('"', '\\"')}"`;
|
|
|
|
const config = defineConfig({
|
|
testDir: "./ai-tests",
|
|
testMatch: "cv-ai-readiness.spec.ts",
|
|
workers: 1,
|
|
fullyParallel: false,
|
|
retries: 0,
|
|
timeout: 90_000,
|
|
reporter: "list",
|
|
outputDir: "test-results/cv-ai-readiness",
|
|
webServer: [
|
|
{
|
|
command: `${quote(process.execPath)} ${quote(path.resolve("scripts/cv-ai-provider-fixture.mjs"))} --port 18133`,
|
|
url: `${providerUrl}/health`,
|
|
reuseExistingServer: false,
|
|
timeout: 30_000,
|
|
},
|
|
{
|
|
command: `${quote(process.env.DOTNET_HOST_PATH || "dotnet")} run --no-build --configuration Release --project ../JobTrackerApi/JobTrackerApi.csproj --urls ${apiUrl}`,
|
|
url: `${apiUrl}/ready`,
|
|
reuseExistingServer: false,
|
|
timeout: 120_000,
|
|
env: {
|
|
ASPNETCORE_ENVIRONMENT: "Development",
|
|
Auth__Require: "true",
|
|
Auth__JwtKey: "cv-ai-readiness-only-key-at-least-thirty-two-characters",
|
|
Auth__AdminEmail: "cv-ai-readiness@example.test",
|
|
Auth__AdminPassword: "E2ePassword123!",
|
|
Auth__AllowRegistration: "false",
|
|
RateLimits__AuthLoginPermitLimit: "100",
|
|
Data__Root: dataRoot,
|
|
Database__Provider: "sqlite",
|
|
ConnectionStrings__JobTracker: `Data Source=${path.join(dataRoot, "readiness.sqlite")}`,
|
|
HttpsRedirection__Enabled: "false",
|
|
Ai__BaseUrl: providerUrl,
|
|
Ai__ServiceToken: "",
|
|
Ai__ProbeEnabled: "false",
|
|
Auth__GoogleClientId: "",
|
|
Auth__MicrosoftClientId: "",
|
|
Email__Enabled: "false",
|
|
Stripe__SecretKey: "",
|
|
Backups__Enabled: "false",
|
|
Workers__AiOperationsEnabled: "false",
|
|
Workers__RulesEnabled: "false",
|
|
Workers__FollowUpRemindersEnabled: "false",
|
|
Workers__DailyExportEnabled: "false",
|
|
Workers__JobEnrichmentEnabled: "false",
|
|
},
|
|
},
|
|
],
|
|
});
|
|
|
|
const webServers = Array.isArray(config.webServer) ? config.webServer : [config.webServer!];
|
|
const backend = webServers[1];
|
|
export default defineConfig({
|
|
...config,
|
|
webServer: [...webServers, {
|
|
...backend,
|
|
// Launch settings otherwise override the Production environment with Development.
|
|
command: backend.command.replace(" run ", " run --no-launch-profile ").replace(apiUrl, productionApiUrl),
|
|
url: `${productionApiUrl}/ready`,
|
|
env: {
|
|
...backend.env,
|
|
ASPNETCORE_ENVIRONMENT: "Production",
|
|
App__PublicBaseUrl: productionApiUrl.replace("http:", "https:"),
|
|
Data__Root: path.join(dataRoot, "production"),
|
|
ConnectionStrings__JobTracker: `Data Source=${path.join(dataRoot, "production", "readiness.sqlite")}`,
|
|
},
|
|
}],
|
|
});
|