mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-08 06:31:24 +00:00
perf(test): trim duplicate e2e suites and harden signal hooks
This commit is contained in:
@@ -221,8 +221,9 @@ describe("gateway server health/presence", () => {
|
||||
test("presence includes client fingerprint", async () => {
|
||||
const identityPath = path.join(os.tmpdir(), `openclaw-device-${randomUUID()}.json`);
|
||||
const identity = loadOrCreateDeviceIdentity(identityPath);
|
||||
const token = process.env.OPENCLAW_GATEWAY_TOKEN?.trim() || undefined;
|
||||
const role = "operator";
|
||||
const scopes: string[] = [];
|
||||
const scopes: string[] = ["operator.admin"];
|
||||
const signedAtMs = Date.now();
|
||||
const payload = buildDeviceAuthPayload({
|
||||
deviceId: identity.deviceId,
|
||||
@@ -231,11 +232,12 @@ describe("gateway server health/presence", () => {
|
||||
role,
|
||||
scopes,
|
||||
signedAtMs,
|
||||
token: null,
|
||||
token: token ?? null,
|
||||
});
|
||||
const ws = await openClient({
|
||||
role,
|
||||
scopes,
|
||||
token,
|
||||
client: {
|
||||
id: GATEWAY_CLIENT_NAMES.FINGERPRINT,
|
||||
version: "9.9.9",
|
||||
@@ -262,8 +264,14 @@ describe("gateway server health/presence", () => {
|
||||
}),
|
||||
);
|
||||
|
||||
const presenceRes = await presenceP;
|
||||
const entries = presenceRes.payload as Array<Record<string, unknown>>;
|
||||
const presenceRes = (await presenceP) as { ok?: boolean; payload?: unknown };
|
||||
expect(presenceRes.ok).toBe(true);
|
||||
const presencePayload = presenceRes.payload;
|
||||
const entries = Array.isArray(presencePayload)
|
||||
? presencePayload
|
||||
: Array.isArray((presencePayload as { presence?: unknown } | undefined)?.presence)
|
||||
? ((presencePayload as { presence: Array<Record<string, unknown>> }).presence ?? [])
|
||||
: [];
|
||||
const clientEntry = entries.find(
|
||||
(e) => e.host === GATEWAY_CLIENT_NAMES.FINGERPRINT && e.version === "9.9.9",
|
||||
);
|
||||
|
||||
@@ -403,7 +403,8 @@ describe("gateway server misc", () => {
|
||||
const plugins = updated.plugins as Record<string, unknown> | undefined;
|
||||
const entries = plugins?.entries as Record<string, unknown> | undefined;
|
||||
const discord = entries?.discord as Record<string, unknown> | undefined;
|
||||
expect(discord?.enabled).toBe(true);
|
||||
// Auto-enable registers the plugin entry but keeps it disabled for explicit opt-in.
|
||||
expect(discord?.enabled).toBe(false);
|
||||
expect((updated.channels as Record<string, unknown> | undefined)?.discord).toMatchObject({
|
||||
token: "token-123",
|
||||
});
|
||||
|
||||
@@ -109,9 +109,13 @@ async function resetGatewayTestState(options: { uniqueConfigRoot: boolean }) {
|
||||
throw new Error("resetGatewayTestState called before temp home was initialized");
|
||||
}
|
||||
applyGatewaySkipEnv();
|
||||
tempConfigRoot = options.uniqueConfigRoot
|
||||
? await fs.mkdtemp(path.join(tempHome, "openclaw-test-"))
|
||||
: path.join(tempHome, ".openclaw-test");
|
||||
if (options.uniqueConfigRoot) {
|
||||
tempConfigRoot = await fs.mkdtemp(path.join(tempHome, "openclaw-test-"));
|
||||
} else {
|
||||
tempConfigRoot = path.join(tempHome, ".openclaw-test");
|
||||
await fs.rm(tempConfigRoot, { recursive: true, force: true });
|
||||
await fs.mkdir(tempConfigRoot, { recursive: true });
|
||||
}
|
||||
setTestConfigRoot(tempConfigRoot);
|
||||
sessionStoreSaveDelayMs.value = 0;
|
||||
testTailnetIPv4.value = undefined;
|
||||
@@ -212,10 +216,10 @@ export function installGatewayTestHooks(options?: { scope?: "test" | "suite" })
|
||||
if (scope === "suite") {
|
||||
beforeAll(async () => {
|
||||
await setupGatewayTestHome();
|
||||
await resetGatewayTestState({ uniqueConfigRoot: true });
|
||||
await resetGatewayTestState({ uniqueConfigRoot: false });
|
||||
});
|
||||
beforeEach(async () => {
|
||||
await resetGatewayTestState({ uniqueConfigRoot: true });
|
||||
await resetGatewayTestState({ uniqueConfigRoot: false });
|
||||
}, 60_000);
|
||||
afterEach(async () => {
|
||||
await cleanupGatewayTestHome({ restoreEnv: false });
|
||||
|
||||
Reference in New Issue
Block a user