
























@@ -1990,7 +1990,9 @@ describe("matrix live qa scenarios", () => {
19901990expect(artifacts.roomKey).toBe("e2ee-sync-state-loss-crypto-intact-recovery");
1991199119921992await expectPathMissing(syncStorePath);
1993-expect(registerWithToken.mock.calls.at(0)?.[0]?.registrationToken).toBe("registration-token");
1993+expect(mockObjectArg(registerWithToken, "registerWithToken").registrationToken).toBe(
1994+"registration-token",
1995+);
19941996expect(createPrivateRoom).toHaveBeenCalledWith({
19951997encrypted: true,
19961998inviteUserIds: ["@observer:matrix-qa.test", "@sync-gateway:matrix-qa.test"],
@@ -4701,7 +4703,7 @@ describe("matrix live qa scenarios", () => {
47014703expect(artifacts.secondaryDeviceId).toBe("CLIDEVICE");
4702470447034705expect(startMatrixQaOpenClawCli).toHaveBeenCalledTimes(1);
4704-expect(startMatrixQaOpenClawCli.mock.calls.at(0)?.[0].args).toEqual([
4706+expect(mockObjectArg(startMatrixQaOpenClawCli, "startMatrixQaOpenClawCli").args).toEqual([
47054707"matrix",
47064708"verify",
47074709"self",
@@ -4710,19 +4712,29 @@ describe("matrix live qa scenarios", () => {
47104712"--timeout-ms",
47114713"8000",
47124714]);
4713-expect(startMatrixQaOpenClawCli.mock.calls.at(0)?.[0].timeoutMs).toBe(16_000);
4715+expect(mockObjectArg(startMatrixQaOpenClawCli, "startMatrixQaOpenClawCli").timeoutMs).toBe(
4716+16_000,
4717+);
47144718expect(waitForOutput).toHaveBeenCalledTimes(2);
47154719expect(writeStdin).toHaveBeenCalledWith("yes\n");
47164720expect(endStdin).toHaveBeenCalledTimes(1);
47174721expect(wait).toHaveBeenCalledTimes(1);
47184722expect(kill).toHaveBeenCalledTimes(1);
4719-const registrationRequest = registerWithToken.mock.calls.at(0)?.[0];
4723+const registrationRequest = mockObjectArg(registerWithToken, "registerWithToken");
47204724expect(registrationRequest?.deviceName).toBe(
47214725"OpenClaw Matrix QA CLI Self Verification Owner",
47224726);
4723-expect(registrationRequest?.localpart?.startsWith("qa-cli-self-verification-")).toBe(true);
4724-expect(registrationRequest?.localpart).toHaveLength("qa-cli-self-verification-".length + 8);
4725-expect(registrationRequest?.password?.startsWith("matrix-qa-")).toBe(true);
4727+if (
4728+typeof registrationRequest.localpart !== "string" ||
4729+typeof registrationRequest.password !== "string"
4730+) {
4731+throw new Error("expected registration request credentials");
4732+}
4733+const registrationLocalpart = registrationRequest.localpart;
4734+const registrationPassword = registrationRequest.password;
4735+expect(registrationLocalpart.startsWith("qa-cli-self-verification-")).toBe(true);
4736+expect(registrationLocalpart).toHaveLength("qa-cli-self-verification-".length + 8);
4737+expect(registrationPassword.startsWith("matrix-qa-")).toBe(true);
47264738expect(registrationRequest?.registrationToken).toBe("registration-token");
47274739expect(loginWithPassword).toHaveBeenCalledWith({
47284740deviceName: "OpenClaw Matrix QA CLI Self Verification Device",
@@ -4750,7 +4762,8 @@ describe("matrix live qa scenarios", () => {
47504762["matrix", "verify", "status", "--account", "cli", "--json"],
47514763]);
47524764expect(runMatrixQaOpenClawCli.mock.calls.at(0)?.[0].stdin).toBe("encoded-recovery-key\n");
4753-const cliEnv = startMatrixQaOpenClawCli.mock.calls.at(0)?.[0].env;
4765+const cliEnv = mockObjectArg(startMatrixQaOpenClawCli, "startMatrixQaOpenClawCli")
4766+.env as Record<string, unknown>;
47544767expect(cliEnv?.OPENCLAW_STATE_DIR).toContain("openclaw-matrix-cli-qa-");
47554768expect(cliEnv?.OPENCLAW_CONFIG_PATH).toContain("openclaw-matrix-cli-qa-");
47564769const configPath = String(cliEnv?.OPENCLAW_CONFIG_PATH);
@@ -4915,10 +4928,12 @@ describe("matrix live qa scenarios", () => {
49154928],
49164929["matrix", "verify", "status", "--account", "cli-add-e2ee", "--json"],
49174930]);
4918-expect(registerWithToken.mock.calls.at(0)?.[0]?.deviceName).toBe(
4931+expect(mockObjectArg(registerWithToken, "registerWithToken").deviceName).toBe(
49194932"OpenClaw Matrix QA CLI Account Add Owner",
49204933);
4921-expect(registerWithToken.mock.calls.at(0)?.[0]?.registrationToken).toBe("registration-token");
4934+expect(mockObjectArg(registerWithToken, "registerWithToken").registrationToken).toBe(
4935+"registration-token",
4936+);
49224937const [cliRunDir] = await readdir(path.join(outputDir, "cli-account-add-enable-e2ee"));
49234938const cliArtifactDir = path.join(outputDir, "cli-account-add-enable-e2ee", cliRunDir ?? "");
49244939await expect(
@@ -5049,12 +5064,18 @@ describe("matrix live qa scenarios", () => {
50495064["matrix", "encryption", "setup", "--account", "cli-encryption-setup", "--json"],
50505065["matrix", "verify", "status", "--account", "cli-encryption-setup", "--json"],
50515066]);
5052-expect(registerWithToken.mock.calls.at(0)?.[0]?.deviceName).toBe(
5067+expect(mockObjectArg(registerWithToken, "registerWithToken").deviceName).toBe(
50535068"OpenClaw Matrix QA CLI Encryption Setup Owner",
50545069);
5055-expect(registerWithToken.mock.calls.at(0)?.[0]?.registrationToken).toBe("registration-token");
5056-expect(loginWithPassword.mock.calls.at(0)?.[0]?.password).toBe("cli-setup-password");
5057-expect(loginWithPassword.mock.calls.at(0)?.[0]?.userId).toBe("@cli-setup:matrix-qa.test");
5070+expect(mockObjectArg(registerWithToken, "registerWithToken").registrationToken).toBe(
5071+"registration-token",
5072+);
5073+expect(mockObjectArg(loginWithPassword, "loginWithPassword").password).toBe(
5074+"cli-setup-password",
5075+);
5076+expect(mockObjectArg(loginWithPassword, "loginWithPassword").userId).toBe(
5077+"@cli-setup:matrix-qa.test",
5078+);
50585079const [cliRunDir] = await readdir(path.join(outputDir, "cli-encryption-setup"));
50595080const cliArtifactDir = path.join(outputDir, "cli-encryption-setup", cliRunDir ?? "");
50605081await expect(
@@ -5169,12 +5190,16 @@ describe("matrix live qa scenarios", () => {
51695190["matrix", "encryption", "setup", "--account", "cli-encryption-idempotent", "--json"],
51705191["matrix", "encryption", "setup", "--account", "cli-encryption-idempotent", "--json"],
51715192]);
5172-expect(registerWithToken.mock.calls.at(0)?.[0]?.deviceName).toBe(
5193+expect(mockObjectArg(registerWithToken, "registerWithToken").deviceName).toBe(
51735194"OpenClaw Matrix QA CLI Encryption Idempotent Owner",
51745195);
5175-expect(registerWithToken.mock.calls.at(0)?.[0]?.registrationToken).toBe("registration-token");
5176-expect(loginWithPassword.mock.calls.at(0)?.[0]?.password).toBe("cli-idempotent-password");
5177-expect(loginWithPassword.mock.calls.at(0)?.[0]?.userId).toBe(
5196+expect(mockObjectArg(registerWithToken, "registerWithToken").registrationToken).toBe(
5197+"registration-token",
5198+);
5199+expect(mockObjectArg(loginWithPassword, "loginWithPassword").password).toBe(
5200+"cli-idempotent-password",
5201+);
5202+expect(mockObjectArg(loginWithPassword, "loginWithPassword").userId).toBe(
51785203"@cli-idempotent:matrix-qa.test",
51795204);
51805205const [cliRunDir] = await readdir(path.join(outputDir, "cli-encryption-setup-idempotent"));
@@ -5292,26 +5317,37 @@ describe("matrix live qa scenarios", () => {
52925317search: "",
52935318}),
52945319).toBe(true);
5295-expect(startMatrixQaOpenClawCli.mock.calls.at(0)?.[0].args).toEqual([
5320+expect(mockObjectArg(startMatrixQaOpenClawCli, "startMatrixQaOpenClawCli").args).toEqual([
52965321"matrix",
52975322"encryption",
52985323"setup",
52995324"--account",
53005325"cli-encryption-failure",
53015326"--json",
53025327]);
5303-expect(startMatrixQaOpenClawCli.mock.calls.at(0)?.[0].env.OPENCLAW_CONFIG_PATH).toContain(
5304-"openclaw-matrix-e2ee-setup-qa-",
5305-);
5328+expect(
5329+(
5330+mockObjectArg(startMatrixQaOpenClawCli, "startMatrixQaOpenClawCli").env as Record<
5331+string,
5332+unknown
5333+>
5334+).OPENCLAW_CONFIG_PATH,
5335+).toContain("openclaw-matrix-e2ee-setup-qa-");
53065336expect(output).toHaveBeenCalledTimes(1);
53075337expect(wait).toHaveBeenCalledTimes(1);
53085338expect(kill).toHaveBeenCalledTimes(1);
5309-expect(registerWithToken.mock.calls.at(0)?.[0]?.deviceName).toBe(
5339+expect(mockObjectArg(registerWithToken, "registerWithToken").deviceName).toBe(
53105340"OpenClaw Matrix QA CLI Encryption Failure Owner",
53115341);
5312-expect(registerWithToken.mock.calls.at(0)?.[0]?.registrationToken).toBe("registration-token");
5313-expect(loginWithPassword.mock.calls.at(0)?.[0]?.password).toBe("cli-failure-password");
5314-expect(loginWithPassword.mock.calls.at(0)?.[0]?.userId).toBe("@cli-failure:matrix-qa.test");
5342+expect(mockObjectArg(registerWithToken, "registerWithToken").registrationToken).toBe(
5343+"registration-token",
5344+);
5345+expect(mockObjectArg(loginWithPassword, "loginWithPassword").password).toBe(
5346+"cli-failure-password",
5347+);
5348+expect(mockObjectArg(loginWithPassword, "loginWithPassword").userId).toBe(
5349+"@cli-failure:matrix-qa.test",
5350+);
53155351expect(proxyStop).toHaveBeenCalledTimes(1);
53165352const [cliRunDir] = await readdir(
53175353path.join(outputDir, "cli-encryption-setup-bootstrap-failure"),
@@ -5475,12 +5511,18 @@ describe("matrix live qa scenarios", () => {
54755511"--json",
54765512],
54775513]);
5478-expect(registerWithToken.mock.calls.at(0)?.[0]?.deviceName).toBe(
5514+expect(mockObjectArg(registerWithToken, "registerWithToken").deviceName).toBe(
54795515"OpenClaw Matrix QA CLI Recovery Key Owner",
54805516);
5481-expect(registerWithToken.mock.calls.at(0)?.[0]?.registrationToken).toBe("registration-token");
5482-expect(loginWithPassword.mock.calls.at(0)?.[0]?.password).toBe("cli-recovery-password");
5483-expect(loginWithPassword.mock.calls.at(0)?.[0]?.userId).toBe("@cli-recovery:matrix-qa.test");
5517+expect(mockObjectArg(registerWithToken, "registerWithToken").registrationToken).toBe(
5518+"registration-token",
5519+);
5520+expect(mockObjectArg(loginWithPassword, "loginWithPassword").password).toBe(
5521+"cli-recovery-password",
5522+);
5523+expect(mockObjectArg(loginWithPassword, "loginWithPassword").userId).toBe(
5524+"@cli-recovery:matrix-qa.test",
5525+);
54845526expect(deleteOwnDevices).toHaveBeenCalledWith(["CLIRECOVERYDEVICE"]);
54855527expect(stop).toHaveBeenCalledTimes(1);
54865528const [cliRunDir] = await readdir(path.join(outputDir, "cli-recovery-key-setup"));
@@ -5589,7 +5631,7 @@ describe("matrix live qa scenarios", () => {
55895631expect(artifacts.recoveryKeyRejected).toBe(true);
55905632expect(artifacts.setupSuccess).toBe(false);
559156335592-expect(startMatrixQaOpenClawCli.mock.calls.at(0)?.[0].args).toEqual([
5634+expect(mockObjectArg(startMatrixQaOpenClawCli, "startMatrixQaOpenClawCli").args).toEqual([
55935635"matrix",
55945636"encryption",
55955637"setup",
@@ -5602,12 +5644,18 @@ describe("matrix live qa scenarios", () => {
56025644expect(output).toHaveBeenCalledTimes(1);
56035645expect(wait).toHaveBeenCalledTimes(1);
56045646expect(kill).toHaveBeenCalledTimes(1);
5605-expect(registerWithToken.mock.calls.at(0)?.[0]?.deviceName).toBe(
5647+expect(mockObjectArg(registerWithToken, "registerWithToken").deviceName).toBe(
56065648"OpenClaw Matrix QA CLI Invalid Recovery Key Owner",
56075649);
5608-expect(registerWithToken.mock.calls.at(0)?.[0]?.registrationToken).toBe("registration-token");
5609-expect(loginWithPassword.mock.calls.at(0)?.[0]?.password).toBe("cli-invalid-password");
5610-expect(loginWithPassword.mock.calls.at(0)?.[0]?.userId).toBe("@cli-invalid:matrix-qa.test");
5650+expect(mockObjectArg(registerWithToken, "registerWithToken").registrationToken).toBe(
5651+"registration-token",
5652+);
5653+expect(mockObjectArg(loginWithPassword, "loginWithPassword").password).toBe(
5654+"cli-invalid-password",
5655+);
5656+expect(mockObjectArg(loginWithPassword, "loginWithPassword").userId).toBe(
5657+"@cli-invalid:matrix-qa.test",
5658+);
56115659expect(deleteOwnDevices).toHaveBeenCalledWith(["CLIINVALIDDEVICE"]);
56125660expect(stop).toHaveBeenCalledTimes(1);
56135661const [cliRunDir] = await readdir(path.join(outputDir, "cli-recovery-key-invalid"));
@@ -5713,12 +5761,18 @@ describe("matrix live qa scenarios", () => {
57135761expect(runMatrixQaOpenClawCli.mock.calls.map(([params]) => params.args)).toEqual([
57145762["matrix", "encryption", "setup", "--account", "cli-multi-target", "--json"],
57155763]);
5716-expect(registerWithToken.mock.calls.at(0)?.[0]?.deviceName).toBe(
5764+expect(mockObjectArg(registerWithToken, "registerWithToken").deviceName).toBe(
57175765"OpenClaw Matrix QA CLI Multi Account Owner",
57185766);
5719-expect(registerWithToken.mock.calls.at(0)?.[0]?.registrationToken).toBe("registration-token");
5720-expect(loginWithPassword.mock.calls.at(0)?.[0]?.password).toBe("cli-multi-password");
5721-expect(loginWithPassword.mock.calls.at(0)?.[0]?.userId).toBe("@cli-multi:matrix-qa.test");
5767+expect(mockObjectArg(registerWithToken, "registerWithToken").registrationToken).toBe(
5768+"registration-token",
5769+);
5770+expect(mockObjectArg(loginWithPassword, "loginWithPassword").password).toBe(
5771+"cli-multi-password",
5772+);
5773+expect(mockObjectArg(loginWithPassword, "loginWithPassword").userId).toBe(
5774+"@cli-multi:matrix-qa.test",
5775+);
57225776const [cliRunDir] = await readdir(path.join(outputDir, "cli-encryption-setup-multi-account"));
57235777const cliArtifactDir = path.join(
57245778outputDir,
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。