@silasfmartins/testhub 1.0.0

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.
Files changed (296) hide show
  1. package/.github/copilot-instructions.md +520 -0
  2. package/biome.json +37 -0
  3. package/dist/index.d.ts +45 -0
  4. package/dist/index.js +169 -0
  5. package/dist/scripts/consumer-postinstall.d.ts +15 -0
  6. package/dist/scripts/consumer-postinstall.js +785 -0
  7. package/dist/scripts/generate-docs.d.ts +16 -0
  8. package/dist/scripts/generate-docs.js +1363 -0
  9. package/dist/scripts/generate-index.d.ts +2 -0
  10. package/dist/scripts/generate-index.js +314 -0
  11. package/dist/scripts/init-api.d.ts +2 -0
  12. package/dist/scripts/init-api.js +525 -0
  13. package/dist/scripts/init-banco.d.ts +2 -0
  14. package/dist/scripts/init-banco.js +347 -0
  15. package/dist/scripts/init-frontend.d.ts +2 -0
  16. package/dist/scripts/init-frontend.js +627 -0
  17. package/dist/scripts/init-mobile.d.ts +2 -0
  18. package/dist/scripts/init-mobile.js +481 -0
  19. package/dist/scripts/init-scenarios.d.ts +2 -0
  20. package/dist/scripts/init-scenarios.js +846 -0
  21. package/dist/scripts/init-ssh.d.ts +2 -0
  22. package/dist/scripts/init-ssh.js +639 -0
  23. package/dist/scripts/package-versions.d.ts +57 -0
  24. package/dist/scripts/package-versions.js +768 -0
  25. package/dist/scripts/postinstall.d.ts +1 -0
  26. package/dist/scripts/postinstall.js +527 -0
  27. package/dist/scripts/robust-build.d.ts +7 -0
  28. package/dist/scripts/robust-build.js +88 -0
  29. package/dist/scripts/setup-local-packages.d.ts +31 -0
  30. package/dist/scripts/setup-local-packages.js +237 -0
  31. package/dist/scripts/smart-override.d.ts +2 -0
  32. package/dist/scripts/smart-override.js +1360 -0
  33. package/dist/scripts/sync-configs.d.ts +27 -0
  34. package/dist/scripts/sync-configs.js +248 -0
  35. package/dist/scripts/test-biome-parse.d.ts +5 -0
  36. package/dist/scripts/test-biome-parse.js +84 -0
  37. package/dist/scripts/ultracite-setup.d.ts +4 -0
  38. package/dist/scripts/ultracite-setup.js +310 -0
  39. package/dist/scripts/update-all-init-scripts.d.ts +2 -0
  40. package/dist/scripts/update-all-init-scripts.js +52 -0
  41. package/dist/scripts/update-biome-schema.d.ts +15 -0
  42. package/dist/scripts/update-biome-schema.js +124 -0
  43. package/dist/src/AutoCoreFacade.d.ts +145 -0
  44. package/dist/src/AutoCoreFacade.js +217 -0
  45. package/dist/src/api/ApiActions.d.ts +297 -0
  46. package/dist/src/api/ApiActions.js +1905 -0
  47. package/dist/src/api/Certificate.d.ts +60 -0
  48. package/dist/src/api/Certificate.js +79 -0
  49. package/dist/src/api/JsonResponse.d.ts +116 -0
  50. package/dist/src/api/JsonResponse.js +206 -0
  51. package/dist/src/appium/DeviceFarmViewer.d.ts +79 -0
  52. package/dist/src/appium/DeviceFarmViewer.js +1083 -0
  53. package/dist/src/appium/MobileActions.d.ts +347 -0
  54. package/dist/src/appium/MobileActions.js +1632 -0
  55. package/dist/src/appium/MobileConnection.d.ts +160 -0
  56. package/dist/src/appium/MobileConnection.js +772 -0
  57. package/dist/src/config/envLoader.d.ts +123 -0
  58. package/dist/src/config/envLoader.js +361 -0
  59. package/dist/src/config/jest-safe-setup.d.ts +19 -0
  60. package/dist/src/config/jest-safe-setup.js +369 -0
  61. package/dist/src/config/timeouts.d.ts +32 -0
  62. package/dist/src/config/timeouts.js +38 -0
  63. package/dist/src/desktop/DesktopActions.d.ts +46 -0
  64. package/dist/src/desktop/DesktopActions.js +398 -0
  65. package/dist/src/desktop/DesktopConnection.d.ts +32 -0
  66. package/dist/src/desktop/DesktopConnection.js +84 -0
  67. package/dist/src/domain/entities/TestExecution.d.ts +117 -0
  68. package/dist/src/domain/entities/TestExecution.js +150 -0
  69. package/dist/src/domain/entities/TestReport.d.ts +114 -0
  70. package/dist/src/domain/entities/TestReport.js +179 -0
  71. package/dist/src/domain/repositories/ITestRepository.d.ts +196 -0
  72. package/dist/src/domain/repositories/ITestRepository.js +14 -0
  73. package/dist/src/domain/schemas/ValidationSchemas.d.ts +159 -0
  74. package/dist/src/domain/schemas/ValidationSchemas.js +181 -0
  75. package/dist/src/functions/errors/BaseError.d.ts +78 -0
  76. package/dist/src/functions/errors/BaseError.js +245 -0
  77. package/dist/src/functions/errors/ConfigurationError.d.ts +16 -0
  78. package/dist/src/functions/errors/ConfigurationError.js +48 -0
  79. package/dist/src/functions/errors/ErrorCatalog.d.ts +148 -0
  80. package/dist/src/functions/errors/ErrorCatalog.js +157 -0
  81. package/dist/src/functions/errors/GlobalErrorHandler.d.ts +101 -0
  82. package/dist/src/functions/errors/GlobalErrorHandler.js +281 -0
  83. package/dist/src/functions/errors/IntegrationError.d.ts +17 -0
  84. package/dist/src/functions/errors/IntegrationError.js +51 -0
  85. package/dist/src/functions/errors/SecurityError.d.ts +14 -0
  86. package/dist/src/functions/errors/SecurityError.js +42 -0
  87. package/dist/src/functions/errors/SystemError.d.ts +12 -0
  88. package/dist/src/functions/errors/SystemError.js +36 -0
  89. package/dist/src/functions/errors/ValidationError.d.ts +14 -0
  90. package/dist/src/functions/errors/ValidationError.js +61 -0
  91. package/dist/src/functions/errors/index.d.ts +12 -0
  92. package/dist/src/functions/errors/index.js +13 -0
  93. package/dist/src/global-setup.d.ts +1 -0
  94. package/dist/src/global-setup.js +1037 -0
  95. package/dist/src/helpers/BancoActions.d.ts +188 -0
  96. package/dist/src/helpers/BancoActions.js +581 -0
  97. package/dist/src/helpers/EnviromentHelper.d.ts +17 -0
  98. package/dist/src/helpers/EnviromentHelper.js +66 -0
  99. package/dist/src/helpers/ParallelExecutionHelper.d.ts +183 -0
  100. package/dist/src/helpers/ParallelExecutionHelper.js +375 -0
  101. package/dist/src/helpers/SyncSignal.d.ts +15 -0
  102. package/dist/src/helpers/SyncSignal.js +44 -0
  103. package/dist/src/hubdocs/CategoryDetector.d.ts +83 -0
  104. package/dist/src/hubdocs/CategoryDetector.js +401 -0
  105. package/dist/src/hubdocs/DirectStatementInterceptor.d.ts +54 -0
  106. package/dist/src/hubdocs/DirectStatementInterceptor.js +243 -0
  107. package/dist/src/hubdocs/ExecutionTracker.d.ts +107 -0
  108. package/dist/src/hubdocs/ExecutionTracker.js +702 -0
  109. package/dist/src/hubdocs/HubDocs.d.ts +395 -0
  110. package/dist/src/hubdocs/HubDocs.js +3586 -0
  111. package/dist/src/hubdocs/StatementMethodFilter.d.ts +71 -0
  112. package/dist/src/hubdocs/StatementMethodFilter.js +618 -0
  113. package/dist/src/hubdocs/StatementTracker.d.ts +417 -0
  114. package/dist/src/hubdocs/StatementTracker.js +2419 -0
  115. package/dist/src/hubdocs/SwaggerGenerator.d.ts +59 -0
  116. package/dist/src/hubdocs/SwaggerGenerator.js +405 -0
  117. package/dist/src/hubdocs/index.d.ts +9 -0
  118. package/dist/src/hubdocs/index.js +9 -0
  119. package/dist/src/hubdocs/types.d.ts +114 -0
  120. package/dist/src/hubdocs/types.js +5 -0
  121. package/dist/src/infrastructure/DependencyContainer.d.ts +142 -0
  122. package/dist/src/infrastructure/DependencyContainer.js +250 -0
  123. package/dist/src/infrastructure/adapters/AppiumAdapter.d.ts +168 -0
  124. package/dist/src/infrastructure/adapters/AppiumAdapter.js +468 -0
  125. package/dist/src/infrastructure/adapters/OracleAdapter.d.ts +150 -0
  126. package/dist/src/infrastructure/adapters/OracleAdapter.js +388 -0
  127. package/dist/src/infrastructure/adapters/PlaywrightAdapter.d.ts +192 -0
  128. package/dist/src/infrastructure/adapters/PlaywrightAdapter.js +382 -0
  129. package/dist/src/infrastructure/adapters/SSHAdapter.d.ts +141 -0
  130. package/dist/src/infrastructure/adapters/SSHAdapter.js +428 -0
  131. package/dist/src/interfaces.d.ts +501 -0
  132. package/dist/src/interfaces.js +25 -0
  133. package/dist/src/internal/fakes/__fake-actions__.d.ts +17 -0
  134. package/dist/src/internal/fakes/__fake-actions__.js +21 -0
  135. package/dist/src/internal/fakes/__forbidden__.d.ts +10 -0
  136. package/dist/src/internal/fakes/__forbidden__.js +18 -0
  137. package/dist/src/internal/fakes/__honeypot__.d.ts +15 -0
  138. package/dist/src/internal/fakes/__honeypot__.js +24 -0
  139. package/dist/src/octane/OctaneReporter.d.ts +13 -0
  140. package/dist/src/octane/OctaneReporter.js +61 -0
  141. package/dist/src/playwright/CryptoActions.d.ts +20 -0
  142. package/dist/src/playwright/CryptoActions.js +75 -0
  143. package/dist/src/playwright/EnhancedWebActions.d.ts +7 -0
  144. package/dist/src/playwright/EnhancedWebActions.js +65 -0
  145. package/dist/src/playwright/WebActions.d.ts +1599 -0
  146. package/dist/src/playwright/WebActions.js +11788 -0
  147. package/dist/src/playwright/actions/ActionTimeline.d.ts +36 -0
  148. package/dist/src/playwright/actions/ActionTimeline.js +101 -0
  149. package/dist/src/playwright/actions/RecoveryQueue.d.ts +82 -0
  150. package/dist/src/playwright/actions/RecoveryQueue.js +130 -0
  151. package/dist/src/playwright/actions/SelectorCache.d.ts +53 -0
  152. package/dist/src/playwright/actions/SelectorCache.js +96 -0
  153. package/dist/src/playwright/actions/index.d.ts +13 -0
  154. package/dist/src/playwright/actions/index.js +14 -0
  155. package/dist/src/playwright/actions/types.d.ts +147 -0
  156. package/dist/src/playwright/actions/types.js +5 -0
  157. package/dist/src/playwright/fixtures.d.ts +112 -0
  158. package/dist/src/playwright/fixtures.js +718 -0
  159. package/dist/src/playwright/network-logs-reporter.d.ts +7 -0
  160. package/dist/src/playwright/network-logs-reporter.js +66 -0
  161. package/dist/src/playwright/registerRecoveryWrappers.d.ts +1 -0
  162. package/dist/src/playwright/registerRecoveryWrappers.js +54 -0
  163. package/dist/src/security/BuildSecurity.d.ts +12 -0
  164. package/dist/src/security/BuildSecurity.js +138 -0
  165. package/dist/src/security/EulaProtection.d.ts +70 -0
  166. package/dist/src/security/EulaProtection.js +155 -0
  167. package/dist/src/security/HoneypotManager.d.ts +46 -0
  168. package/dist/src/security/HoneypotManager.js +234 -0
  169. package/dist/src/security/KeysManager.d.ts +36 -0
  170. package/dist/src/security/KeysManager.js +158 -0
  171. package/dist/src/security/ProofOfWorkIntegration.d.ts +64 -0
  172. package/dist/src/security/ProofOfWorkIntegration.js +206 -0
  173. package/dist/src/security/SecurityValidation.d.ts +21 -0
  174. package/dist/src/security/SecurityValidation.js +163 -0
  175. package/dist/src/security/SourceMapProtection.d.ts +55 -0
  176. package/dist/src/security/SourceMapProtection.js +220 -0
  177. package/dist/src/security/protector.d.ts +1 -0
  178. package/dist/src/security/protector.js +97 -0
  179. package/dist/src/ssh/SSHActions.d.ts +262 -0
  180. package/dist/src/ssh/SSHActions.js +790 -0
  181. package/dist/src/ssh/SSHClient.d.ts +99 -0
  182. package/dist/src/ssh/SSHClient.js +409 -0
  183. package/dist/src/statements/BaseStatement.d.ts +38 -0
  184. package/dist/src/statements/BaseStatement.js +78 -0
  185. package/dist/src/testContext/AuthStateManager.d.ts +93 -0
  186. package/dist/src/testContext/AuthStateManager.js +256 -0
  187. package/dist/src/testContext/CoverageManager.d.ts +198 -0
  188. package/dist/src/testContext/CoverageManager.js +917 -0
  189. package/dist/src/testContext/TestAnnotations.d.ts +476 -0
  190. package/dist/src/testContext/TestAnnotations.js +2647 -0
  191. package/dist/src/testContext/TestContext.d.ts +138 -0
  192. package/dist/src/testContext/TestContext.js +369 -0
  193. package/dist/src/testContext/UnifiedHtmlGenerator.d.ts +7 -0
  194. package/dist/src/testContext/UnifiedHtmlGenerator.js +264 -0
  195. package/dist/src/testContext/UnifiedReportManager.d.ts +211 -0
  196. package/dist/src/testContext/UnifiedReportManager.js +1206 -0
  197. package/dist/src/testhub/DynamicConfigManager.d.ts +121 -0
  198. package/dist/src/testhub/DynamicConfigManager.js +320 -0
  199. package/dist/src/testhub/SystemsManager.d.ts +119 -0
  200. package/dist/src/testhub/SystemsManager.js +365 -0
  201. package/dist/src/testhub/TestHubClient.d.ts +335 -0
  202. package/dist/src/testhub/TestHubClient.js +1215 -0
  203. package/dist/src/testhub/TestHubReporter.d.ts +62 -0
  204. package/dist/src/testhub/TestHubReporter.js +576 -0
  205. package/dist/src/testhub/TestHubVars.d.ts +116 -0
  206. package/dist/src/testhub/TestHubVars.js +273 -0
  207. package/dist/src/utils/ActionInterceptor.d.ts +59 -0
  208. package/dist/src/utils/ActionInterceptor.js +741 -0
  209. package/dist/src/utils/ArtifactsCompressor.d.ts +43 -0
  210. package/dist/src/utils/ArtifactsCompressor.js +181 -0
  211. package/dist/src/utils/AutoLogsFinal.d.ts +47 -0
  212. package/dist/src/utils/AutoLogsFinal.js +148 -0
  213. package/dist/src/utils/CodeGenSession.d.ts +114 -0
  214. package/dist/src/utils/CodeGenSession.js +264 -0
  215. package/dist/src/utils/ConfigLogger.d.ts +133 -0
  216. package/dist/src/utils/ConfigLogger.js +611 -0
  217. package/dist/src/utils/CustomReporter.d.ts +22 -0
  218. package/dist/src/utils/CustomReporter.js +352 -0
  219. package/dist/src/utils/DataStore.d.ts +171 -0
  220. package/dist/src/utils/DataStore.js +484 -0
  221. package/dist/src/utils/DatabaseInterceptor.d.ts +19 -0
  222. package/dist/src/utils/DatabaseInterceptor.js +295 -0
  223. package/dist/src/utils/DateHelper.d.ts +16 -0
  224. package/dist/src/utils/DateHelper.js +120 -0
  225. package/dist/src/utils/DateValidator.d.ts +4 -0
  226. package/dist/src/utils/DateValidator.js +51 -0
  227. package/dist/src/utils/DocumentGenerator.d.ts +35 -0
  228. package/dist/src/utils/DocumentGenerator.js +129 -0
  229. package/dist/src/utils/EvidenceCapture.d.ts +90 -0
  230. package/dist/src/utils/EvidenceCapture.js +600 -0
  231. package/dist/src/utils/EvidenceReportGenerator.d.ts +70 -0
  232. package/dist/src/utils/EvidenceReportGenerator.js +799 -0
  233. package/dist/src/utils/FrameManagementUtil.d.ts +42 -0
  234. package/dist/src/utils/FrameManagementUtil.js +75 -0
  235. package/dist/src/utils/GlobalStatementsInterceptor.d.ts +1 -0
  236. package/dist/src/utils/GlobalStatementsInterceptor.js +1 -0
  237. package/dist/src/utils/HTMLTemplate.d.ts +1 -0
  238. package/dist/src/utils/HTMLTemplate.js +1034 -0
  239. package/dist/src/utils/InterceptacaoMagica.d.ts +23 -0
  240. package/dist/src/utils/InterceptacaoMagica.js +365 -0
  241. package/dist/src/utils/LogSanitizer.d.ts +35 -0
  242. package/dist/src/utils/LogSanitizer.js +110 -0
  243. package/dist/src/utils/Logger.d.ts +65 -0
  244. package/dist/src/utils/Logger.js +284 -0
  245. package/dist/src/utils/McpLocalClient.d.ts +141 -0
  246. package/dist/src/utils/McpLocalClient.js +871 -0
  247. package/dist/src/utils/PDFEvidenceGenerator.d.ts +20 -0
  248. package/dist/src/utils/PDFEvidenceGenerator.js +156 -0
  249. package/dist/src/utils/SpecFileAnalyzer.d.ts +35 -0
  250. package/dist/src/utils/SpecFileAnalyzer.js +209 -0
  251. package/dist/src/utils/StatementInterceptor.d.ts +18 -0
  252. package/dist/src/utils/StatementInterceptor.js +87 -0
  253. package/dist/src/utils/StatementLogger.d.ts +33 -0
  254. package/dist/src/utils/StatementLogger.js +113 -0
  255. package/dist/src/utils/StatementsInterceptor.d.ts +1 -0
  256. package/dist/src/utils/StatementsInterceptor.js +1 -0
  257. package/dist/src/utils/TeamsFlushHook.d.ts +17 -0
  258. package/dist/src/utils/TeamsFlushHook.js +168 -0
  259. package/dist/src/utils/TerminalLogCapture.d.ts +158 -0
  260. package/dist/src/utils/TerminalLogCapture.js +531 -0
  261. package/dist/src/utils/TestMethodLogger.d.ts +70 -0
  262. package/dist/src/utils/TestMethodLogger.js +95 -0
  263. package/dist/src/utils/UnifiedTeardown.d.ts +4 -0
  264. package/dist/src/utils/UnifiedTeardown.js +400 -0
  265. package/dist/src/utils/XPathCatalog.d.ts +152 -0
  266. package/dist/src/utils/XPathCatalog.js +350 -0
  267. package/dist/src/utils/generators.d.ts +90 -0
  268. package/dist/src/utils/generators.js +167 -0
  269. package/dist/src/utils/testRecovery/ResilientPlaywright.d.ts +152 -0
  270. package/dist/src/utils/testRecovery/ResilientPlaywright.js +715 -0
  271. package/dist/src/utils/testRecovery/TestRecoveryClient.d.ts +801 -0
  272. package/dist/src/utils/testRecovery/TestRecoveryClient.js +1415 -0
  273. package/dist/src/utils/testRecovery/autoFixCode.d.ts +65 -0
  274. package/dist/src/utils/testRecovery/autoFixCode.js +32 -0
  275. package/dist/vitest.config.d.ts +2 -0
  276. package/dist/vitest.config.js +59 -0
  277. package/dist/wdio.conf.d.ts +1 -0
  278. package/dist/wdio.conf.js +420 -0
  279. package/package.json +137 -0
  280. package/protect-loader.mjs +643 -0
  281. package/scripts/consumer-postinstall.ts +975 -0
  282. package/scripts/generate-index.ts +343 -0
  283. package/scripts/init-api.ts +613 -0
  284. package/scripts/init-banco.ts +437 -0
  285. package/scripts/init-frontend.ts +727 -0
  286. package/scripts/init-mobile.ts +558 -0
  287. package/scripts/init-scenarios.ts +925 -0
  288. package/scripts/init-ssh.ts +734 -0
  289. package/scripts/package-versions.ts +978 -0
  290. package/scripts/postinstall.ts +605 -0
  291. package/scripts/smart-override.ts +1675 -0
  292. package/scripts/sync-configs.ts +302 -0
  293. package/scripts/ultracite-setup.ts +370 -0
  294. package/src/types/globals.d.ts +48 -0
  295. package/tsconfig.json +29 -0
  296. package/types/autocore-sync-signal.d.ts +10 -0
@@ -0,0 +1,398 @@
1
+ import { Logger } from '../utils/Logger.js';
2
+ import { TestContext } from '../testContext/TestContext.js';
3
+ import { UnifiedReportManager } from '../testContext/UnifiedReportManager.js';
4
+ import { EvidenceCapture } from '../utils/EvidenceCapture.js';
5
+ import DesktopConnection from './DesktopConnection.js';
6
+ import { BaseError } from '../functions/errors/index.js';
7
+ export class DesktopActions {
8
+ static ensureDriver() {
9
+ return DesktopConnection.getDriver();
10
+ }
11
+ static async executarComLog(nome, executar) {
12
+ const start = Date.now();
13
+ Logger.info(`DesktopActions: iniciando ${nome}`);
14
+ try {
15
+ const res = await executar();
16
+ const dur = Date.now() - start;
17
+ Logger.success(`DesktopActions: ${nome} concluído (${dur}ms)`);
18
+ const testInfo = TestContext.getSafeTestInfo();
19
+ if (testInfo?.title) {
20
+ UnifiedReportManager.adicionarLog(testInfo.title, `✅ ${nome} (${dur}ms)`);
21
+ }
22
+ return res;
23
+ }
24
+ catch (err) {
25
+ const dur = Date.now() - start;
26
+ Logger.error(`DesktopActions: erro em ${nome} (${dur}ms): ${String(err)}`);
27
+ const testInfo = TestContext.getSafeTestInfo();
28
+ // tentar capturar evidência
29
+ try {
30
+ const buff = await DesktopConnection.captureScreenshot(nome);
31
+ if (buff && testInfo?.title) {
32
+ await EvidenceCapture.captureAction(testInfo.title, `Desktop: ${nome}`, `❌ erro (${dur}ms)`, { error: String(err) }, buff);
33
+ }
34
+ }
35
+ catch { }
36
+ throw err;
37
+ }
38
+ }
39
+ static async runSikuliIfNeeded(element, actionName, value) {
40
+ // Se o elemento for um objeto com imagePath, chamar Sikuli
41
+ if (element && typeof element === 'object' && element.imagePath) {
42
+ const script = element.sikuliScript || element.imagePath;
43
+ return DesktopConnection.runSikuliScript(script, [actionName, JSON.stringify(value || {})]);
44
+ }
45
+ return null;
46
+ }
47
+ static async click(element, description = '', getSnapshot = false) {
48
+ return this.executarComLog('click', async () => {
49
+ const driver = this.ensureDriver();
50
+ if (driver && typeof element === 'string') {
51
+ const el = await driver.$(element);
52
+ await el.waitForDisplayed({ timeout: 30000 });
53
+ await el.click();
54
+ return;
55
+ }
56
+ const sikuli = await this.runSikuliIfNeeded(element, 'click');
57
+ if (sikuli)
58
+ return sikuli;
59
+ throw new BaseError('Elemento não encontrado para click');
60
+ });
61
+ }
62
+ static async doubleClick(element, description = '', getSnapshot = false) {
63
+ return this.executarComLog('doubleClick', async () => {
64
+ const driver = this.ensureDriver();
65
+ if (driver && typeof element === 'string') {
66
+ const el = await driver.$(element);
67
+ await el.waitForDisplayed({ timeout: 30000 });
68
+ await el.doubleClick();
69
+ return;
70
+ }
71
+ const sik = await this.runSikuliIfNeeded(element, 'doubleClick');
72
+ if (sik)
73
+ return sik;
74
+ throw new BaseError('Elemento não encontrado para doubleClick');
75
+ });
76
+ }
77
+ static async setText(element, text, description = '', getSnapshot = false) {
78
+ return this.executarComLog('setText', async () => {
79
+ const driver = this.ensureDriver();
80
+ if (driver && typeof element === 'string') {
81
+ const el = await driver.$(element);
82
+ await el.waitForDisplayed({ timeout: 30000 });
83
+ await el.clearValue();
84
+ await el.setValue(text);
85
+ return;
86
+ }
87
+ const sik = await this.runSikuliIfNeeded(element, 'setText', text);
88
+ if (sik)
89
+ return sik;
90
+ throw new BaseError('Elemento não encontrado para setText');
91
+ });
92
+ }
93
+ static async selectInTableActiveRow(element, rowActivate, description = '', getSnapshot = false) {
94
+ return this.executarComLog('selectInTableActiveRow', async () => {
95
+ const driver = this.ensureDriver();
96
+ if (driver && typeof element === 'string') {
97
+ const table = await driver.$(element);
98
+ await table.waitForDisplayed({ timeout: 30000 });
99
+ const row = await table.$(`tr:nth-child(${rowActivate})`);
100
+ await row.click();
101
+ return;
102
+ }
103
+ throw new BaseError('selectInTableActiveRow não suportado para esse elemento');
104
+ });
105
+ }
106
+ static async clickOptionInTable(element, item, description = '', getSnapshot = false) {
107
+ return this.executarComLog('clickOptionInTable', async () => {
108
+ const driver = this.ensureDriver();
109
+ if (driver && typeof element === 'string') {
110
+ const table = await driver.$(element);
111
+ await table.waitForDisplayed({ timeout: 30000 });
112
+ const cell = await table.$(`//*[contains(., "${item}")]`);
113
+ await cell.click();
114
+ return;
115
+ }
116
+ throw new BaseError('clickOptionInTable não suportado para esse elemento');
117
+ });
118
+ }
119
+ static async clickOptionInTableRowAndHeader(element, row, header, description = '', getSnapshot = false) {
120
+ return this.executarComLog('clickOptionInTableRowAndHeader', async () => {
121
+ const driver = this.ensureDriver();
122
+ if (driver && typeof element === 'string') {
123
+ const table = await driver.$(element);
124
+ await table.waitForDisplayed({ timeout: 30000 });
125
+ const headers = await table.$$('th');
126
+ let idx = -1;
127
+ for (let i = 0; i < (await headers.length); i++) {
128
+ const txt = await headers[i].getText();
129
+ if (txt.trim() === header) {
130
+ idx = i + 1;
131
+ break;
132
+ }
133
+ }
134
+ if (idx === -1)
135
+ throw new BaseError('Cabeçalho não encontrado');
136
+ const cell = await table.$(`tr:nth-child(${row}) td:nth-child(${idx})`);
137
+ await cell.click();
138
+ return;
139
+ }
140
+ throw new BaseError('clickOptionInTableRowAndHeader não suportado para esse elemento');
141
+ });
142
+ }
143
+ static async doubleClickOptionInTable(element, item, description = '', getSnapshot = false) {
144
+ return this.executarComLog('doubleClickOptionInTable', async () => {
145
+ const driver = this.ensureDriver();
146
+ if (driver && typeof element === 'string') {
147
+ const table = await driver.$(element);
148
+ await table.waitForDisplayed({ timeout: 30000 });
149
+ const cell = await table.$(`//*[contains(., "${item}")]`);
150
+ await cell.doubleClick();
151
+ return;
152
+ }
153
+ throw new BaseError('doubleClickOptionInTable não suportado para esse elemento');
154
+ });
155
+ }
156
+ static async selectRowInTable(element, row, description = '', getSnapshot = false) {
157
+ return this.executarComLog('selectRowInTable', async () => {
158
+ return this.selectInTableActiveRow(element, row, description, getSnapshot);
159
+ });
160
+ }
161
+ static async selectRowOptionInTable(element, itens, description = '', getSnapshot = false) {
162
+ return this.executarComLog('selectRowOptionInTable', async () => {
163
+ const driver = this.ensureDriver();
164
+ if (driver && typeof element === 'string') {
165
+ const table = await driver.$(element);
166
+ await table.waitForDisplayed({ timeout: 30000 });
167
+ const rows = await table.$$('tr');
168
+ for (const r of rows) {
169
+ const txt = await r.getText();
170
+ const hasAll = itens.every(it => txt.includes(it));
171
+ if (hasAll) {
172
+ await r.click();
173
+ return;
174
+ }
175
+ }
176
+ throw new BaseError('Linha não encontrada com todos os itens');
177
+ }
178
+ throw new BaseError('selectRowOptionInTable não suportado para esse elemento');
179
+ });
180
+ }
181
+ static async selectInTreeView(element, pathStr, description = '', getSnapshot = false) {
182
+ return this.executarComLog('selectInTreeView', async () => {
183
+ const driver = this.ensureDriver();
184
+ if (driver && typeof element === 'string') {
185
+ const parts = pathStr.split('/');
186
+ let context = await driver.$(element);
187
+ for (const p of parts) {
188
+ const node = await context.$(`//*[text()="${p}"]`);
189
+ await node.click();
190
+ context = node;
191
+ }
192
+ return;
193
+ }
194
+ throw new BaseError('selectInTreeView não suportado para esse elemento');
195
+ });
196
+ }
197
+ static async selectInTabControl(element, item, description = '', getSnapshot = false) {
198
+ return this.executarComLog('selectInTabControl', async () => {
199
+ const driver = this.ensureDriver();
200
+ if (driver && typeof element === 'string') {
201
+ const tab = await driver.$(element);
202
+ await tab.waitForDisplayed({ timeout: 30000 });
203
+ const target = await tab.$(`//*[text()="${item}"]`);
204
+ await target.click();
205
+ return;
206
+ }
207
+ throw new BaseError('selectInTabControl não suportado para esse elemento');
208
+ });
209
+ }
210
+ static async setValueTable(element, value, row, column, description = '', getSnapshot = false) {
211
+ return this.executarComLog('setValueTable', async () => {
212
+ const driver = this.ensureDriver();
213
+ if (driver && typeof element === 'string') {
214
+ const table = await driver.$(element);
215
+ await table.waitForDisplayed({ timeout: 30000 });
216
+ const headers = await table.$$('th');
217
+ let idx = -1;
218
+ for (let i = 0; i < (await headers.length); i++) {
219
+ const txt = await headers[i].getText();
220
+ if (txt.trim() === column) {
221
+ idx = i + 1;
222
+ break;
223
+ }
224
+ }
225
+ if (idx === -1)
226
+ throw new BaseError('Coluna não encontrada');
227
+ const cell = await table.$(`tr:nth-child(${row}) td:nth-child(${idx})`);
228
+ const input = await cell.$('input');
229
+ await input.setValue(value);
230
+ return;
231
+ }
232
+ throw new BaseError('setValueTable não suportado para esse elemento');
233
+ });
234
+ }
235
+ static async setStateCheckBox(element, checked, description = '', getSnapshot = false) {
236
+ return this.executarComLog('setStateCheckBox', async () => {
237
+ const driver = this.ensureDriver();
238
+ if (driver && typeof element === 'string') {
239
+ const cb = await driver.$(element);
240
+ await cb.waitForDisplayed({ timeout: 30000 });
241
+ const isChecked = await cb.isSelected();
242
+ if (isChecked !== checked) {
243
+ await cb.click();
244
+ }
245
+ return;
246
+ }
247
+ throw new BaseError('setStateCheckBox não suportado para esse elemento');
248
+ });
249
+ }
250
+ static async implicitWait(element, timeOrDesc, descriptionOrGet, getSnapshot) {
251
+ return this.executarComLog('implicitWait', async () => {
252
+ const driver = this.ensureDriver();
253
+ let time = 120;
254
+ if (typeof timeOrDesc === 'number')
255
+ time = timeOrDesc;
256
+ if (driver && typeof element === 'string') {
257
+ await driver.$(element).waitForExist({ timeout: time * 1000 });
258
+ return;
259
+ }
260
+ throw new BaseError('implicitWait não suportado para esse elemento');
261
+ });
262
+ }
263
+ static async selectInList(element, text, description = '', getSnapshot = false) {
264
+ return this.executarComLog('selectInList', async () => {
265
+ const driver = this.ensureDriver();
266
+ if (driver && typeof element === 'string') {
267
+ const list = await driver.$(element);
268
+ await list.waitForDisplayed({ timeout: 30000 });
269
+ const item = await list.$(`//*[text()="${text}"]`);
270
+ await item.click();
271
+ return;
272
+ }
273
+ throw new BaseError('selectInList não suportado para esse elemento');
274
+ });
275
+ }
276
+ static async validateObject(element, arg1, arg2, arg3) {
277
+ // Suporta várias assinaturas
278
+ return this.executarComLog('validateObject', async () => {
279
+ const driver = this.ensureDriver();
280
+ let timeout = 0;
281
+ let expected = true;
282
+ if (typeof arg1 === 'number') {
283
+ timeout = arg1;
284
+ }
285
+ else if (typeof arg1 === 'boolean') {
286
+ expected = arg1;
287
+ }
288
+ if (typeof arg2 === 'number')
289
+ timeout = arg2;
290
+ if (driver && typeof element === 'string') {
291
+ if (timeout > 0) {
292
+ try {
293
+ await driver.$(element).waitForDisplayed({ timeout: timeout * 1000 });
294
+ return expected;
295
+ }
296
+ catch {
297
+ return !expected;
298
+ }
299
+ }
300
+ try {
301
+ const exists = await driver.$(element).isExisting();
302
+ return exists === expected;
303
+ }
304
+ catch {
305
+ return !expected;
306
+ }
307
+ }
308
+ throw new BaseError('validateObject não suportado para esse elemento');
309
+ });
310
+ }
311
+ static async setTextTable(element, row, columnHeader, value, description = '', getSnapshot = false) {
312
+ return this.setValueTable(element, value, row, columnHeader, description, getSnapshot);
313
+ }
314
+ static async getText(element, description = '', getSnapshot = false) {
315
+ return this.executarComLog('getText', async () => {
316
+ const driver = this.ensureDriver();
317
+ if (driver && typeof element === 'string') {
318
+ const el = await driver.$(element);
319
+ await el.waitForDisplayed({ timeout: 30000 });
320
+ return el.getText();
321
+ }
322
+ throw new BaseError('getText não suportado para esse elemento');
323
+ });
324
+ }
325
+ static async getTextEditor(element, description = '', getSnapshot = false) {
326
+ return this.getText(element, description, getSnapshot);
327
+ }
328
+ static async getAttachedText(element, description = '', getSnapshot = false) {
329
+ return this.getText(element, description, getSnapshot);
330
+ }
331
+ static async getLabel(element, description = '', getSnapshot = false) {
332
+ return this.getText(element, description, getSnapshot);
333
+ }
334
+ static async selectOptionMenu(element, description = '', getSnapshot = false) {
335
+ return this.click(element, description, getSnapshot);
336
+ }
337
+ static async selectOptionSubMenu(element, path, description = '', getSnapshot = false) {
338
+ return this.selectInTreeView(element, path, description, getSnapshot);
339
+ }
340
+ static async closeWindow(element, description = '') {
341
+ return this.executarComLog('closeWindow', async () => {
342
+ const driver = this.ensureDriver();
343
+ if (driver) {
344
+ await driver.closeWindow();
345
+ return;
346
+ }
347
+ throw new BaseError('closeWindow requires driver');
348
+ });
349
+ }
350
+ static async maximizeWindow(description = '', getSnapshot = false) {
351
+ return this.executarComLog('maximizeWindow', async () => {
352
+ const driver = this.ensureDriver();
353
+ if (driver) {
354
+ await driver.maximizeWindow();
355
+ return;
356
+ }
357
+ throw new BaseError('maximizeWindow requires driver');
358
+ });
359
+ }
360
+ static async pressKey(key, description = '') {
361
+ return this.executarComLog('pressKey', async () => {
362
+ const driver = this.ensureDriver();
363
+ if (driver) {
364
+ await driver.pressKeyCode?.(key) || await driver.keys?.([String.fromCharCode(key)]);
365
+ return;
366
+ }
367
+ throw new BaseError('pressKey requires driver');
368
+ });
369
+ }
370
+ static async releaseKey(key, description = '') {
371
+ return this.executarComLog('releaseKey', async () => {
372
+ // WebDriverIO usually doesn't have releaseKey; simulate with keyUp if available
373
+ const driver = this.ensureDriver();
374
+ if (driver) {
375
+ await driver.releaseActions?.() || undefined;
376
+ return;
377
+ }
378
+ throw new BaseError('releaseKey requires driver');
379
+ });
380
+ }
381
+ static async waitForElementJavaToDisappear(object, time = 60) {
382
+ return this.executarComLog('waitForElementJavaToDisappear', async () => {
383
+ const driver = this.ensureDriver();
384
+ if (driver && typeof object === 'string') {
385
+ try {
386
+ await driver.$(object).waitForExist({ timeout: time * 1000, reverse: true });
387
+ return true;
388
+ }
389
+ catch {
390
+ return false;
391
+ }
392
+ }
393
+ // Se não houver driver, não é possível verificar
394
+ return false;
395
+ });
396
+ }
397
+ }
398
+ export default DesktopActions;
@@ -0,0 +1,32 @@
1
+ import { ChildProcess } from 'node:child_process';
2
+ /**
3
+ * Gerencia conexão com o driver desktop (WebDriverIO) e execução do SikuliX
4
+ */
5
+ export declare class DesktopConnection {
6
+ private static driver;
7
+ private static appProcess;
8
+ static setDriver(driver: WebdriverIO.Browser): void;
9
+ static getDriver(): WebdriverIO.Browser | null;
10
+ /**
11
+ * Executa um script SikuliX externo. O comando `sikulix` ou `runsikulix` deve
12
+ * estar disponível no PATH ou passe full path via env SIKULIX_CMD.
13
+ */
14
+ static runSikuliScript(scriptPath: string, args?: string[]): Promise<{
15
+ stdout: string;
16
+ stderr: string;
17
+ }>;
18
+ /**
19
+ * Inicia a aplicação desktop informada pelo caminho `appPath`.
20
+ * Retorna o objeto ChildProcess iniciado.
21
+ */
22
+ static startApp(appPath: string, args?: string[]): Promise<ChildProcess>;
23
+ /**
24
+ * Fecha a aplicação iniciada por `startApp`, se existir.
25
+ */
26
+ static closeApp(): Promise<void>;
27
+ /**
28
+ * Captura screenshot do driver WebDriverIO
29
+ */
30
+ static captureScreenshot(name?: string): Promise<Buffer | null>;
31
+ }
32
+ export default DesktopConnection;
@@ -0,0 +1,84 @@
1
+ import { execFile, spawn } from 'node:child_process';
2
+ /**
3
+ * Gerencia conexão com o driver desktop (WebDriverIO) e execução do SikuliX
4
+ */
5
+ export class DesktopConnection {
6
+ static driver = null;
7
+ static appProcess = null;
8
+ static setDriver(driver) {
9
+ this.driver = driver;
10
+ }
11
+ static getDriver() {
12
+ return this.driver;
13
+ }
14
+ /**
15
+ * Executa um script SikuliX externo. O comando `sikulix` ou `runsikulix` deve
16
+ * estar disponível no PATH ou passe full path via env SIKULIX_CMD.
17
+ */
18
+ static async runSikuliScript(scriptPath, args = []) {
19
+ return new Promise((resolve, reject) => {
20
+ const cmd = process.env.SIKULIX_CMD || 'runsikulix';
21
+ const params = ['-r', scriptPath, ...args];
22
+ execFile(cmd, params, { cwd: process.cwd(), env: process.env }, (err, stdout, stderr) => {
23
+ if (err)
24
+ return reject({ err, stdout, stderr });
25
+ resolve({ stdout: String(stdout), stderr: String(stderr) });
26
+ });
27
+ });
28
+ }
29
+ /**
30
+ * Inicia a aplicação desktop informada pelo caminho `appPath`.
31
+ * Retorna o objeto ChildProcess iniciado.
32
+ */
33
+ static async startApp(appPath, args = []) {
34
+ if (!appPath)
35
+ throw new Error('appPath é obrigatório para startApp');
36
+ // Se já existe processo, retorna
37
+ if (this.appProcess && !this.appProcess.killed)
38
+ return this.appProcess;
39
+ const child = spawn(appPath, args, {
40
+ cwd: process.cwd(),
41
+ env: process.env,
42
+ detached: false,
43
+ stdio: 'ignore',
44
+ });
45
+ this.appProcess = child;
46
+ // Registrar listeners para limpar referência quando encerrar
47
+ child.on('exit', () => {
48
+ this.appProcess = null;
49
+ });
50
+ return child;
51
+ }
52
+ /**
53
+ * Fecha a aplicação iniciada por `startApp`, se existir.
54
+ */
55
+ static async closeApp() {
56
+ try {
57
+ if (this.appProcess && !this.appProcess.killed) {
58
+ this.appProcess.kill();
59
+ this.appProcess = null;
60
+ }
61
+ }
62
+ catch (e) {
63
+ // ignorar
64
+ }
65
+ }
66
+ /**
67
+ * Captura screenshot do driver WebDriverIO
68
+ */
69
+ static async captureScreenshot(name = 'desktop') {
70
+ try {
71
+ if (!this.driver)
72
+ return null;
73
+ const base64 = await this.driver.saveScreenshot();
74
+ if (typeof base64 === 'string') {
75
+ return Buffer.from(base64, 'base64');
76
+ }
77
+ return base64;
78
+ }
79
+ catch (e) {
80
+ return null;
81
+ }
82
+ }
83
+ }
84
+ export default DesktopConnection;
@@ -0,0 +1,117 @@
1
+ /**
2
+ * @fileoverview Entidade de domínio para execução de testes
3
+ * @module Domain/Entities
4
+ */
5
+ /**
6
+ * Tipos de teste suportados pelo framework
7
+ */
8
+ export declare enum TestType {
9
+ API = "api",
10
+ WEB = "web",
11
+ MOBILE = "mobile",
12
+ SSH = "ssh",
13
+ DATABASE = "database"
14
+ }
15
+ /**
16
+ * Status de execução do teste
17
+ */
18
+ export declare enum TestStatus {
19
+ PENDING = "pending",
20
+ RUNNING = "running",
21
+ PASSED = "passed",
22
+ FAILED = "failed",
23
+ SKIPPED = "skipped"
24
+ }
25
+ /**
26
+ * Resultado de um teste executado
27
+ */
28
+ export interface TestResult {
29
+ readonly status: TestStatus;
30
+ readonly message?: string;
31
+ readonly error?: Error;
32
+ readonly duration: number;
33
+ readonly timestamp: Date;
34
+ readonly metadata?: Record<string, any>;
35
+ }
36
+ /**
37
+ * Especificação de um teste a ser executado
38
+ */
39
+ export interface TestSpecification {
40
+ readonly name: string;
41
+ readonly type: TestType;
42
+ readonly description?: string;
43
+ readonly timeout?: number;
44
+ readonly retries?: number;
45
+ readonly tags?: string[];
46
+ readonly parameters: Record<string, any>;
47
+ }
48
+ /**
49
+ * Entidade principal para execução de testes
50
+ * Contém a lógica de negócio para gerenciar o ciclo de vida de um teste
51
+ */
52
+ export declare class TestExecution {
53
+ readonly id: string;
54
+ readonly specification: TestSpecification;
55
+ private _status;
56
+ private _startTime?;
57
+ private _endTime?;
58
+ private _result?;
59
+ private _steps;
60
+ constructor(id: string, specification: TestSpecification);
61
+ /**
62
+ * Inicia a execução do teste
63
+ */
64
+ start(): void;
65
+ /**
66
+ * Adiciona um passo de execução
67
+ */
68
+ addStep(step: TestStep): void;
69
+ /**
70
+ * Completa a execução do teste com sucesso
71
+ */
72
+ complete(message?: string, metadata?: Record<string, any>): void;
73
+ /**
74
+ * Marca o teste como falhou
75
+ */
76
+ fail(error: Error, metadata?: Record<string, any>): void;
77
+ /**
78
+ * Pula a execução do teste
79
+ */
80
+ skip(reason?: string): void;
81
+ /**
82
+ * Status atual do teste
83
+ */
84
+ get status(): TestStatus;
85
+ /**
86
+ * Resultado da execução (disponível após conclusão)
87
+ */
88
+ get result(): TestResult | undefined;
89
+ /**
90
+ * Duração da execução em milissegundos
91
+ */
92
+ get duration(): number;
93
+ /**
94
+ * Passos executados durante o teste
95
+ */
96
+ get steps(): readonly TestStep[];
97
+ /**
98
+ * Verifica se o teste está em execução
99
+ */
100
+ get isRunning(): boolean;
101
+ /**
102
+ * Verifica se o teste foi concluído (passou, falhou ou foi pulado)
103
+ */
104
+ get isCompleted(): boolean;
105
+ }
106
+ /**
107
+ * Representa um passo individual na execução de um teste
108
+ */
109
+ export interface TestStep {
110
+ readonly id: string;
111
+ readonly description: string;
112
+ readonly timestamp: Date;
113
+ readonly duration?: number;
114
+ readonly status: TestStatus;
115
+ readonly data?: any;
116
+ readonly error?: Error;
117
+ }