@nbakka/mcp-appium 2.0.90 → 2.0.92
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/review-ui/index.html +49 -5
- package/lib/server.js +30 -26
- package/package.json +1 -1
package/lib/review-ui/index.html
CHANGED
|
@@ -67,7 +67,7 @@
|
|
|
67
67
|
color: #666;
|
|
68
68
|
font-size: 0.9em;
|
|
69
69
|
}
|
|
70
|
-
.edit-btn, .save-btn, .cancel-btn-inline {
|
|
70
|
+
.edit-btn, .save-btn, .cancel-btn-inline, .delete-btn {
|
|
71
71
|
padding: 6px 12px;
|
|
72
72
|
border: none;
|
|
73
73
|
border-radius: 4px;
|
|
@@ -87,6 +87,13 @@
|
|
|
87
87
|
background-color: #757575;
|
|
88
88
|
color: white;
|
|
89
89
|
}
|
|
90
|
+
.delete-btn {
|
|
91
|
+
background-color: #f44336;
|
|
92
|
+
color: white;
|
|
93
|
+
}
|
|
94
|
+
.delete-btn:hover {
|
|
95
|
+
background-color: #d32f2f;
|
|
96
|
+
}
|
|
90
97
|
.original-text {
|
|
91
98
|
color: #999;
|
|
92
99
|
text-decoration: line-through;
|
|
@@ -228,10 +235,13 @@
|
|
|
228
235
|
const container = document.getElementById('new-cases');
|
|
229
236
|
if (testCases.new && testCases.new.length > 0) {
|
|
230
237
|
container.innerHTML = testCases.new.map((tc, index) => `
|
|
231
|
-
<div class="test-case">
|
|
238
|
+
<div class="test-case" id="new-case-${index}">
|
|
232
239
|
<div class="test-case-header">
|
|
233
240
|
<span class="test-case-id">ID: ${tc.id}</span>
|
|
234
|
-
<
|
|
241
|
+
<div>
|
|
242
|
+
<button class="edit-btn" onclick="toggleEdit('new', ${index})">Edit</button>
|
|
243
|
+
<button class="delete-btn" onclick="deleteTestCase('new', ${index})">Delete</button>
|
|
244
|
+
</div>
|
|
235
245
|
</div>
|
|
236
246
|
<div id="new-${index}-display" style="display: block;">
|
|
237
247
|
<strong>Description:</strong> ${tc.description}
|
|
@@ -255,10 +265,13 @@
|
|
|
255
265
|
const container = document.getElementById('modify-cases');
|
|
256
266
|
if (testCases.modify && testCases.modify.length > 0) {
|
|
257
267
|
container.innerHTML = testCases.modify.map((tc, index) => `
|
|
258
|
-
<div class="test-case">
|
|
268
|
+
<div class="test-case" id="modify-case-${index}">
|
|
259
269
|
<div class="test-case-header">
|
|
260
270
|
<span class="test-case-id">ID: ${tc.id}</span>
|
|
261
|
-
<
|
|
271
|
+
<div>
|
|
272
|
+
<button class="edit-btn" onclick="toggleEdit('modify', ${index})">Edit</button>
|
|
273
|
+
<button class="delete-btn" onclick="deleteTestCase('modify', ${index})">Delete</button>
|
|
274
|
+
</div>
|
|
262
275
|
</div>
|
|
263
276
|
<div id="modify-${index}-display" style="display: block;">
|
|
264
277
|
<div class="original-text"><strong>Original:</strong> ${tc.original}</div>
|
|
@@ -397,6 +410,37 @@
|
|
|
397
410
|
}
|
|
398
411
|
}
|
|
399
412
|
|
|
413
|
+
async function deleteTestCase(type, index) {
|
|
414
|
+
const confirmation = confirm("Are you sure you want to delete this test case?");
|
|
415
|
+
if (!confirmation) return;
|
|
416
|
+
|
|
417
|
+
try {
|
|
418
|
+
showStatus('Deleting test case...', 'info');
|
|
419
|
+
const response = await fetch(`/delete/${sessionId}`, {
|
|
420
|
+
method: 'POST',
|
|
421
|
+
headers: { 'Content-Type': 'application/json' },
|
|
422
|
+
body: JSON.stringify({ type, index })
|
|
423
|
+
});
|
|
424
|
+
|
|
425
|
+
if (!response.ok) {
|
|
426
|
+
throw new Error(`HTTP ${response.status}: ${response.statusText}`);
|
|
427
|
+
}
|
|
428
|
+
|
|
429
|
+
// Remove the deleted test case from the local state
|
|
430
|
+
if (type === 'new') {
|
|
431
|
+
testCases.new.splice(index, 1);
|
|
432
|
+
} else if (type === 'modify') {
|
|
433
|
+
testCases.modify.splice(index, 1);
|
|
434
|
+
}
|
|
435
|
+
|
|
436
|
+
// Re-render the UI to update indexes and remove the element
|
|
437
|
+
renderTestCases();
|
|
438
|
+
showStatus('Test case deleted successfully!', 'success');
|
|
439
|
+
} catch (error) {
|
|
440
|
+
showStatus(`Error deleting test case: ${error.message}`, 'error');
|
|
441
|
+
}
|
|
442
|
+
}
|
|
443
|
+
|
|
400
444
|
// Load test cases when page loads
|
|
401
445
|
window.onload = loadTestCases;
|
|
402
446
|
</script>
|
package/lib/server.js
CHANGED
|
@@ -896,6 +896,30 @@ tool(
|
|
|
896
896
|
res.json({ status: 'cancelled', message: 'Review cancelled' });
|
|
897
897
|
});
|
|
898
898
|
|
|
899
|
+
app.post(`/delete/${sessionId}`, (req, res) => {
|
|
900
|
+
const session = approvalSessions.get(sessionId);
|
|
901
|
+
if (!session) {
|
|
902
|
+
return res.status(404).json({ error: 'Session not found' });
|
|
903
|
+
}
|
|
904
|
+
|
|
905
|
+
const { type, index } = req.body;
|
|
906
|
+
|
|
907
|
+
try {
|
|
908
|
+
if (type === 'new' && session.testCases.new && index < session.testCases.new.length) {
|
|
909
|
+
session.testCases.new.splice(index, 1);
|
|
910
|
+
} else if (type === 'modify' && session.testCases.modify && index < session.testCases.modify.length) {
|
|
911
|
+
session.testCases.modify.splice(index, 1);
|
|
912
|
+
} else {
|
|
913
|
+
return res.status(400).json({ error: 'Invalid type or index' });
|
|
914
|
+
}
|
|
915
|
+
|
|
916
|
+
approvalSessions.set(sessionId, session);
|
|
917
|
+
res.json({ status: 'deleted', message: 'Test case deleted successfully' });
|
|
918
|
+
} catch (error) {
|
|
919
|
+
res.status(500).json({ error: 'Failed to delete test case' });
|
|
920
|
+
}
|
|
921
|
+
});
|
|
922
|
+
|
|
899
923
|
const server = app.listen(port, async () => {
|
|
900
924
|
// Remove console.log to prevent JSON parsing errors
|
|
901
925
|
try {
|
|
@@ -951,10 +975,7 @@ tool(
|
|
|
951
975
|
|
|
952
976
|
const session = approvalSessions.get(sessionId);
|
|
953
977
|
if (!session) {
|
|
954
|
-
return
|
|
955
|
-
status: "error",
|
|
956
|
-
message: `Session not found. Invalid session ID: ${sessionId}`
|
|
957
|
-
});
|
|
978
|
+
return `❌ Session not found. Invalid session ID: ${sessionId}`;
|
|
958
979
|
}
|
|
959
980
|
|
|
960
981
|
const currentTime = Date.now();
|
|
@@ -968,41 +989,24 @@ tool(
|
|
|
968
989
|
}
|
|
969
990
|
approvalSessions.delete(sessionId);
|
|
970
991
|
|
|
971
|
-
return JSON.stringify(
|
|
972
|
-
status: "approved",
|
|
973
|
-
message: "Test cases approved successfully!",
|
|
974
|
-
elapsedTime: elapsedTime,
|
|
975
|
-
approvedTestCases: approvedTestCases
|
|
976
|
-
});
|
|
992
|
+
return `✅ Test cases approved successfully! Elapsed time: ${elapsedTime}s\n\nApproved test cases:\n${JSON.stringify(approvedTestCases, null, 2)}`;
|
|
977
993
|
} else if (session.status === 'cancelled') {
|
|
978
994
|
if (session.server) {
|
|
979
995
|
session.server.close();
|
|
980
996
|
}
|
|
981
997
|
approvalSessions.delete(sessionId);
|
|
982
998
|
|
|
983
|
-
return
|
|
984
|
-
status: "cancelled",
|
|
985
|
-
message: "Review was cancelled by the user",
|
|
986
|
-
elapsedTime: elapsedTime
|
|
987
|
-
});
|
|
999
|
+
return `❌ Review was cancelled by the user. Elapsed time: ${elapsedTime}s`;
|
|
988
1000
|
} else if (session.status === 'timeout' || elapsedTime > 300) {
|
|
989
1001
|
if (session.server) {
|
|
990
1002
|
session.server.close();
|
|
991
1003
|
}
|
|
992
1004
|
approvalSessions.delete(sessionId);
|
|
993
1005
|
|
|
994
|
-
return
|
|
995
|
-
status: "timeout",
|
|
996
|
-
message: "Review session timed out",
|
|
997
|
-
elapsedTime: elapsedTime
|
|
998
|
-
});
|
|
1006
|
+
return `⏰ Review session timed out. Elapsed time: ${elapsedTime}s`;
|
|
999
1007
|
} else {
|
|
1000
|
-
|
|
1001
|
-
|
|
1002
|
-
message: "Test cases are still pending approval",
|
|
1003
|
-
elapsedTime: elapsedTime,
|
|
1004
|
-
remainingTime: Math.max(0, 300 - elapsedTime)
|
|
1005
|
-
});
|
|
1008
|
+
const remainingTime = Math.max(0, 300 - elapsedTime);
|
|
1009
|
+
return `⏳ Test cases are still pending approval. Elapsed: ${elapsedTime}s, Remaining: ${remainingTime}s`;
|
|
1006
1010
|
}
|
|
1007
1011
|
}
|
|
1008
1012
|
);
|