index.html 3.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  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. <a class="ui blue button" href="backend.html">Open Backend Unit Test</a>
  33. <div class="ui divider"></div>
  34. <p>Test Results</p>
  35. <table class="ui celled table">
  36. <thead>
  37. <tr><th>Script</th>
  38. <th>Results</th>
  39. <th>Status</th>
  40. </tr></thead>
  41. <tbody id="results">
  42. </tbody>
  43. </table>
  44. </div>
  45. <br><br>
  46. <script>
  47. function openGateway(){
  48. window.open("../system/ajgi/interface");
  49. }
  50. function runtest(){
  51. $("#results").html("");
  52. //Get a list of test to be run
  53. ao_module_agirun("UnitTest/list.agi",{testdata: "Hello World"}, function(data){
  54. data.forEach(test => {
  55. let scriptname = test.split("/").pop();
  56. let thisScriptPath = JSON.parse(JSON.stringify(test));
  57. ao_module_agirun(test, {foo: "Hello", bar: "World"}, function(data){
  58. //Success callback
  59. $("#results").append(`<tr class="positive">
  60. <td data-label="">${scriptname}</td>
  61. <td data-label="">${JSON.stringify(data)}</td>
  62. <td data-label="">Success</td>
  63. </tr>`);
  64. }, function(){
  65. $("#results").append(`<tr class="negative">
  66. <td data-label="">${scriptname}</td>
  67. <td data-label=""><a href="../system/ajgi/interface?script=${thisScriptPath}" target="_blank">Open Debug Interface</a></td>
  68. <td data-label="">Failed</td>
  69. </tr>`);
  70. }, 10000);
  71. });
  72. })
  73. }
  74. </script>
  75. </body>
  76. </html>