Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions e2e/client-type.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
// Estate test-traffic contract: the edge classifier keys on this exact header to keep e2e out of real-user metrics.
export const CLIENT_TYPE_HEADER = 'x-client-type';
export const CLIENT_TYPE_TEST = 'test';

export const testClientHeader = (): Record<string, string> => ({
[CLIENT_TYPE_HEADER]: CLIENT_TYPE_TEST,
});
6 changes: 5 additions & 1 deletion e2e/helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import { createServer } from 'node:net';
import { tmpdir } from 'node:os';
import { join } from 'node:path';
import { expect, request as apiRequest, type APIRequestContext } from '@playwright/test';
import { testClientHeader } from './client-type.js';

export const TARGET_FQDN = process.env['AGENTAGE_SITE_FQDN'] ?? 'dev.agentage.io';
export const AUTH_URL = `https://auth.${TARGET_FQDN}`;
Expand Down Expand Up @@ -150,7 +151,10 @@ export const testAccount = (): TestAccount => {

// Better Auth 403s cookie-bearing POSTs without a same-origin Origin header.
export const newBrowserContext = (): Promise<APIRequestContext> =>
apiRequest.newContext({ baseURL: AUTH_URL, extraHTTPHeaders: { Origin: AUTH_URL } });
apiRequest.newContext({
baseURL: AUTH_URL,
extraHTTPHeaders: { Origin: AUTH_URL, ...testClientHeader() },
});

const sleep = (ms: number): Promise<void> => new Promise((r) => setTimeout(r, ms));

Expand Down
7 changes: 6 additions & 1 deletion e2e/mcp-contract.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { existsSync, readFileSync } from 'node:fs';
import { join } from 'node:path';
import { expect, test } from '@playwright/test';
import { assertCliBuilt, createCliMachine, freePort, type CliMachine } from './helpers.js';
import { testClientHeader } from './client-type.js';

// Frozen MCP contract behavior tier. mcp-daemon.test.ts proves the tool surface exists (6 tools,
// dual-channel output); this proves the BEHAVIORS a bad @agentage/server-memory or
Expand All @@ -28,7 +29,11 @@ const rpc = async (
): Promise<{ result?: ToolResult; error?: { message: string } }> => {
const res = await fetch(`http://127.0.0.1:${port}/mcp`, {
method: 'POST',
headers: { 'Content-Type': 'application/json', Accept: 'application/json, text/event-stream' },
headers: {
'Content-Type': 'application/json',
Accept: 'application/json, text/event-stream',
...testClientHeader(),
},
body: JSON.stringify({ jsonrpc: '2.0', id: 1, method, params }),
});
expect(res.ok, `POST /mcp ${method} -> ${res.status}`).toBe(true);
Expand Down
7 changes: 6 additions & 1 deletion e2e/mcp-daemon.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { existsSync, readFileSync } from 'node:fs';
import { join } from 'node:path';
import { expect, test } from '@playwright/test';
import { assertCliBuilt, createCliMachine, freePort, type CliMachine } from './helpers.js';
import { testClientHeader } from './client-type.js';

// M3 daemon MCP tier: the daemon exposes the frozen 6 memory__* tools at POST /mcp (stateless
// Streamable HTTP). An ephemeral port + isolated AGENTAGE_CONFIG_DIR keep it off the real daemon /
Expand Down Expand Up @@ -36,7 +37,11 @@ interface RpcResult {
const mcpRpc = async (port: number, method: string, params: unknown): Promise<RpcResult> => {
const res = await fetch(`http://127.0.0.1:${port}/mcp`, {
method: 'POST',
headers: { 'Content-Type': 'application/json', Accept: 'application/json, text/event-stream' },
headers: {
'Content-Type': 'application/json',
Accept: 'application/json, text/event-stream',
...testClientHeader(),
},
body: JSON.stringify({ jsonrpc: '2.0', id: 1, method, params }),
});
expect(res.ok, `POST /mcp ${method} -> ${res.status}`).toBe(true);
Expand Down
2 changes: 2 additions & 0 deletions playwright.config.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { defineConfig } from '@playwright/test';
import { testClientHeader } from './e2e/client-type.js';

export default defineConfig({
testDir: './e2e',
Expand All @@ -8,4 +9,5 @@ export default defineConfig({
retries: process.env['CI'] ? 1 : 0,
workers: 1,
reporter: process.env['CI'] ? [['list'], ['html', { open: 'never' }]] : 'list',
use: { extraHTTPHeaders: { ...testClientHeader() } },
});