chore: drop comments that restate the code
This commit is contained in:
@@ -1,7 +1,3 @@
|
||||
// Minimal fetch wrapper for the LiveOps platform/admin HTTP API used by the seed
|
||||
// and by tests' admin-side assertions. Retries network errors and 5xx with backoff;
|
||||
// fails fast on 4xx.
|
||||
|
||||
const sleep = (ms: number) => new Promise((r) => setTimeout(r, ms));
|
||||
|
||||
export class ApiError extends Error {
|
||||
@@ -54,8 +50,8 @@ export function createAdminClient(baseUrl: string): AdminClient {
|
||||
if (!res.ok) throw new ApiError(res.status, path, text);
|
||||
return (text ? JSON.parse(text) : undefined) as T;
|
||||
} catch (err) {
|
||||
if (err instanceof ApiError) throw err; // 4xx — don't retry
|
||||
lastErr = err; // network error — retry
|
||||
if (err instanceof ApiError) throw err;
|
||||
lastErr = err;
|
||||
await sleep(300 * (attempt + 1));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,9 +1,3 @@
|
||||
// Vitest globalSetup for the production e2e suite.
|
||||
//
|
||||
// Setup: seeds a fresh project on prod (unless RUDDER_E2E_PROJECT_KEY is provided) and
|
||||
// writes .e2e-prod.local.json for the tests to read.
|
||||
// Teardown: deletes the seeded project (default). Set RUDDER_E2E_KEEP=1 to keep it.
|
||||
|
||||
import { runSeed, deleteProject } from './seed.js';
|
||||
import { readArtifact, writeArtifact, removeArtifact } from './artifact.js';
|
||||
import type { SeedArtifact } from './types.js';
|
||||
@@ -11,15 +5,12 @@ import type { SeedArtifact } from './types.js';
|
||||
export default async function setup(): Promise<() => Promise<void>> {
|
||||
const baseUrl = process.env.RUDDER_E2E_BASE_URL ?? 'https://api.rudder.build';
|
||||
|
||||
// Externally-provided project: skip seeding, just verify an artifact/env exists.
|
||||
if (process.env.RUDDER_E2E_PROJECT_KEY) {
|
||||
const existing = readArtifact();
|
||||
if (!existing) {
|
||||
writeArtifact({
|
||||
baseUrl,
|
||||
projectKey: process.env.RUDDER_E2E_PROJECT_KEY,
|
||||
// Remaining fields are unknown for an external project; tests relying on the
|
||||
// seeded dataset/admin token will require a real seed run.
|
||||
} as unknown as SeedArtifact);
|
||||
}
|
||||
return async () => {};
|
||||
|
||||
@@ -1,11 +1,8 @@
|
||||
// Test-side helpers: load the seed artifact and build SDK clients against prod.
|
||||
|
||||
import { RudderClient, createClient } from '../../../src/client/RudderClient.js';
|
||||
import type { TokenStore } from '../../../src/token/TokenStore.js';
|
||||
import { readArtifact } from './artifact.js';
|
||||
import type { SeedArtifact } from './types.js';
|
||||
|
||||
/** Loads the seed artifact; RUDDER_E2E_* env vars override file values. */
|
||||
export function loadArtifact(): SeedArtifact {
|
||||
const file = readArtifact();
|
||||
if (!file) {
|
||||
@@ -37,7 +34,6 @@ export function createInMemoryTokenStore(): TokenStore {
|
||||
};
|
||||
}
|
||||
|
||||
/** A client with no auth yet (in-memory tokens). */
|
||||
export function makeProdClient(
|
||||
artifact: SeedArtifact = loadArtifact(),
|
||||
): RudderClient {
|
||||
@@ -48,7 +44,6 @@ export function makeProdClient(
|
||||
});
|
||||
}
|
||||
|
||||
/** A device-authenticated client. In Node each call mints a fresh player (ephemeral device id). */
|
||||
export async function freshPlayer(
|
||||
artifact: SeedArtifact = loadArtifact(),
|
||||
): Promise<RudderClient> {
|
||||
|
||||
@@ -1,7 +1,3 @@
|
||||
// Production seed: registers an operator and creates a project. Creating a
|
||||
// project provisions staging + prod environments; the prod SDK key is what
|
||||
// the runtime SDK sends as projectKey.
|
||||
|
||||
import { createAdminClient } from './adminClient.js';
|
||||
import type { SeedArtifact } from './types.js';
|
||||
|
||||
|
||||
@@ -1,11 +1,7 @@
|
||||
// Shared types for the production e2e harness.
|
||||
|
||||
/** Persisted seed output, written to .e2e-prod.local.json and read by tests. */
|
||||
export interface SeedArtifact {
|
||||
baseUrl: string;
|
||||
projectId: string;
|
||||
projectKey: string;
|
||||
/** Operator (platform) bearer token — used for admin calls (wallet grant, player details). */
|
||||
adminToken: string;
|
||||
adminEmail: string;
|
||||
environment: string;
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
import { describe, it, expect, beforeAll } from 'vitest';
|
||||
import { loadArtifact } from './_setup/harness.js';
|
||||
|
||||
// Smoke gate: if egress to prod is blocked or the gateway is down, fail fast here.
|
||||
describe('e2e-prod: health', () => {
|
||||
let baseUrl: string;
|
||||
beforeAll(() => {
|
||||
|
||||
@@ -1,9 +1,6 @@
|
||||
import { describe, it, expect, beforeEach, afterEach, vi } from 'vitest';
|
||||
import { createTestClient } from '../helpers/createClient.js';
|
||||
import { createFakeGateway, type FakeGateway } from '../helpers/fakeGateway.js';
|
||||
// Checked-in output of `rudder client generate --lang ts` for
|
||||
// test/fixtures/leaderboards.manifest.json; `npm run typecheck` proves the
|
||||
// generated factory accepts RudderClient.
|
||||
import { modules, type LeaderboardsSubmitError } from '../fixtures/rudder.modules.js';
|
||||
import { RudderModuleError } from '../../src/client/RudderError.js';
|
||||
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
import type { TokenStore } from '../../src/token/TokenStore.js';
|
||||
|
||||
/** In-memory token store for testing. */
|
||||
export function createFakeTokenStore(): TokenStore {
|
||||
let access: string | null = null;
|
||||
let refresh: string | null = null;
|
||||
|
||||
@@ -2,7 +2,6 @@ import { RudderClient, createClient } from '../../src/client/RudderClient.js';
|
||||
import type { RudderClientOptions } from '../../src/client/RudderClientOptions.js';
|
||||
import { createFakeTokenStore } from './FakeTokenStore.js';
|
||||
|
||||
/** Creates a RudderClient with test-friendly defaults and a fake token store. */
|
||||
export function createTestClient(overrides?: Partial<RudderClientOptions>): RudderClient {
|
||||
return createClient({
|
||||
baseUrl: 'https://api.test.rudder.build',
|
||||
|
||||
Reference in New Issue
Block a user