Skip to content

Commit e8435a2

Browse files
committed
test(e2e): cover claude/gemini resume commands
1 parent a5b9ba6 commit e8435a2

4 files changed

Lines changed: 54 additions & 2 deletions

File tree

tests/e2e/run.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ const testClaudeProxy = require('./test-claude-proxy');
1919
const testSessionSearch = require('./test-session-search');
2020
const testSessions = require('./test-sessions');
2121
const testSessionConvertDerived = require('./test-session-convert-derived');
22+
const testSessionResumeCommands = require('./test-session-resume-commands');
2223
const testOpenclaw = require('./test-openclaw');
2324
const testHealthSpeed = require('./test-health-speed');
2425
const testMessages = require('./test-messages');
@@ -132,6 +133,7 @@ async function main() {
132133
await testSessionSearch(ctx);
133134
await testSessions(ctx);
134135
await testSessionConvertDerived(ctx);
136+
await testSessionResumeCommands(ctx);
135137
await testOpenclaw(ctx);
136138
await testHealthSpeed(ctx);
137139
await testMessages(ctx);
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
const path = require('path');
2+
const { pathToFileURL } = require('url');
3+
const { assert } = require('./helpers');
4+
5+
function createWebUiVm(appOptions) {
6+
const vm = {
7+
...(typeof appOptions.data === 'function' ? appOptions.data() : {}),
8+
$refs: {}
9+
};
10+
for (const [name, fn] of Object.entries(appOptions.methods || {})) {
11+
vm[name] = fn;
12+
}
13+
vm.$nextTick = function $nextTick(callback) {
14+
if (typeof callback === 'function') callback();
15+
};
16+
vm.showMessage = function showMessage() {};
17+
vm.fallbackCopyText = function fallbackCopyText() { return true; };
18+
return vm;
19+
}
20+
21+
module.exports = async function testSessionResumeCommands(ctx) {
22+
const { api, claudeSessionId, geminiSessionId, claudeSessionPath, geminiSessionPath } = ctx;
23+
24+
const helperPath = path.resolve(__dirname, '..', 'unit', 'helpers', 'web-ui-app-options.mjs');
25+
const { captureCurrentBundledAppOptions } = await import(pathToFileURL(helperPath).href);
26+
const appOptions = await captureCurrentBundledAppOptions();
27+
const vm = createWebUiVm(appOptions);
28+
29+
const claudeSessions = await api('list-sessions', { source: 'claude', limit: 50, forceRefresh: true });
30+
const claudeEntry = (claudeSessions.sessions || []).find((item) => item && item.sessionId === claudeSessionId);
31+
assert(claudeEntry, 'resume e2e missing claude session entry');
32+
assert(vm.isResumeCommandAvailable(claudeEntry) === true, 'claude session should allow resume command');
33+
assert(vm.buildResumeCommand.call({ ...vm, sessionResumeWithYolo: true }, claudeEntry) === `claude -r ${claudeSessionId}`, 'claude resume command mismatch');
34+
35+
const claudeNoId = { source: 'claude', sessionId: '', filePath: claudeSessionPath };
36+
assert(vm.isResumeCommandAvailable(claudeNoId) === true, 'claude should allow resume from filePath');
37+
assert(vm.buildResumeCommand.call({ ...vm, sessionResumeWithYolo: true }, claudeNoId).includes('claude -r '), 'claude resume command should be generated from filePath');
38+
39+
const geminiSessions = await api('list-sessions', { source: 'gemini', limit: 50, forceRefresh: true });
40+
const geminiEntry = (geminiSessions.sessions || []).find((item) => item && item.sessionId === geminiSessionId);
41+
assert(geminiEntry, 'resume e2e missing gemini session entry');
42+
assert(vm.isResumeCommandAvailable(geminiEntry) === true, 'gemini session should allow resume command');
43+
assert(vm.buildResumeCommand.call({ ...vm, sessionResumeWithYolo: true }, geminiEntry) === `gemini -r ${geminiSessionId}`, 'gemini resume command mismatch');
44+
45+
const geminiNoId = { source: 'gemini', sessionId: '', filePath: geminiSessionPath };
46+
assert(vm.isResumeCommandAvailable(geminiNoId) === true, 'gemini should allow resume from filePath');
47+
assert(vm.buildResumeCommand.call({ ...vm, sessionResumeWithYolo: true }, geminiNoId) === `gemini -r ${geminiSessionId}`, 'gemini resume command should be generated from filePath');
48+
};
49+

tests/unit/run.mjs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ await import(pathToFileURL(path.join(__dirname, 'openclaw-editing.test.mjs')));
3333
await import(pathToFileURL(path.join(__dirname, 'openclaw-persist-regression.test.mjs')));
3434
await import(pathToFileURL(path.join(__dirname, 'agents-modal-guards.test.mjs')));
3535
await import(pathToFileURL(path.join(__dirname, 'session-actions-standalone.test.mjs')));
36+
await import(pathToFileURL(path.join(__dirname, 'session-resume-command.test.mjs')));
3637
await import(pathToFileURL(path.join(__dirname, 'session-header-actions-layout.test.mjs')));
3738
await import(pathToFileURL(path.join(__dirname, 'session-browser-timeline-regression.test.mjs')));
3839
await import(pathToFileURL(path.join(__dirname, 'session-detail-preview-fast.test.mjs')));

web-ui/modules/app.methods.session-actions.mjs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@ export function createSessionActionMethods(options = {}) {
148148
const source = session && session.source ? String(session.source).trim().toLowerCase() : '';
149149
const sessionId = session && session.sessionId ? String(session.sessionId).trim() : '';
150150
const filePath = session && session.filePath ? String(session.filePath).trim() : '';
151-
const resumeKey = source === 'claude'
151+
const resumeKey = (source === 'claude' || source === 'gemini')
152152
? (sessionId || this.extractClaudeResumeKeyFromFilePath(filePath))
153153
: sessionId;
154154
const arg = this.quoteResumeArg(resumeKey);
@@ -175,7 +175,7 @@ export function createSessionActionMethods(options = {}) {
175175
if (!base) return '';
176176
const lower = base.toLowerCase();
177177
if (lower.endsWith('.jsonl')) {
178-
return base.slice(0, -5);
178+
return base.slice(0, -6);
179179
}
180180
if (lower.endsWith('.json')) {
181181
return base.slice(0, -5);

0 commit comments

Comments
 (0)