refactor(test): dedupe ios/android gateway client id tests

This commit is contained in:
Peter Steinberger
2026-02-15 23:07:50 +00:00
parent 8ba16a894f
commit 0b56472cf5

View File

@@ -61,30 +61,14 @@ function connectReq(
);
}
test("accepts openclaw-ios as a valid gateway client id", async () => {
test.each([
{ clientId: "openclaw-ios", platform: "ios" },
{ clientId: "openclaw-android", platform: "android" },
])("accepts $clientId as a valid gateway client id", async ({ clientId, platform }) => {
const ws = new WebSocket(`ws://127.0.0.1:${port}`);
await new Promise<void>((resolve) => ws.once("open", resolve));
const res = await connectReq(ws, { clientId: "openclaw-ios", platform: "ios" });
// We don't care if auth fails here; we only care that schema validation accepts the client id.
// A schema rejection would close the socket before sending a response.
if (!res.ok) {
// allow unauthorized error when gateway requires auth
// but reject schema validation errors
const message = String(res.error?.message ?? "");
if (message.includes("invalid connect params")) {
throw new Error(message);
}
}
ws.close();
});
test("accepts openclaw-android as a valid gateway client id", async () => {
const ws = new WebSocket(`ws://127.0.0.1:${port}`);
await new Promise<void>((resolve) => ws.once("open", resolve));
const res = await connectReq(ws, { clientId: "openclaw-android", platform: "android" });
const res = await connectReq(ws, { clientId, platform });
// We don't care if auth fails here; we only care that schema validation accepts the client id.
// A schema rejection would close the socket before sending a response.
if (!res.ok) {