@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.
- package/.github/copilot-instructions.md +520 -0
- package/biome.json +37 -0
- package/dist/index.d.ts +45 -0
- package/dist/index.js +169 -0
- package/dist/scripts/consumer-postinstall.d.ts +15 -0
- package/dist/scripts/consumer-postinstall.js +785 -0
- package/dist/scripts/generate-docs.d.ts +16 -0
- package/dist/scripts/generate-docs.js +1363 -0
- package/dist/scripts/generate-index.d.ts +2 -0
- package/dist/scripts/generate-index.js +314 -0
- package/dist/scripts/init-api.d.ts +2 -0
- package/dist/scripts/init-api.js +525 -0
- package/dist/scripts/init-banco.d.ts +2 -0
- package/dist/scripts/init-banco.js +347 -0
- package/dist/scripts/init-frontend.d.ts +2 -0
- package/dist/scripts/init-frontend.js +627 -0
- package/dist/scripts/init-mobile.d.ts +2 -0
- package/dist/scripts/init-mobile.js +481 -0
- package/dist/scripts/init-scenarios.d.ts +2 -0
- package/dist/scripts/init-scenarios.js +846 -0
- package/dist/scripts/init-ssh.d.ts +2 -0
- package/dist/scripts/init-ssh.js +639 -0
- package/dist/scripts/package-versions.d.ts +57 -0
- package/dist/scripts/package-versions.js +768 -0
- package/dist/scripts/postinstall.d.ts +1 -0
- package/dist/scripts/postinstall.js +527 -0
- package/dist/scripts/robust-build.d.ts +7 -0
- package/dist/scripts/robust-build.js +88 -0
- package/dist/scripts/setup-local-packages.d.ts +31 -0
- package/dist/scripts/setup-local-packages.js +237 -0
- package/dist/scripts/smart-override.d.ts +2 -0
- package/dist/scripts/smart-override.js +1360 -0
- package/dist/scripts/sync-configs.d.ts +27 -0
- package/dist/scripts/sync-configs.js +248 -0
- package/dist/scripts/test-biome-parse.d.ts +5 -0
- package/dist/scripts/test-biome-parse.js +84 -0
- package/dist/scripts/ultracite-setup.d.ts +4 -0
- package/dist/scripts/ultracite-setup.js +310 -0
- package/dist/scripts/update-all-init-scripts.d.ts +2 -0
- package/dist/scripts/update-all-init-scripts.js +52 -0
- package/dist/scripts/update-biome-schema.d.ts +15 -0
- package/dist/scripts/update-biome-schema.js +124 -0
- package/dist/src/AutoCoreFacade.d.ts +145 -0
- package/dist/src/AutoCoreFacade.js +217 -0
- package/dist/src/api/ApiActions.d.ts +297 -0
- package/dist/src/api/ApiActions.js +1905 -0
- package/dist/src/api/Certificate.d.ts +60 -0
- package/dist/src/api/Certificate.js +79 -0
- package/dist/src/api/JsonResponse.d.ts +116 -0
- package/dist/src/api/JsonResponse.js +206 -0
- package/dist/src/appium/DeviceFarmViewer.d.ts +79 -0
- package/dist/src/appium/DeviceFarmViewer.js +1083 -0
- package/dist/src/appium/MobileActions.d.ts +347 -0
- package/dist/src/appium/MobileActions.js +1632 -0
- package/dist/src/appium/MobileConnection.d.ts +160 -0
- package/dist/src/appium/MobileConnection.js +772 -0
- package/dist/src/config/envLoader.d.ts +123 -0
- package/dist/src/config/envLoader.js +361 -0
- package/dist/src/config/jest-safe-setup.d.ts +19 -0
- package/dist/src/config/jest-safe-setup.js +369 -0
- package/dist/src/config/timeouts.d.ts +32 -0
- package/dist/src/config/timeouts.js +38 -0
- package/dist/src/desktop/DesktopActions.d.ts +46 -0
- package/dist/src/desktop/DesktopActions.js +398 -0
- package/dist/src/desktop/DesktopConnection.d.ts +32 -0
- package/dist/src/desktop/DesktopConnection.js +84 -0
- package/dist/src/domain/entities/TestExecution.d.ts +117 -0
- package/dist/src/domain/entities/TestExecution.js +150 -0
- package/dist/src/domain/entities/TestReport.d.ts +114 -0
- package/dist/src/domain/entities/TestReport.js +179 -0
- package/dist/src/domain/repositories/ITestRepository.d.ts +196 -0
- package/dist/src/domain/repositories/ITestRepository.js +14 -0
- package/dist/src/domain/schemas/ValidationSchemas.d.ts +159 -0
- package/dist/src/domain/schemas/ValidationSchemas.js +181 -0
- package/dist/src/functions/errors/BaseError.d.ts +78 -0
- package/dist/src/functions/errors/BaseError.js +245 -0
- package/dist/src/functions/errors/ConfigurationError.d.ts +16 -0
- package/dist/src/functions/errors/ConfigurationError.js +48 -0
- package/dist/src/functions/errors/ErrorCatalog.d.ts +148 -0
- package/dist/src/functions/errors/ErrorCatalog.js +157 -0
- package/dist/src/functions/errors/GlobalErrorHandler.d.ts +101 -0
- package/dist/src/functions/errors/GlobalErrorHandler.js +281 -0
- package/dist/src/functions/errors/IntegrationError.d.ts +17 -0
- package/dist/src/functions/errors/IntegrationError.js +51 -0
- package/dist/src/functions/errors/SecurityError.d.ts +14 -0
- package/dist/src/functions/errors/SecurityError.js +42 -0
- package/dist/src/functions/errors/SystemError.d.ts +12 -0
- package/dist/src/functions/errors/SystemError.js +36 -0
- package/dist/src/functions/errors/ValidationError.d.ts +14 -0
- package/dist/src/functions/errors/ValidationError.js +61 -0
- package/dist/src/functions/errors/index.d.ts +12 -0
- package/dist/src/functions/errors/index.js +13 -0
- package/dist/src/global-setup.d.ts +1 -0
- package/dist/src/global-setup.js +1037 -0
- package/dist/src/helpers/BancoActions.d.ts +188 -0
- package/dist/src/helpers/BancoActions.js +581 -0
- package/dist/src/helpers/EnviromentHelper.d.ts +17 -0
- package/dist/src/helpers/EnviromentHelper.js +66 -0
- package/dist/src/helpers/ParallelExecutionHelper.d.ts +183 -0
- package/dist/src/helpers/ParallelExecutionHelper.js +375 -0
- package/dist/src/helpers/SyncSignal.d.ts +15 -0
- package/dist/src/helpers/SyncSignal.js +44 -0
- package/dist/src/hubdocs/CategoryDetector.d.ts +83 -0
- package/dist/src/hubdocs/CategoryDetector.js +401 -0
- package/dist/src/hubdocs/DirectStatementInterceptor.d.ts +54 -0
- package/dist/src/hubdocs/DirectStatementInterceptor.js +243 -0
- package/dist/src/hubdocs/ExecutionTracker.d.ts +107 -0
- package/dist/src/hubdocs/ExecutionTracker.js +702 -0
- package/dist/src/hubdocs/HubDocs.d.ts +395 -0
- package/dist/src/hubdocs/HubDocs.js +3586 -0
- package/dist/src/hubdocs/StatementMethodFilter.d.ts +71 -0
- package/dist/src/hubdocs/StatementMethodFilter.js +618 -0
- package/dist/src/hubdocs/StatementTracker.d.ts +417 -0
- package/dist/src/hubdocs/StatementTracker.js +2419 -0
- package/dist/src/hubdocs/SwaggerGenerator.d.ts +59 -0
- package/dist/src/hubdocs/SwaggerGenerator.js +405 -0
- package/dist/src/hubdocs/index.d.ts +9 -0
- package/dist/src/hubdocs/index.js +9 -0
- package/dist/src/hubdocs/types.d.ts +114 -0
- package/dist/src/hubdocs/types.js +5 -0
- package/dist/src/infrastructure/DependencyContainer.d.ts +142 -0
- package/dist/src/infrastructure/DependencyContainer.js +250 -0
- package/dist/src/infrastructure/adapters/AppiumAdapter.d.ts +168 -0
- package/dist/src/infrastructure/adapters/AppiumAdapter.js +468 -0
- package/dist/src/infrastructure/adapters/OracleAdapter.d.ts +150 -0
- package/dist/src/infrastructure/adapters/OracleAdapter.js +388 -0
- package/dist/src/infrastructure/adapters/PlaywrightAdapter.d.ts +192 -0
- package/dist/src/infrastructure/adapters/PlaywrightAdapter.js +382 -0
- package/dist/src/infrastructure/adapters/SSHAdapter.d.ts +141 -0
- package/dist/src/infrastructure/adapters/SSHAdapter.js +428 -0
- package/dist/src/interfaces.d.ts +501 -0
- package/dist/src/interfaces.js +25 -0
- package/dist/src/internal/fakes/__fake-actions__.d.ts +17 -0
- package/dist/src/internal/fakes/__fake-actions__.js +21 -0
- package/dist/src/internal/fakes/__forbidden__.d.ts +10 -0
- package/dist/src/internal/fakes/__forbidden__.js +18 -0
- package/dist/src/internal/fakes/__honeypot__.d.ts +15 -0
- package/dist/src/internal/fakes/__honeypot__.js +24 -0
- package/dist/src/octane/OctaneReporter.d.ts +13 -0
- package/dist/src/octane/OctaneReporter.js +61 -0
- package/dist/src/playwright/CryptoActions.d.ts +20 -0
- package/dist/src/playwright/CryptoActions.js +75 -0
- package/dist/src/playwright/EnhancedWebActions.d.ts +7 -0
- package/dist/src/playwright/EnhancedWebActions.js +65 -0
- package/dist/src/playwright/WebActions.d.ts +1599 -0
- package/dist/src/playwright/WebActions.js +11788 -0
- package/dist/src/playwright/actions/ActionTimeline.d.ts +36 -0
- package/dist/src/playwright/actions/ActionTimeline.js +101 -0
- package/dist/src/playwright/actions/RecoveryQueue.d.ts +82 -0
- package/dist/src/playwright/actions/RecoveryQueue.js +130 -0
- package/dist/src/playwright/actions/SelectorCache.d.ts +53 -0
- package/dist/src/playwright/actions/SelectorCache.js +96 -0
- package/dist/src/playwright/actions/index.d.ts +13 -0
- package/dist/src/playwright/actions/index.js +14 -0
- package/dist/src/playwright/actions/types.d.ts +147 -0
- package/dist/src/playwright/actions/types.js +5 -0
- package/dist/src/playwright/fixtures.d.ts +112 -0
- package/dist/src/playwright/fixtures.js +718 -0
- package/dist/src/playwright/network-logs-reporter.d.ts +7 -0
- package/dist/src/playwright/network-logs-reporter.js +66 -0
- package/dist/src/playwright/registerRecoveryWrappers.d.ts +1 -0
- package/dist/src/playwright/registerRecoveryWrappers.js +54 -0
- package/dist/src/security/BuildSecurity.d.ts +12 -0
- package/dist/src/security/BuildSecurity.js +138 -0
- package/dist/src/security/EulaProtection.d.ts +70 -0
- package/dist/src/security/EulaProtection.js +155 -0
- package/dist/src/security/HoneypotManager.d.ts +46 -0
- package/dist/src/security/HoneypotManager.js +234 -0
- package/dist/src/security/KeysManager.d.ts +36 -0
- package/dist/src/security/KeysManager.js +158 -0
- package/dist/src/security/ProofOfWorkIntegration.d.ts +64 -0
- package/dist/src/security/ProofOfWorkIntegration.js +206 -0
- package/dist/src/security/SecurityValidation.d.ts +21 -0
- package/dist/src/security/SecurityValidation.js +163 -0
- package/dist/src/security/SourceMapProtection.d.ts +55 -0
- package/dist/src/security/SourceMapProtection.js +220 -0
- package/dist/src/security/protector.d.ts +1 -0
- package/dist/src/security/protector.js +97 -0
- package/dist/src/ssh/SSHActions.d.ts +262 -0
- package/dist/src/ssh/SSHActions.js +790 -0
- package/dist/src/ssh/SSHClient.d.ts +99 -0
- package/dist/src/ssh/SSHClient.js +409 -0
- package/dist/src/statements/BaseStatement.d.ts +38 -0
- package/dist/src/statements/BaseStatement.js +78 -0
- package/dist/src/testContext/AuthStateManager.d.ts +93 -0
- package/dist/src/testContext/AuthStateManager.js +256 -0
- package/dist/src/testContext/CoverageManager.d.ts +198 -0
- package/dist/src/testContext/CoverageManager.js +917 -0
- package/dist/src/testContext/TestAnnotations.d.ts +476 -0
- package/dist/src/testContext/TestAnnotations.js +2647 -0
- package/dist/src/testContext/TestContext.d.ts +138 -0
- package/dist/src/testContext/TestContext.js +369 -0
- package/dist/src/testContext/UnifiedHtmlGenerator.d.ts +7 -0
- package/dist/src/testContext/UnifiedHtmlGenerator.js +264 -0
- package/dist/src/testContext/UnifiedReportManager.d.ts +211 -0
- package/dist/src/testContext/UnifiedReportManager.js +1206 -0
- package/dist/src/testhub/DynamicConfigManager.d.ts +121 -0
- package/dist/src/testhub/DynamicConfigManager.js +320 -0
- package/dist/src/testhub/SystemsManager.d.ts +119 -0
- package/dist/src/testhub/SystemsManager.js +365 -0
- package/dist/src/testhub/TestHubClient.d.ts +335 -0
- package/dist/src/testhub/TestHubClient.js +1215 -0
- package/dist/src/testhub/TestHubReporter.d.ts +62 -0
- package/dist/src/testhub/TestHubReporter.js +576 -0
- package/dist/src/testhub/TestHubVars.d.ts +116 -0
- package/dist/src/testhub/TestHubVars.js +273 -0
- package/dist/src/utils/ActionInterceptor.d.ts +59 -0
- package/dist/src/utils/ActionInterceptor.js +741 -0
- package/dist/src/utils/ArtifactsCompressor.d.ts +43 -0
- package/dist/src/utils/ArtifactsCompressor.js +181 -0
- package/dist/src/utils/AutoLogsFinal.d.ts +47 -0
- package/dist/src/utils/AutoLogsFinal.js +148 -0
- package/dist/src/utils/CodeGenSession.d.ts +114 -0
- package/dist/src/utils/CodeGenSession.js +264 -0
- package/dist/src/utils/ConfigLogger.d.ts +133 -0
- package/dist/src/utils/ConfigLogger.js +611 -0
- package/dist/src/utils/CustomReporter.d.ts +22 -0
- package/dist/src/utils/CustomReporter.js +352 -0
- package/dist/src/utils/DataStore.d.ts +171 -0
- package/dist/src/utils/DataStore.js +484 -0
- package/dist/src/utils/DatabaseInterceptor.d.ts +19 -0
- package/dist/src/utils/DatabaseInterceptor.js +295 -0
- package/dist/src/utils/DateHelper.d.ts +16 -0
- package/dist/src/utils/DateHelper.js +120 -0
- package/dist/src/utils/DateValidator.d.ts +4 -0
- package/dist/src/utils/DateValidator.js +51 -0
- package/dist/src/utils/DocumentGenerator.d.ts +35 -0
- package/dist/src/utils/DocumentGenerator.js +129 -0
- package/dist/src/utils/EvidenceCapture.d.ts +90 -0
- package/dist/src/utils/EvidenceCapture.js +600 -0
- package/dist/src/utils/EvidenceReportGenerator.d.ts +70 -0
- package/dist/src/utils/EvidenceReportGenerator.js +799 -0
- package/dist/src/utils/FrameManagementUtil.d.ts +42 -0
- package/dist/src/utils/FrameManagementUtil.js +75 -0
- package/dist/src/utils/GlobalStatementsInterceptor.d.ts +1 -0
- package/dist/src/utils/GlobalStatementsInterceptor.js +1 -0
- package/dist/src/utils/HTMLTemplate.d.ts +1 -0
- package/dist/src/utils/HTMLTemplate.js +1034 -0
- package/dist/src/utils/InterceptacaoMagica.d.ts +23 -0
- package/dist/src/utils/InterceptacaoMagica.js +365 -0
- package/dist/src/utils/LogSanitizer.d.ts +35 -0
- package/dist/src/utils/LogSanitizer.js +110 -0
- package/dist/src/utils/Logger.d.ts +65 -0
- package/dist/src/utils/Logger.js +284 -0
- package/dist/src/utils/McpLocalClient.d.ts +141 -0
- package/dist/src/utils/McpLocalClient.js +871 -0
- package/dist/src/utils/PDFEvidenceGenerator.d.ts +20 -0
- package/dist/src/utils/PDFEvidenceGenerator.js +156 -0
- package/dist/src/utils/SpecFileAnalyzer.d.ts +35 -0
- package/dist/src/utils/SpecFileAnalyzer.js +209 -0
- package/dist/src/utils/StatementInterceptor.d.ts +18 -0
- package/dist/src/utils/StatementInterceptor.js +87 -0
- package/dist/src/utils/StatementLogger.d.ts +33 -0
- package/dist/src/utils/StatementLogger.js +113 -0
- package/dist/src/utils/StatementsInterceptor.d.ts +1 -0
- package/dist/src/utils/StatementsInterceptor.js +1 -0
- package/dist/src/utils/TeamsFlushHook.d.ts +17 -0
- package/dist/src/utils/TeamsFlushHook.js +168 -0
- package/dist/src/utils/TerminalLogCapture.d.ts +158 -0
- package/dist/src/utils/TerminalLogCapture.js +531 -0
- package/dist/src/utils/TestMethodLogger.d.ts +70 -0
- package/dist/src/utils/TestMethodLogger.js +95 -0
- package/dist/src/utils/UnifiedTeardown.d.ts +4 -0
- package/dist/src/utils/UnifiedTeardown.js +400 -0
- package/dist/src/utils/XPathCatalog.d.ts +152 -0
- package/dist/src/utils/XPathCatalog.js +350 -0
- package/dist/src/utils/generators.d.ts +90 -0
- package/dist/src/utils/generators.js +167 -0
- package/dist/src/utils/testRecovery/ResilientPlaywright.d.ts +152 -0
- package/dist/src/utils/testRecovery/ResilientPlaywright.js +715 -0
- package/dist/src/utils/testRecovery/TestRecoveryClient.d.ts +801 -0
- package/dist/src/utils/testRecovery/TestRecoveryClient.js +1415 -0
- package/dist/src/utils/testRecovery/autoFixCode.d.ts +65 -0
- package/dist/src/utils/testRecovery/autoFixCode.js +32 -0
- package/dist/vitest.config.d.ts +2 -0
- package/dist/vitest.config.js +59 -0
- package/dist/wdio.conf.d.ts +1 -0
- package/dist/wdio.conf.js +420 -0
- package/package.json +137 -0
- package/protect-loader.mjs +643 -0
- package/scripts/consumer-postinstall.ts +975 -0
- package/scripts/generate-index.ts +343 -0
- package/scripts/init-api.ts +613 -0
- package/scripts/init-banco.ts +437 -0
- package/scripts/init-frontend.ts +727 -0
- package/scripts/init-mobile.ts +558 -0
- package/scripts/init-scenarios.ts +925 -0
- package/scripts/init-ssh.ts +734 -0
- package/scripts/package-versions.ts +978 -0
- package/scripts/postinstall.ts +605 -0
- package/scripts/smart-override.ts +1675 -0
- package/scripts/sync-configs.ts +302 -0
- package/scripts/ultracite-setup.ts +370 -0
- package/src/types/globals.d.ts +48 -0
- package/tsconfig.json +29 -0
- package/types/autocore-sync-signal.d.ts +10 -0
|
@@ -0,0 +1,525 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
// @ts-nocheck
|
|
3
|
+
import fs from 'node:fs';
|
|
4
|
+
import { execSync } from 'child_process';
|
|
5
|
+
import yaml from 'js-yaml';
|
|
6
|
+
import path from 'path';
|
|
7
|
+
import { generateBiomeConfigString, generatePackageJson, generateTsConfigForProject, generateVitestConfigString, getLatestVersions, } from './package-versions.js';
|
|
8
|
+
import { setupUltracite } from './ultracite-setup.js';
|
|
9
|
+
const root = process.cwd();
|
|
10
|
+
const catalogPath = path.join(root, 'catalog-info.yaml');
|
|
11
|
+
if (!fs.existsSync(catalogPath)) {
|
|
12
|
+
console.error('❌ Arquivo catalog-info.yaml não encontrado.');
|
|
13
|
+
process.exit(1);
|
|
14
|
+
}
|
|
15
|
+
const catalog = yaml.load(fs.readFileSync(catalogPath, 'utf-8'));
|
|
16
|
+
const projectName = catalog?.metadata?.name || 'meu-projeto';
|
|
17
|
+
const projectNameUnderscore = projectName.replace(/-/g, '_');
|
|
18
|
+
const write = (filePath, content) => {
|
|
19
|
+
const fullPath = path.join(root, filePath);
|
|
20
|
+
fs.mkdirSync(path.dirname(fullPath), { recursive: true });
|
|
21
|
+
fs.writeFileSync(fullPath, content);
|
|
22
|
+
};
|
|
23
|
+
async function main() {
|
|
24
|
+
console.log('🚀 Inicializando projeto API com versões atualizadas...');
|
|
25
|
+
console.log(`📦 Projeto: ${projectName}`);
|
|
26
|
+
console.log('');
|
|
27
|
+
// ✅ Buscar versões mais recentes
|
|
28
|
+
const versions = await getLatestVersions();
|
|
29
|
+
// ✅ Gerar package.json com versões atualizadas
|
|
30
|
+
const packageJsonContent = generatePackageJson(projectName, 'api', versions);
|
|
31
|
+
// ✅ Gerar tsconfig.json baseado no AutoCore
|
|
32
|
+
const tsconfigContent = generateTsConfigForProject('api');
|
|
33
|
+
// ✅ Gerar vitest.config.ts sincronizado com o AutoCore (corrige ReferenceError)
|
|
34
|
+
const vitestConfigContent = generateVitestConfigString('api');
|
|
35
|
+
// ✅ Gerar biome.json sincronizado com AutoCore
|
|
36
|
+
const biomeConfigContent = generateBiomeConfigString();
|
|
37
|
+
console.log('📝 Criando arquivos do projeto...');
|
|
38
|
+
// package.json com versões dinâmicas
|
|
39
|
+
write('package.json', JSON.stringify(packageJsonContent, null, 2));
|
|
40
|
+
// ✅ tsconfig.json sempre sincronizado com o AutoCore
|
|
41
|
+
write('tsconfig.json', JSON.stringify(tsconfigContent, null, 2));
|
|
42
|
+
// ✅ biome.json sincronizado automaticamente com o AutoCore
|
|
43
|
+
write('biome.json', biomeConfigContent);
|
|
44
|
+
// playwright.config.ts
|
|
45
|
+
write('playwright.config.ts', `import { defineConfig } from '@playwright/test'
|
|
46
|
+
export default defineConfig({
|
|
47
|
+
globalSetup: '@silasfmartins/testhub/setup',
|
|
48
|
+
reporter: [
|
|
49
|
+
['list'],
|
|
50
|
+
['html', { open: 'never' }],
|
|
51
|
+
['@silasfmartins/testhub/reporter'],
|
|
52
|
+
],
|
|
53
|
+
testDir: './tests',
|
|
54
|
+
testMatch: ['**/*.spec.ts', '**/*.test.ts'],
|
|
55
|
+
// Timeouts adequados para testes rápidos
|
|
56
|
+
timeout: 120_000,
|
|
57
|
+
expect: {
|
|
58
|
+
timeout: 60_000,
|
|
59
|
+
},
|
|
60
|
+
use: {
|
|
61
|
+
trace: 'on',
|
|
62
|
+
},
|
|
63
|
+
})`);
|
|
64
|
+
// .npmrc
|
|
65
|
+
write('.npmrc', `registry=https://pkgs.dev.azure.com/telefonica-vivo-brasil/_packaging/DevOps/npm/registry/`);
|
|
66
|
+
// .gitignore
|
|
67
|
+
write('.gitignore', `# Playwright
|
|
68
|
+
node_modules/
|
|
69
|
+
/test-results/
|
|
70
|
+
/playwright-report/
|
|
71
|
+
/blob-report/
|
|
72
|
+
/playwright/.cache/
|
|
73
|
+
|
|
74
|
+
# Tests e logs
|
|
75
|
+
/tests
|
|
76
|
+
/logs
|
|
77
|
+
docs
|
|
78
|
+
docs/
|
|
79
|
+
|
|
80
|
+
# Environment files
|
|
81
|
+
.env
|
|
82
|
+
.env.preprod
|
|
83
|
+
.env.esteira1
|
|
84
|
+
.env.esteira2
|
|
85
|
+
.env.prodlike
|
|
86
|
+
.env.prod
|
|
87
|
+
|
|
88
|
+
.vscode
|
|
89
|
+
.vscode/
|
|
90
|
+
|
|
91
|
+
# AutoCore específicos
|
|
92
|
+
.test-data-store.json
|
|
93
|
+
.env.lock
|
|
94
|
+
.configlogger.lock
|
|
95
|
+
|
|
96
|
+
# VS Code
|
|
97
|
+
.vscode/settings.json
|
|
98
|
+
.github/
|
|
99
|
+
.github
|
|
100
|
+
|
|
101
|
+
# Biome
|
|
102
|
+
.biome.log
|
|
103
|
+
|
|
104
|
+
# Coverage
|
|
105
|
+
coverage/
|
|
106
|
+
*.lcov
|
|
107
|
+
|
|
108
|
+
# Screenshots e videos
|
|
109
|
+
/test-results/
|
|
110
|
+
/playwright-report/`);
|
|
111
|
+
// Arquivo de environment padrão
|
|
112
|
+
write('.env', `# Arquivo que seleciona o ambiente a ser utilizado
|
|
113
|
+
ENV=PREPROD`);
|
|
114
|
+
// Arquivo de environment padrão
|
|
115
|
+
write('.env.preprod', `# Configurações de ambiente para preprod
|
|
116
|
+
# Adicione suas variáveis de ambiente aqui`);
|
|
117
|
+
// Arquivo de environment esteira1
|
|
118
|
+
write('.env.esteira1', `# Configurações de ambiente para esteira1
|
|
119
|
+
# Adicione suas variáveis de ambiente aqui`);
|
|
120
|
+
// Arquivo de environment esteira2
|
|
121
|
+
write('.env.esteira2', `# Configurações de ambiente para esteira2
|
|
122
|
+
# Adicione suas variáveis de ambiente aqui`);
|
|
123
|
+
// ✅ Estrutura de testes
|
|
124
|
+
console.log('📝 Criando estrutura de testes...');
|
|
125
|
+
// tests/example.spec.ts - Teste E2E com Playwright
|
|
126
|
+
write('tests/example.spec.ts', `import { type TestInfo, test, TestAnnotations, ApiActions } from '@silasfmartins/testhub'
|
|
127
|
+
|
|
128
|
+
test.describe('API Tests - ${projectName}', () => {
|
|
129
|
+
TestAnnotations.stopOnFailure() // opcional: para o runner ao falhar um CT
|
|
130
|
+
|
|
131
|
+
test('CT001 - Exemplo de requisição API', async ({ }, testInfo: TestInfo) => {
|
|
132
|
+
TestAnnotations.Api.testInfo = testInfo
|
|
133
|
+
await TestAnnotations.setSystem('MEU_SISTEMA')
|
|
134
|
+
|
|
135
|
+
// Exemplo de requisição - substitua pelo seu statement
|
|
136
|
+
// await new StatementsToken().getToken()
|
|
137
|
+
|
|
138
|
+
// Exemplo de chamada API direta
|
|
139
|
+
await ApiActions.executeGet(
|
|
140
|
+
'Buscar dados do endpoint',
|
|
141
|
+
'/api/endpoint'
|
|
142
|
+
)
|
|
143
|
+
})
|
|
144
|
+
})
|
|
145
|
+
`);
|
|
146
|
+
// Arquivo de environment prodlike
|
|
147
|
+
write('.env.prodlike', `# Configurações de ambiente para prodlike
|
|
148
|
+
# Adicione suas variáveis de ambiente aqui`);
|
|
149
|
+
// Exemplo de Request Token
|
|
150
|
+
write('src/request/token/RequestToken.ts', `import type { ApiRequest } from '@silasfmartins/testhub'
|
|
151
|
+
|
|
152
|
+
export class RequestToken {
|
|
153
|
+
requestToken(): ApiRequest {
|
|
154
|
+
const headers = {
|
|
155
|
+
authorization: 'Basic exemplo',
|
|
156
|
+
'Content-Type': 'application/json',
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
const data = 'exemplo'
|
|
160
|
+
|
|
161
|
+
return {
|
|
162
|
+
url: '/ms_oauth/oauth2/endpoints/vivooauthservice/tokens',
|
|
163
|
+
options: { headers, data },
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
`);
|
|
168
|
+
// Exemplo de statements
|
|
169
|
+
write('src/statements/token/StatementsToken.ts', `import { ApiActions, DataStore, Logger } from "@silasfmartins/testhub"
|
|
170
|
+
import { RequestToken } from "../request/token/RequestToken.js"
|
|
171
|
+
|
|
172
|
+
export class StatementsToken {
|
|
173
|
+
/**
|
|
174
|
+
* Obter token sistêmico para autenticação
|
|
175
|
+
*/
|
|
176
|
+
async getToken(): Promise<void> {
|
|
177
|
+
Logger.info("Executando o método: getToken");
|
|
178
|
+
Logger.info("Iniciando Get Token Sistêmico");
|
|
179
|
+
|
|
180
|
+
const VALIDATE_TOKEN = 200
|
|
181
|
+
|
|
182
|
+
const tokenResponse = await ApiActions.post(
|
|
183
|
+
new RequestToken().requestToken(),
|
|
184
|
+
"Requisição Token Sistêmico",
|
|
185
|
+
true
|
|
186
|
+
);
|
|
187
|
+
|
|
188
|
+
ApiActions.validateEquals(
|
|
189
|
+
tokenResponse.status(),
|
|
190
|
+
VALIDATE_TOKEN,
|
|
191
|
+
"Validação do status code da requisição de token"
|
|
192
|
+
);
|
|
193
|
+
|
|
194
|
+
// Armazenar token para uso posterior
|
|
195
|
+
DataStore.set("ACCESS_TOKEN", tokenResponse.get("token"))
|
|
196
|
+
|
|
197
|
+
Logger.info("Token obtido e armazenado com sucesso");
|
|
198
|
+
}
|
|
199
|
+
}
|
|
200
|
+
`);
|
|
201
|
+
// Exemplo de teste básico
|
|
202
|
+
write('tests/example.spec.ts', `import { type TestInfo, test, TestAnnotations } from '@silasfmartins/testhub'
|
|
203
|
+
import { StatementsToken } from '../src/statements/token/StatementsToken.js';
|
|
204
|
+
|
|
205
|
+
test.describe('Exemplo API Tests', () => {
|
|
206
|
+
TestAnnotations.Api.testInfo = testInfo;
|
|
207
|
+
await TestAnnotations.setSystem('MEU_SISTEMA');
|
|
208
|
+
test('Deve obter token com sucesso', async () => {
|
|
209
|
+
// Obter token
|
|
210
|
+
await new StatementsToken().getToken()
|
|
211
|
+
});
|
|
212
|
+
});`);
|
|
213
|
+
//env.ts
|
|
214
|
+
write('src/env.ts', `import { config } from 'dotenv'
|
|
215
|
+
|
|
216
|
+
config()
|
|
217
|
+
|
|
218
|
+
const rawEnv = {
|
|
219
|
+
ENV: process.env.ENV,
|
|
220
|
+
}
|
|
221
|
+
export const env = rawEnv
|
|
222
|
+
`);
|
|
223
|
+
// Pipeline Azure DevOps
|
|
224
|
+
write('.azuredevops/azure-pipeline.yml', `trigger:
|
|
225
|
+
batch: true
|
|
226
|
+
branches:
|
|
227
|
+
include:
|
|
228
|
+
- 'master'
|
|
229
|
+
paths:
|
|
230
|
+
include:
|
|
231
|
+
- '*'
|
|
232
|
+
exclude:
|
|
233
|
+
- .azuredevops/*
|
|
234
|
+
- docs/*
|
|
235
|
+
- catalog-info.yaml
|
|
236
|
+
- mkdocs.yml
|
|
237
|
+
- scripts.py
|
|
238
|
+
- catalog/*
|
|
239
|
+
|
|
240
|
+
resources:
|
|
241
|
+
repositories:
|
|
242
|
+
- repository: CodePlay
|
|
243
|
+
name: DevOps/Vivo.CodePlay.Pipelines
|
|
244
|
+
type: git
|
|
245
|
+
ref: refs/heads/test-playwright
|
|
246
|
+
endpoint: CodePlay
|
|
247
|
+
|
|
248
|
+
pool:
|
|
249
|
+
name: GeneralPurposeLinuxAgentsCI
|
|
250
|
+
|
|
251
|
+
extends:
|
|
252
|
+
template: tech_products/qa/build/pipeline_node_npm.yml@CodePlay
|
|
253
|
+
parameters:
|
|
254
|
+
jobName: 'build_${projectNameUnderscore}_pkg'
|
|
255
|
+
commitSHA: '$(Build.SourceVersion)'
|
|
256
|
+
registryServiceConnection: 'ACR-DEVOPS'
|
|
257
|
+
govAppAcronym: ''
|
|
258
|
+
skipScan: false # Alterado para false para executar Fortify e SonarQube
|
|
259
|
+
`);
|
|
260
|
+
// SonarQube configuration
|
|
261
|
+
write('.azuredevops/sonar-project.properties', `################### NÃO ALTERAR!!! ###################
|
|
262
|
+
# Informações gerais sobre o projeto. #
|
|
263
|
+
# Todas as variáveis de ambiente são fornecidas pela #
|
|
264
|
+
# automação, não alterar! #
|
|
265
|
+
######################################################
|
|
266
|
+
|
|
267
|
+
sonar.projectDescription=Projeto de API com AutoCore
|
|
268
|
+
sonar.analysis.orgName=\${env.AZ_ORG_NAME}
|
|
269
|
+
sonar.analysis.buildAuthor=\${env.AZ_BUILD_AUTHOR}
|
|
270
|
+
sonar.scm.exclusions.disabled=false
|
|
271
|
+
sonar.scm.forceReloadAll=true
|
|
272
|
+
sonar.log.level=DEBUG
|
|
273
|
+
sonar.verbose=true
|
|
274
|
+
sonar.sourceEncoding=UTF-8
|
|
275
|
+
|
|
276
|
+
# Diretórios e arquivos relevantes para Node.js/TypeScript
|
|
277
|
+
sonar.sources=src
|
|
278
|
+
sonar.inclusions=**/*.ts
|
|
279
|
+
sonar.test.inclusions=**/*.spec.ts,**/*.test.ts
|
|
280
|
+
sonar.typescript.lcov.reportPaths=coverage/lcov.info
|
|
281
|
+
sonar.javascript.lcov.reportPaths=coverage/lcov.info
|
|
282
|
+
|
|
283
|
+
# Exclusões de cobertura e análise
|
|
284
|
+
sonar.exclusions=node_modules/**,dist/**,coverage/**,**/*.config.js,**/*.config.ts
|
|
285
|
+
sonar.coverage.exclusions=**/*.d.ts,node_modules/**,dist/**,coverage/**,**/*.config.js,**/*.config.ts,**/*.spec.ts,**/*.test.ts
|
|
286
|
+
sonar.test.exclusions=node_modules/**,dist/**,coverage/**
|
|
287
|
+
|
|
288
|
+
# Configurações específicas para projetos API
|
|
289
|
+
sonar.javascript.environments=node
|
|
290
|
+
sonar.typescript.node=true
|
|
291
|
+
`);
|
|
292
|
+
// README.md
|
|
293
|
+
write('README.md', `# ${projectName}
|
|
294
|
+
|
|
295
|
+
Projeto de automação de testes de API baseado no AutoCore.
|
|
296
|
+
|
|
297
|
+
## 🚀 Como usar
|
|
298
|
+
|
|
299
|
+
### Instalação de dependências
|
|
300
|
+
\`\`\`bash
|
|
301
|
+
npm install
|
|
302
|
+
\`\`\`
|
|
303
|
+
|
|
304
|
+
### Executar testes
|
|
305
|
+
\`\`\`bash
|
|
306
|
+
# Ambiente preprod
|
|
307
|
+
npm run test:preprod
|
|
308
|
+
|
|
309
|
+
# Ambiente esteira1
|
|
310
|
+
npm run test:esteira1
|
|
311
|
+
|
|
312
|
+
# Ambiente esteira2
|
|
313
|
+
npm run test:esteira2
|
|
314
|
+
|
|
315
|
+
# Ambiente prodlike
|
|
316
|
+
npm run test:prodlike
|
|
317
|
+
\`\`\`
|
|
318
|
+
|
|
319
|
+
### Gerar Artefato para Projetos de Cenários
|
|
320
|
+
npm run build
|
|
321
|
+
|
|
322
|
+
### Configuração de ambiente
|
|
323
|
+
|
|
324
|
+
1. Configure as variáveis de ambiente nos arquivos \`.env.*\`
|
|
325
|
+
2. Adicione suas URLs de API e credenciais
|
|
326
|
+
3. Execute os testes
|
|
327
|
+
|
|
328
|
+
## 📋 Estrutura do projeto
|
|
329
|
+
|
|
330
|
+
\`\`\`
|
|
331
|
+
${projectName}/
|
|
332
|
+
├── src/
|
|
333
|
+
│ ├── statements/ # Lógica de negócio dos testes
|
|
334
|
+
│ └── request/ # Configurações de requisições
|
|
335
|
+
| └── env.ts # Configuração de environment
|
|
336
|
+
├── tests/ # Arquivos de teste
|
|
337
|
+
├── .env.* # Variáveis de ambiente por ambiente
|
|
338
|
+
├── playwright.config.ts # Configuração do Playwright
|
|
339
|
+
├── tsconfig.json # Configuração TypeScript (sincronizada)
|
|
340
|
+
├── biome.json # Configuração Biome (sincronizada)
|
|
341
|
+
└── README.md # Esta documentação
|
|
342
|
+
\`\`\`
|
|
343
|
+
|
|
344
|
+
## 🔧 Desenvolvimento
|
|
345
|
+
|
|
346
|
+
- **TypeScript**: Configurado e sincronizado com AutoCore
|
|
347
|
+
- **Playwright**: Framework de testes
|
|
348
|
+
- **AutoCore**: Biblioteca de utilitários para automação
|
|
349
|
+
- **Biome**: Linting e formatação (configuração sincronizada)
|
|
350
|
+
- **Ultracite**: Experiência de desenvolvimento aprimorada
|
|
351
|
+
|
|
352
|
+
## 📊 Relatórios
|
|
353
|
+
|
|
354
|
+
Os relatórios são gerados automaticamente em:
|
|
355
|
+
- \`playwright-report/\` - Relatório HTML visual
|
|
356
|
+
- \`test-results/\` - Resultados detalhados e artifacts
|
|
357
|
+
- Logs estruturados no console
|
|
358
|
+
|
|
359
|
+
## 🧪 Exemplos de Uso
|
|
360
|
+
|
|
361
|
+
### Teste básico de API
|
|
362
|
+
\`\`\`typescript
|
|
363
|
+
import { type TestInfo, test, TestAnnotations } from '@silasfmartins/testhub'
|
|
364
|
+
|
|
365
|
+
test('Meu teste de API', async ({ }, testInfo) => {
|
|
366
|
+
TestAnnotations.Api.testInfo = testInfo;
|
|
367
|
+
|
|
368
|
+
const response = await ApiActions.get({
|
|
369
|
+
url: 'https://api.example.com/endpoint',
|
|
370
|
+
options: {}
|
|
371
|
+
}, 'Descrição da requisição');
|
|
372
|
+
|
|
373
|
+
ApiActions.validateEquals(response.status, 200, 'Status deve ser 200');
|
|
374
|
+
});
|
|
375
|
+
\`\`\`
|
|
376
|
+
|
|
377
|
+
### Fluxo com autenticação
|
|
378
|
+
\`\`\`typescript
|
|
379
|
+
import { StatementsToken } from '../src/statements/StatementsToken.js';
|
|
380
|
+
import { DataStore } from '@silasfmartins/testhub';
|
|
381
|
+
|
|
382
|
+
test('Fluxo autenticado', async () => {
|
|
383
|
+
// Obter token
|
|
384
|
+
const statements = new StatementsToken();
|
|
385
|
+
await statements.getToken();
|
|
386
|
+
|
|
387
|
+
// Usar token
|
|
388
|
+
const token = DataStore.get('ACCESS_TOKEN');
|
|
389
|
+
// ... usar token em requisições subsequentes
|
|
390
|
+
});
|
|
391
|
+
\`\`\`
|
|
392
|
+
|
|
393
|
+
## 🔧 Comandos Úteis
|
|
394
|
+
|
|
395
|
+
\`\`\`bash
|
|
396
|
+
# Desenvolvimento
|
|
397
|
+
npm run test:preprod # Executar testes em preprod
|
|
398
|
+
npm run build # Compilar projeto (se necessário)
|
|
399
|
+
npm run update # Atualizar índices
|
|
400
|
+
|
|
401
|
+
# Qualidade de código
|
|
402
|
+
npx biome check # Verificar código com Biome
|
|
403
|
+
npx biome format # Formatar código com Biome
|
|
404
|
+
npx biome check --apply # Aplicar correções automáticas
|
|
405
|
+
|
|
406
|
+
# Debug
|
|
407
|
+
npm run test:preprod -- --debug # Executar em modo debug
|
|
408
|
+
npm run test:preprod -- --headed # Executar com interface visual
|
|
409
|
+
npm run test:preprod -- --ui # Executar com UI do Playwright
|
|
410
|
+
\`\`\`
|
|
411
|
+
|
|
412
|
+
## 🔄 Sincronização com AutoCore
|
|
413
|
+
|
|
414
|
+
Este projeto mantém sincronização automática com o AutoCore para:
|
|
415
|
+
|
|
416
|
+
- **tsconfig.json**: Configuração de compilação TypeScript
|
|
417
|
+
- **biome.json**: Configuração de linting e formatação
|
|
418
|
+
- **Versões de dependências**: Sempre atualizadas
|
|
419
|
+
|
|
420
|
+
Para sincronizar manualmente:
|
|
421
|
+
\`\`\`bash
|
|
422
|
+
npx autocore-sync-configs
|
|
423
|
+
\`\`\`
|
|
424
|
+
|
|
425
|
+
## 📈 Métricas e Monitoramento
|
|
426
|
+
|
|
427
|
+
- **Relatórios HTML**: Visualização rica dos resultados
|
|
428
|
+
- **Logs estruturados**: Para análise e debugging
|
|
429
|
+
- **Screenshots automáticos**: Em caso de falhas
|
|
430
|
+
- **Traces**: Para análise detalhada de execução
|
|
431
|
+
|
|
432
|
+
## 🆘 Resolução de Problemas
|
|
433
|
+
|
|
434
|
+
### Erro de autenticação npm
|
|
435
|
+
\`\`\`bash
|
|
436
|
+
npm config set registry https://pkgs.dev.azure.com/telefonica-vivo-brasil/_packaging/DevOps/npm/registry/
|
|
437
|
+
npm login
|
|
438
|
+
\`\`\`
|
|
439
|
+
|
|
440
|
+
### Problemas de certificado
|
|
441
|
+
\`\`\`bash
|
|
442
|
+
npm config set strict-ssl false
|
|
443
|
+
\`\`\`
|
|
444
|
+
|
|
445
|
+
### Atualizar dependências
|
|
446
|
+
\`\`\`bash
|
|
447
|
+
npx npm-check-updates -u && npm install
|
|
448
|
+
\`\`\`
|
|
449
|
+
|
|
450
|
+
## 📝 Contribuição
|
|
451
|
+
|
|
452
|
+
1. Mantenha os padrões de código (Biome configurado)
|
|
453
|
+
2. Adicione testes para novas funcionalidades
|
|
454
|
+
3. Use o sistema de logging do AutoCore
|
|
455
|
+
4. Documente mudanças significativas
|
|
456
|
+
|
|
457
|
+
---
|
|
458
|
+
|
|
459
|
+
**Gerado automaticamente pelo AutoCore v${versions?.dependencies?.['@silasfmartins/testhub'] || 'latest'}**`);
|
|
460
|
+
console.log('📦 Instalando dependências...');
|
|
461
|
+
const installLockPath = path.join(root, '.install.lock');
|
|
462
|
+
if (fs.existsSync(installLockPath)) {
|
|
463
|
+
// Pula npm install se o lock já existe
|
|
464
|
+
console.log('🔄 Dependências já instaladas, pulando npm install');
|
|
465
|
+
}
|
|
466
|
+
else {
|
|
467
|
+
// Executa npm install e cria o lock
|
|
468
|
+
console.log('📦 Instalando dependências...');
|
|
469
|
+
try {
|
|
470
|
+
execSync('npm install', {
|
|
471
|
+
stdio: 'inherit',
|
|
472
|
+
cwd: root,
|
|
473
|
+
});
|
|
474
|
+
fs.writeFileSync(installLockPath, 'ok');
|
|
475
|
+
console.log('✅ Dependências instaladas com sucesso');
|
|
476
|
+
}
|
|
477
|
+
catch (error) {
|
|
478
|
+
console.warn('⚠️ Erro ao instalar dependências automaticamente');
|
|
479
|
+
console.log('💡 Execute manualmente: npm install');
|
|
480
|
+
}
|
|
481
|
+
}
|
|
482
|
+
// ✅ Configurar Ultracite automaticamente
|
|
483
|
+
console.log('🤖 Configurando ambiente de desenvolvimento...');
|
|
484
|
+
await setupUltracite(root);
|
|
485
|
+
// ✅ Garantir sincronização final do biome.json
|
|
486
|
+
console.log('🔧 Sincronizando configuração do Biome...');
|
|
487
|
+
const finalBiomeConfig = generateBiomeConfigString();
|
|
488
|
+
write('biome.json', finalBiomeConfig);
|
|
489
|
+
// Remover o lock após tudo finalizar
|
|
490
|
+
if (fs.existsSync(installLockPath)) {
|
|
491
|
+
fs.unlinkSync(installLockPath);
|
|
492
|
+
console.log('🗑️ Lock de instalação removido');
|
|
493
|
+
}
|
|
494
|
+
console.log('');
|
|
495
|
+
console.log('🎉 Projeto API gerado com sucesso!');
|
|
496
|
+
console.log('');
|
|
497
|
+
console.log('📋 Próximos passos:');
|
|
498
|
+
console.log(' 1. Configure suas variáveis de ambiente nos arquivos .env.*');
|
|
499
|
+
console.log(' 2. Adicione suas URLs de API no .env.preprod');
|
|
500
|
+
console.log(' 3. Execute: npm run test:preprod');
|
|
501
|
+
console.log(' 4. O Ultracite está configurado para VS Code');
|
|
502
|
+
console.log('');
|
|
503
|
+
console.log('🛠️ Comandos úteis:');
|
|
504
|
+
console.log(' npm run test:preprod - Executar testes em preprod');
|
|
505
|
+
console.log(' npm run test:esteira1 - Executar testes em esteira1');
|
|
506
|
+
console.log(' npm run test:esteira2 - Executar testes em esteira2');
|
|
507
|
+
console.log(' npm run test:prodlike - Executar testes em prodlike');
|
|
508
|
+
console.log(' npm run build - Compilar projeto');
|
|
509
|
+
console.log(' npm run update - Atualizar índices');
|
|
510
|
+
console.log(' npx biome check - Verificar código com Biome');
|
|
511
|
+
console.log(' npx biome format - Formatar código com Biome');
|
|
512
|
+
console.log('');
|
|
513
|
+
console.log('✅ Configurações sincronizadas com AutoCore:');
|
|
514
|
+
console.log(' 📝 tsconfig.json - Compilação TypeScript');
|
|
515
|
+
console.log(' 🎨 biome.json - Linting e formatação (SINCRONIZADO)');
|
|
516
|
+
console.log(' 🤖 Ultracite - Experiência de desenvolvimento');
|
|
517
|
+
console.log(' 📦 Dependências - Versões mais recentes');
|
|
518
|
+
console.log('');
|
|
519
|
+
console.log('🚀 Projeto pronto para desenvolvimento!');
|
|
520
|
+
}
|
|
521
|
+
// Executar função principal
|
|
522
|
+
main().catch((error) => {
|
|
523
|
+
console.error('❌ Erro durante inicialização:', error);
|
|
524
|
+
process.exit(1);
|
|
525
|
+
});
|