08_missing_files.js 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135
  1. let _fs = require('fs');
  2. let deleteFolderRecursive = function (path) {
  3. if (_fs.existsSync(path)) {
  4. _fs.readdirSync(path).forEach(function (file, index) {
  5. let curPath = path + "/" + file;
  6. console.log("Deleting: " + curPath);
  7. if (_fs.lstatSync(curPath).isDirectory()) { // recurse
  8. deleteFolderRecursive(curPath);
  9. } else { // delete file
  10. _fs.unlinkSync(curPath);
  11. }
  12. });
  13. _fs.rmdirSync(path);
  14. }
  15. };
  16. module.exports = {
  17. 'Signup user': function (client) {
  18. client.url('http://localhost:8124/atompm').pause(300);
  19. client.execute(
  20. function () {
  21. UserManagement.validateCredentials('userremove', 'test');
  22. }, [], null
  23. );
  24. client.pause(500);
  25. let user_exists = false;
  26. client.getText('div[id=div_login_error]', function (result) {
  27. user_exists = result.value.includes('login failed');
  28. });
  29. if (user_exists == false) {
  30. client.execute(
  31. function () {
  32. UserManagement.signup('userremove', 'test');
  33. }, [], null
  34. );
  35. }
  36. client.pause(500);
  37. client.execute(
  38. function () {
  39. UserManagement.login('userremove');
  40. }, [], null
  41. );
  42. client.pause(500);
  43. client.getTitle(function (title) {
  44. this.assert.ok(title.includes("AToMPM - [Unnamed]"), "AToMPM is opened");
  45. });
  46. },
  47. 'Load Missing Toolbar': function (client) {
  48. let filename = './toolbars/missing.metamodel';
  49. client.execute(
  50. function () {
  51. DataUtils.loadbm('./toolbars/missing.metamodel');
  52. }, [], null
  53. );
  54. client.waitForElementPresent("#dialog_btn", 2000, "Check for toolbar loading error: " + filename);
  55. client.element('css selector', '#dialog_btn', function (result) {
  56. if (result.status != -1) {
  57. //Dialog has popped up, so check the text and click the button
  58. client.assert.containsText("#div_dialog_0", "File not found");
  59. client.click("#dialog_btn");
  60. client.verify.ok(true, "Toolbar: " + filename + " failed to load!"); //don't stop testing
  61. }
  62. });
  63. },
  64. 'Load Missing Model': function (client) {
  65. let filename = './test/missing.model';
  66. client.execute(
  67. function () {
  68. DataUtils.loadm('./test/missing.model');
  69. }, [], null
  70. );
  71. client.waitForElementPresent("#dialog_btn", 2000, "Check for model loading error: " + filename);
  72. client.element('css selector', '#dialog_btn', function (result) {
  73. if (result.status != -1) {
  74. //Dialog has popped up, so check the text and click the button
  75. client.assert.containsText("#div_dialog_0", "File cannot be read");
  76. client.click("#dialog_btn");
  77. client.verify.ok(true, "Model: " + filename + " failed to load!"); //don't stop testing
  78. }
  79. });
  80. },
  81. 'Delete and Click Toolbar': function (client) {
  82. client.pause(500);
  83. deleteFolderRecursive("./users/userremove");
  84. client.pause(1000);
  85. let load_button = "#\\2f Toolbars\\2f MainMenu\\2f MainMenu\\2e buttons\\2e model\\2f loadModel";
  86. client.waitForElementPresent(load_button, 1000, "Looking for load button")
  87. .click(load_button)
  88. .waitForElementPresent("#dialog_btn", 1000, "Load menu opens");
  89. client.waitForElementPresent("#dialog_btn", 2000, "Check for file list loading error");
  90. client.element('css selector', '#dialog_btn', function (result) {
  91. if (result.status != -1) {
  92. //Dialog has popped up, so check the text and click the button
  93. client.assert.containsText("#div_dialog_0", "Cannot load file list");
  94. client.click("#dialog_btn");
  95. client.verify.ok(true, "File list failed to load!"); //don't stop testing
  96. }
  97. });
  98. },
  99. after: function (client) {
  100. client.end();
  101. },
  102. };