index.html 3.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <meta name="apple-mobile-web-app-capable" content="yes" />
  5. <meta name="viewport" content="user-scalable=no, width=device-width, initial-scale=1, maximum-scale=1"/>
  6. <meta charset="UTF-8">
  7. <meta name="theme-color" content="#4b75ff">
  8. <link rel="stylesheet" href="../script/semantic/semantic.min.css">
  9. <script src="../script/jquery.min.js"></script>
  10. <script src="../script/ao_module.js"></script>
  11. <script src="../script/semantic/semantic.min.js"></script>
  12. <title>Unit Test</title>
  13. <style>
  14. body{
  15. background-color:white;
  16. }
  17. .success{
  18. color: #20c942;
  19. }
  20. .failed{
  21. color: #eb4034;
  22. }
  23. </style>
  24. </head>
  25. <body>
  26. <br><br>
  27. <div class="ui text container">
  28. <h3>AGI Unit Testing Module</h3>
  29. <button class="ui button" onclick="openGateway();">Open AGI Gateway (No File)</button>
  30. <button class="ui button" onclick="runtest();">Run Unit Test</button>
  31. <a class="ui button" href="wstest.html">Open WebSocket Test</a>
  32. <div class="ui divider"></div>
  33. <p>Test Results</p>
  34. <table class="ui celled table">
  35. <thead>
  36. <tr><th>Script</th>
  37. <th>Results</th>
  38. <th>Status</th>
  39. </tr></thead>
  40. <tbody id="results">
  41. </tbody>
  42. </table>
  43. </div>
  44. <br><br>
  45. <script>
  46. function openGateway(){
  47. window.open("../system/ajgi/interface");
  48. }
  49. function runtest(){
  50. $("#results").html("");
  51. //Get a list of test to be run
  52. ao_module_agirun("UnitTest/list.agi",{testdata: "Hello World"}, function(data){
  53. data.forEach(test => {
  54. let scriptname = test.split("/").pop();
  55. let thisScriptPath = JSON.parse(JSON.stringify(test));
  56. ao_module_agirun(test, {foo: "Hello", bar: "World"}, function(data){
  57. //Success callback
  58. $("#results").append(`<tr class="positive">
  59. <td data-label="">${scriptname}</td>
  60. <td data-label="">${JSON.stringify(data)}</td>
  61. <td data-label="">Success</td>
  62. </tr>`);
  63. }, function(){
  64. $("#results").append(`<tr class="negative">
  65. <td data-label="">${scriptname}</td>
  66. <td data-label=""><a href="../system/ajgi/interface?script=${thisScriptPath}" target="_blank">Open Debug Interface</a></td>
  67. <td data-label="">Failed</td>
  68. </tr>`);
  69. }, 10000);
  70. });
  71. })
  72. }
  73. </script>
  74. </body>
  75. </html>