mirror of
https://github.com/openclaw/openclaw.git
synced 2026-06-06 05:51:15 +08:00
test: require device pair media url
This commit is contained in:
@@ -133,6 +133,13 @@ function requireText(result: { text?: unknown } | null | undefined): string {
|
||||
return result.text;
|
||||
}
|
||||
|
||||
function requireMediaUrl(opts: { mediaUrl?: string }): string {
|
||||
if (!opts.mediaUrl) {
|
||||
throw new Error("pair command did not send a media URL");
|
||||
}
|
||||
return opts.mediaUrl;
|
||||
}
|
||||
|
||||
function createChannelRuntime(
|
||||
runtimeKey: string,
|
||||
sendKey: string,
|
||||
@@ -479,11 +486,12 @@ describe("device-pair /pair qr", () => {
|
||||
expect(caption).toContain("Scan this QR code with the OpenClaw iOS app:");
|
||||
expect(caption).toContain("IMPORTANT: After pairing finishes, run /pair cleanup.");
|
||||
expect(caption).toContain("If this QR code leaks, run /pair cleanup immediately.");
|
||||
expect(opts.mediaUrl).toMatch(/pair-qr\.png$/);
|
||||
expect(opts.mediaLocalRoots).toEqual([path.dirname(opts.mediaUrl!)]);
|
||||
const mediaUrl = requireMediaUrl(opts);
|
||||
expect(mediaUrl).toMatch(/pair-qr\.png$/);
|
||||
expect(opts.mediaLocalRoots).toEqual([path.dirname(mediaUrl)]);
|
||||
expect(opts).toMatchObject(testCase.expectedOpts);
|
||||
expect(sentPng).toBe("fakepng");
|
||||
await expect(fs.access(opts.mediaUrl!)).rejects.toThrow();
|
||||
await expect(fs.access(mediaUrl)).rejects.toThrow();
|
||||
expect(text).toContain("QR code sent above.");
|
||||
expect(text).toContain("IMPORTANT: Run /pair cleanup after pairing finishes.");
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user