Skip to content

Commit cb60a06

Browse files
committed
test: tighten qa matrix encryption cli assertions
1 parent 9b8a604 commit cb60a06

1 file changed

Lines changed: 76 additions & 79 deletions

File tree

extensions/qa-matrix/src/runners/contract/scenarios.test.ts

Lines changed: 76 additions & 79 deletions
Original file line numberDiff line numberDiff line change
@@ -4972,53 +4972,51 @@ describe("matrix live qa scenarios", () => {
49724972

49734973
const scenario = requireMatrixQaScenario("matrix-e2ee-cli-encryption-setup");
49744974

4975-
await expect(
4976-
runMatrixQaScenario(scenario, {
4977-
...matrixQaScenarioContext(),
4978-
driverDeviceId: "DRIVERDEVICE",
4979-
driverPassword: "driver-password",
4980-
gatewayRuntimeEnv: {
4981-
OPENCLAW_CONFIG_PATH: "/tmp/gateway-config.json",
4982-
OPENCLAW_STATE_DIR: "/tmp/gateway-state",
4983-
PATH: process.env.PATH,
4984-
},
4985-
outputDir,
4986-
}),
4987-
).resolves.toMatchObject({
4988-
artifacts: {
4989-
accountId: "cli-encryption-setup",
4990-
cliDeviceId: "CLISETUPDEVICE",
4991-
encryptionChanged: true,
4992-
setupSuccess: true,
4993-
verificationBootstrapSuccess: true,
4975+
const result = await runMatrixQaScenario(scenario, {
4976+
...matrixQaScenarioContext(),
4977+
driverDeviceId: "DRIVERDEVICE",
4978+
driverPassword: "driver-password",
4979+
gatewayRuntimeEnv: {
4980+
OPENCLAW_CONFIG_PATH: "/tmp/gateway-config.json",
4981+
OPENCLAW_STATE_DIR: "/tmp/gateway-state",
4982+
PATH: process.env.PATH,
49944983
},
4984+
outputDir,
49954985
});
4986+
const artifacts = result.artifacts as {
4987+
accountId?: unknown;
4988+
cliDeviceId?: unknown;
4989+
encryptionChanged?: unknown;
4990+
setupSuccess?: unknown;
4991+
verificationBootstrapSuccess?: unknown;
4992+
};
4993+
expect(artifacts.accountId).toBe("cli-encryption-setup");
4994+
expect(artifacts.cliDeviceId).toBe("CLISETUPDEVICE");
4995+
expect(artifacts.encryptionChanged).toBe(true);
4996+
expect(artifacts.setupSuccess).toBe(true);
4997+
expect(artifacts.verificationBootstrapSuccess).toBe(true);
49964998

4997-
expect(initialAccountConfig).toMatchObject({
4998-
accessToken: "cli-setup-token",
4999-
deviceId: "CLISETUPDEVICE",
5000-
encryption: false,
5001-
homeserver: "http://127.0.0.1:28008/",
5002-
password: "cli-setup-password",
5003-
startupVerification: "off",
5004-
userId: "@cli-setup:matrix-qa.test",
5005-
});
4999+
if (!initialAccountConfig) {
5000+
throw new Error("expected initial CLI encryption setup account config");
5001+
}
5002+
const capturedInitialAccountConfig = initialAccountConfig as Record<string, unknown>;
5003+
expect(capturedInitialAccountConfig.accessToken).toBe("cli-setup-token");
5004+
expect(capturedInitialAccountConfig.deviceId).toBe("CLISETUPDEVICE");
5005+
expect(capturedInitialAccountConfig.encryption).toBe(false);
5006+
expect(capturedInitialAccountConfig.homeserver).toBe("http://127.0.0.1:28008/");
5007+
expect(capturedInitialAccountConfig.password).toBe("cli-setup-password");
5008+
expect(capturedInitialAccountConfig.startupVerification).toBe("off");
5009+
expect(capturedInitialAccountConfig.userId).toBe("@cli-setup:matrix-qa.test");
50065010
expect(runMatrixQaOpenClawCli.mock.calls.map(([params]) => params.args)).toEqual([
50075011
["matrix", "encryption", "setup", "--account", "cli-encryption-setup", "--json"],
50085012
["matrix", "verify", "status", "--account", "cli-encryption-setup", "--json"],
50095013
]);
5010-
expect(registerWithToken).toHaveBeenCalledWith(
5011-
expect.objectContaining({
5012-
deviceName: "OpenClaw Matrix QA CLI Encryption Setup Owner",
5013-
registrationToken: "registration-token",
5014-
}),
5015-
);
5016-
expect(loginWithPassword).toHaveBeenCalledWith(
5017-
expect.objectContaining({
5018-
password: "cli-setup-password",
5019-
userId: "@cli-setup:matrix-qa.test",
5020-
}),
5014+
expect(registerWithToken.mock.calls[0]?.[0]?.deviceName).toBe(
5015+
"OpenClaw Matrix QA CLI Encryption Setup Owner",
50215016
);
5017+
expect(registerWithToken.mock.calls[0]?.[0]?.registrationToken).toBe("registration-token");
5018+
expect(loginWithPassword.mock.calls[0]?.[0]?.password).toBe("cli-setup-password");
5019+
expect(loginWithPassword.mock.calls[0]?.[0]?.userId).toBe("@cli-setup:matrix-qa.test");
50225020
const [cliRunDir] = await readdir(path.join(outputDir, "cli-encryption-setup"));
50235021
const cliArtifactDir = path.join(outputDir, "cli-encryption-setup", cliRunDir ?? "");
50245022
await expect(
@@ -5092,54 +5090,53 @@ describe("matrix live qa scenarios", () => {
50925090

50935091
const scenario = requireMatrixQaScenario("matrix-e2ee-cli-encryption-setup-idempotent");
50945092

5095-
await expect(
5096-
runMatrixQaScenario(scenario, {
5097-
...matrixQaScenarioContext(),
5098-
driverDeviceId: "DRIVERDEVICE",
5099-
driverPassword: "driver-password",
5100-
gatewayRuntimeEnv: {
5101-
OPENCLAW_CONFIG_PATH: "/tmp/gateway-config.json",
5102-
OPENCLAW_STATE_DIR: "/tmp/gateway-state",
5103-
PATH: process.env.PATH,
5104-
},
5105-
outputDir,
5106-
}),
5107-
).resolves.toMatchObject({
5108-
artifacts: {
5109-
accountId: "cli-encryption-idempotent",
5110-
cliDeviceId: "CLIIDEMPOTENTDEVICE",
5111-
firstEncryptionChanged: false,
5112-
secondEncryptionChanged: false,
5113-
setupSuccess: true,
5114-
verificationBootstrapSuccess: true,
5093+
const result = await runMatrixQaScenario(scenario, {
5094+
...matrixQaScenarioContext(),
5095+
driverDeviceId: "DRIVERDEVICE",
5096+
driverPassword: "driver-password",
5097+
gatewayRuntimeEnv: {
5098+
OPENCLAW_CONFIG_PATH: "/tmp/gateway-config.json",
5099+
OPENCLAW_STATE_DIR: "/tmp/gateway-state",
5100+
PATH: process.env.PATH,
51155101
},
5102+
outputDir,
51165103
});
5104+
const artifacts = result.artifacts as {
5105+
accountId?: unknown;
5106+
cliDeviceId?: unknown;
5107+
firstEncryptionChanged?: unknown;
5108+
secondEncryptionChanged?: unknown;
5109+
setupSuccess?: unknown;
5110+
verificationBootstrapSuccess?: unknown;
5111+
};
5112+
expect(artifacts.accountId).toBe("cli-encryption-idempotent");
5113+
expect(artifacts.cliDeviceId).toBe("CLIIDEMPOTENTDEVICE");
5114+
expect(artifacts.firstEncryptionChanged).toBe(false);
5115+
expect(artifacts.secondEncryptionChanged).toBe(false);
5116+
expect(artifacts.setupSuccess).toBe(true);
5117+
expect(artifacts.verificationBootstrapSuccess).toBe(true);
51175118

5118-
expect(initialAccountConfig).toMatchObject({
5119-
accessToken: "cli-idempotent-token",
5120-
deviceId: "CLIIDEMPOTENTDEVICE",
5121-
encryption: true,
5122-
homeserver: "http://127.0.0.1:28008/",
5123-
password: "cli-idempotent-password",
5124-
startupVerification: "off",
5125-
userId: "@cli-idempotent:matrix-qa.test",
5126-
});
5119+
if (!initialAccountConfig) {
5120+
throw new Error("expected initial CLI encryption idempotent account config");
5121+
}
5122+
const capturedInitialAccountConfig = initialAccountConfig as Record<string, unknown>;
5123+
expect(capturedInitialAccountConfig.accessToken).toBe("cli-idempotent-token");
5124+
expect(capturedInitialAccountConfig.deviceId).toBe("CLIIDEMPOTENTDEVICE");
5125+
expect(capturedInitialAccountConfig.encryption).toBe(true);
5126+
expect(capturedInitialAccountConfig.homeserver).toBe("http://127.0.0.1:28008/");
5127+
expect(capturedInitialAccountConfig.password).toBe("cli-idempotent-password");
5128+
expect(capturedInitialAccountConfig.startupVerification).toBe("off");
5129+
expect(capturedInitialAccountConfig.userId).toBe("@cli-idempotent:matrix-qa.test");
51275130
expect(runMatrixQaOpenClawCli.mock.calls.map(([params]) => params.args)).toEqual([
51285131
["matrix", "encryption", "setup", "--account", "cli-encryption-idempotent", "--json"],
51295132
["matrix", "encryption", "setup", "--account", "cli-encryption-idempotent", "--json"],
51305133
]);
5131-
expect(registerWithToken).toHaveBeenCalledWith(
5132-
expect.objectContaining({
5133-
deviceName: "OpenClaw Matrix QA CLI Encryption Idempotent Owner",
5134-
registrationToken: "registration-token",
5135-
}),
5136-
);
5137-
expect(loginWithPassword).toHaveBeenCalledWith(
5138-
expect.objectContaining({
5139-
password: "cli-idempotent-password",
5140-
userId: "@cli-idempotent:matrix-qa.test",
5141-
}),
5134+
expect(registerWithToken.mock.calls[0]?.[0]?.deviceName).toBe(
5135+
"OpenClaw Matrix QA CLI Encryption Idempotent Owner",
51425136
);
5137+
expect(registerWithToken.mock.calls[0]?.[0]?.registrationToken).toBe("registration-token");
5138+
expect(loginWithPassword.mock.calls[0]?.[0]?.password).toBe("cli-idempotent-password");
5139+
expect(loginWithPassword.mock.calls[0]?.[0]?.userId).toBe("@cli-idempotent:matrix-qa.test");
51435140
const [cliRunDir] = await readdir(path.join(outputDir, "cli-encryption-setup-idempotent"));
51445141
const cliArtifactDir = path.join(
51455142
outputDir,

0 commit comments

Comments
 (0)