@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,727 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
// @ts-nocheck
|
|
3
|
+
|
|
4
|
+
import fs from 'node:fs'
|
|
5
|
+
import { execSync } from 'child_process'
|
|
6
|
+
import yaml from 'js-yaml'
|
|
7
|
+
import path from 'path'
|
|
8
|
+
import {
|
|
9
|
+
generateBiomeConfigString,
|
|
10
|
+
generateCoverageReadme,
|
|
11
|
+
generatePackageJson,
|
|
12
|
+
generateTsConfigForProject,
|
|
13
|
+
generateVitestConfigString,
|
|
14
|
+
getLatestVersions,
|
|
15
|
+
} from './package-versions.js'
|
|
16
|
+
import { setupUltracite } from './ultracite-setup.js'
|
|
17
|
+
|
|
18
|
+
const root = process.cwd()
|
|
19
|
+
const catalogPath = path.join(root, 'catalog-info.yaml')
|
|
20
|
+
|
|
21
|
+
if (!fs.existsSync(catalogPath)) {
|
|
22
|
+
console.error('❌ Arquivo catalog-info.yaml não encontrado.')
|
|
23
|
+
process.exit(1)
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
const catalog = yaml.load(fs.readFileSync(catalogPath, 'utf-8')) as Record<string, unknown>
|
|
27
|
+
const projectName = catalog?.metadata?.name || 'meu-projeto'
|
|
28
|
+
const projectNameUnderscore = projectName.replace(/-/g, '_')
|
|
29
|
+
|
|
30
|
+
const write = (filePath: string, content: string) => {
|
|
31
|
+
const fullPath = path.join(root, filePath)
|
|
32
|
+
fs.mkdirSync(path.dirname(fullPath), { recursive: true })
|
|
33
|
+
fs.writeFileSync(fullPath, content)
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
async function main() {
|
|
37
|
+
console.log('🚀 Inicializando projeto Frontend com versões atualizadas...')
|
|
38
|
+
console.log(`📦 Projeto: ${projectName}`)
|
|
39
|
+
console.log('')
|
|
40
|
+
|
|
41
|
+
// ✅ Buscar versões mais recentes
|
|
42
|
+
const versions = await getLatestVersions()
|
|
43
|
+
|
|
44
|
+
// ✅ Gerar package.json com versões atualizadas
|
|
45
|
+
const packageJsonContent = generatePackageJson(
|
|
46
|
+
projectName,
|
|
47
|
+
'frontend',
|
|
48
|
+
versions,
|
|
49
|
+
)
|
|
50
|
+
|
|
51
|
+
// ✅ Gerar tsconfig.json baseado no AutoCore
|
|
52
|
+
const tsconfigContent = generateTsConfigForProject('frontend')
|
|
53
|
+
|
|
54
|
+
// ✅ Gerar vitest.config.ts baseado no AutoCore (NOVO!)
|
|
55
|
+
const vitestConfigContent = generateVitestConfigString('frontend')
|
|
56
|
+
|
|
57
|
+
// ✅ Gerar biome.json sincronizado com AutoCore
|
|
58
|
+
const biomeConfigContent = generateBiomeConfigString()
|
|
59
|
+
|
|
60
|
+
console.log('📝 Criando arquivos do projeto...')
|
|
61
|
+
|
|
62
|
+
// package.json com versões dinâmicas
|
|
63
|
+
write('package.json', JSON.stringify(packageJsonContent, null, 2))
|
|
64
|
+
|
|
65
|
+
// ✅ tsconfig.json sempre sincronizado com o AutoCore
|
|
66
|
+
write('tsconfig.json', JSON.stringify(tsconfigContent, null, 2))
|
|
67
|
+
|
|
68
|
+
// ✅ vitest.config.ts sempre sincronizado com o AutoCore (NOVO!)
|
|
69
|
+
write('vitest.config.ts', vitestConfigContent)
|
|
70
|
+
|
|
71
|
+
// ✅ biome.json sincronizado automaticamente com o AutoCore
|
|
72
|
+
write('biome.json', biomeConfigContent)
|
|
73
|
+
|
|
74
|
+
// playwright.config.ts
|
|
75
|
+
write(
|
|
76
|
+
'playwright.config.ts',
|
|
77
|
+
`
|
|
78
|
+
import { defineConfig } from '@playwright/test';
|
|
79
|
+
|
|
80
|
+
export default defineConfig({
|
|
81
|
+
globalSetup: '@silasfmartins/testhub/setup',
|
|
82
|
+
reporter: [['list'], ['html', { open: 'never' }], ['@silasfmartins/testhub/reporter']],
|
|
83
|
+
testDir: './tests',
|
|
84
|
+
testMatch: ['**/**/*.spec.ts', '**/**/*.test.ts'],
|
|
85
|
+
timeout: 1_800_000,
|
|
86
|
+
expect: {
|
|
87
|
+
timeout: 1_800_000,
|
|
88
|
+
},
|
|
89
|
+
fullyParallel: false,
|
|
90
|
+
workers: 1,
|
|
91
|
+
retries: 0,
|
|
92
|
+
use: {
|
|
93
|
+
baseURL: '',
|
|
94
|
+
screenshot: 'on',
|
|
95
|
+
trace: 'on',
|
|
96
|
+
video: 'on',
|
|
97
|
+
},
|
|
98
|
+
projects: [
|
|
99
|
+
// ✅ Projetos "headless" (sem browser) — para SSH, API, Banco, Mobile
|
|
100
|
+
{
|
|
101
|
+
name: 'ssh',
|
|
102
|
+
use: { browserName: undefined },
|
|
103
|
+
},
|
|
104
|
+
{
|
|
105
|
+
name: 'api',
|
|
106
|
+
use: { browserName: undefined },
|
|
107
|
+
},
|
|
108
|
+
{
|
|
109
|
+
name: 'banco',
|
|
110
|
+
use: { browserName: undefined },
|
|
111
|
+
},
|
|
112
|
+
{
|
|
113
|
+
name: 'mobile',
|
|
114
|
+
use: { browserName: undefined },
|
|
115
|
+
},
|
|
116
|
+
|
|
117
|
+
// ✅ Projetos de browser — só serão usados se você solicitar via --project
|
|
118
|
+
{
|
|
119
|
+
name: 'chromium',
|
|
120
|
+
use: {
|
|
121
|
+
browserName: 'chromium',
|
|
122
|
+
viewport: null,
|
|
123
|
+
headless: process.env.PLAYWRIGHT_HEADLESS === 'false' ? false : true,
|
|
124
|
+
launchOptions: {
|
|
125
|
+
args: ['--start-maximized'],
|
|
126
|
+
}
|
|
127
|
+
},
|
|
128
|
+
},
|
|
129
|
+
{
|
|
130
|
+
name: 'firefox',
|
|
131
|
+
use: {
|
|
132
|
+
browserName: 'firefox',
|
|
133
|
+
viewport: null,
|
|
134
|
+
headless: process.env.PLAYWRIGHT_HEADLESS === 'false' ? false : true,
|
|
135
|
+
launchOptions: {
|
|
136
|
+
args: ['--start-maximized'],
|
|
137
|
+
}
|
|
138
|
+
},
|
|
139
|
+
},
|
|
140
|
+
{
|
|
141
|
+
name: 'webkit',
|
|
142
|
+
use: {
|
|
143
|
+
browserName: 'webkit',
|
|
144
|
+
viewport: null,
|
|
145
|
+
headless: process.env.PLAYWRIGHT_HEADLESS === 'false' ? false : true,
|
|
146
|
+
launchOptions: {
|
|
147
|
+
args: ['--start-maximized'],
|
|
148
|
+
}
|
|
149
|
+
},
|
|
150
|
+
},
|
|
151
|
+
],
|
|
152
|
+
});
|
|
153
|
+
`,
|
|
154
|
+
)
|
|
155
|
+
|
|
156
|
+
// .npmrc
|
|
157
|
+
write(
|
|
158
|
+
'.npmrc',
|
|
159
|
+
`registry=https://pkgs.dev.azure.com/telefonica-vivo-brasil/_packaging/DevOps/npm/registry/`,
|
|
160
|
+
)
|
|
161
|
+
|
|
162
|
+
// .gitignore
|
|
163
|
+
write(
|
|
164
|
+
'.gitignore',
|
|
165
|
+
`# Playwright
|
|
166
|
+
node_modules/
|
|
167
|
+
/test-results/
|
|
168
|
+
/playwright-report/
|
|
169
|
+
/blob-report/
|
|
170
|
+
/playwright/.cache/
|
|
171
|
+
playwright-videos
|
|
172
|
+
/playwright-videos/
|
|
173
|
+
/playwright-videos
|
|
174
|
+
|
|
175
|
+
# Tests e logs
|
|
176
|
+
/tests
|
|
177
|
+
/logs
|
|
178
|
+
|
|
179
|
+
# Environment files
|
|
180
|
+
.env
|
|
181
|
+
.env.preprod
|
|
182
|
+
.env.esteira1
|
|
183
|
+
.env.esteira2
|
|
184
|
+
.env.prodlike
|
|
185
|
+
.env.prod
|
|
186
|
+
|
|
187
|
+
.vscode
|
|
188
|
+
.vscode/
|
|
189
|
+
docs
|
|
190
|
+
docs/
|
|
191
|
+
|
|
192
|
+
# AutoCore específicos
|
|
193
|
+
.test-data-store.json
|
|
194
|
+
.env.lock
|
|
195
|
+
.configlogger.lock
|
|
196
|
+
|
|
197
|
+
# VS Code
|
|
198
|
+
.vscode/settings.json
|
|
199
|
+
.github/
|
|
200
|
+
.github
|
|
201
|
+
|
|
202
|
+
# Biome
|
|
203
|
+
.biome.log
|
|
204
|
+
|
|
205
|
+
# Coverage
|
|
206
|
+
coverage/
|
|
207
|
+
*.lcov
|
|
208
|
+
|
|
209
|
+
# Screenshots e videos
|
|
210
|
+
/test-results/
|
|
211
|
+
/playwright-report/`,
|
|
212
|
+
)
|
|
213
|
+
|
|
214
|
+
// Arquivo de environment padrão
|
|
215
|
+
write(
|
|
216
|
+
'.env',
|
|
217
|
+
`# Arquivo que seleciona o ambiente a ser utilizado
|
|
218
|
+
ENV=preprod`,
|
|
219
|
+
)
|
|
220
|
+
|
|
221
|
+
// Arquivo de environment padrão
|
|
222
|
+
write(
|
|
223
|
+
'.env.preprod',
|
|
224
|
+
`# Configurações de ambiente para preprod
|
|
225
|
+
BASE_URL=https://your-app.preprod.com
|
|
226
|
+
NAVIGATION_TIMEOUT=15000
|
|
227
|
+
SLOW_MO=0
|
|
228
|
+
WORKERS=undefined
|
|
229
|
+
RETRIES=0
|
|
230
|
+
# Adicione suas variáveis específicas aqui`,
|
|
231
|
+
)
|
|
232
|
+
|
|
233
|
+
// Arquivo de environment esteira1
|
|
234
|
+
write(
|
|
235
|
+
'.env.esteira1',
|
|
236
|
+
`# Configurações de ambiente para esteira1
|
|
237
|
+
BASE_URL=https://your-app.esteira1.com
|
|
238
|
+
# Adicione suas variáveis específicas aqui`,
|
|
239
|
+
)
|
|
240
|
+
|
|
241
|
+
// Arquivo de environment esteira2
|
|
242
|
+
write(
|
|
243
|
+
'.env.esteira2',
|
|
244
|
+
`# Configurações de ambiente para esteira2
|
|
245
|
+
BASE_URL=https://your-app.esteira2.com
|
|
246
|
+
# Adicione suas variáveis específicas aqui`,
|
|
247
|
+
)
|
|
248
|
+
|
|
249
|
+
// Arquivo de environment prodlike
|
|
250
|
+
write(
|
|
251
|
+
'.env.prodlike',
|
|
252
|
+
`# Configurações de ambiente para prodlike
|
|
253
|
+
BASE_URL=https://your-app.prodlike.com
|
|
254
|
+
# Adicione suas variáveis específicas aqui`,
|
|
255
|
+
)
|
|
256
|
+
|
|
257
|
+
// Attributes exemplo
|
|
258
|
+
write(
|
|
259
|
+
'src/attributes/AttributesAcessarPagina.ts',
|
|
260
|
+
`export class AttributesAcessarPagina {
|
|
261
|
+
protected readonly modal = '//h5[text()="Acesso Ferramentas"]'
|
|
262
|
+
}`,
|
|
263
|
+
)
|
|
264
|
+
|
|
265
|
+
//env.ts
|
|
266
|
+
write('src/env.ts', `import { config } from 'dotenv'
|
|
267
|
+
|
|
268
|
+
config()
|
|
269
|
+
|
|
270
|
+
const rawEnv = {
|
|
271
|
+
ENV: process.env.ENV,
|
|
272
|
+
}
|
|
273
|
+
export const env = rawEnv
|
|
274
|
+
`)
|
|
275
|
+
|
|
276
|
+
// Page Object para Dashboard
|
|
277
|
+
write(
|
|
278
|
+
'src/pages/AcessarPagina.ts',
|
|
279
|
+
`import { WebActions } from '@silasfmartins/testhub'
|
|
280
|
+
import { AttributesAcessarPagina } from '../attributes/AttributesAcessarPagina.js'
|
|
281
|
+
|
|
282
|
+
export default class AcessarPagina extends AttributesAcessarPagina {
|
|
283
|
+
async navigateToLoginPage(): Promise<void> {
|
|
284
|
+
await WebActions.navigateTo('/', 'Página inicial')
|
|
285
|
+
}
|
|
286
|
+
|
|
287
|
+
async validarModal(): Promise<void> {
|
|
288
|
+
await WebActions.waitForVisible(
|
|
289
|
+
this.modal,
|
|
290
|
+
5000,
|
|
291
|
+
'Título Acesso Ferramentas'
|
|
292
|
+
)
|
|
293
|
+
}
|
|
294
|
+
}
|
|
295
|
+
`,
|
|
296
|
+
)
|
|
297
|
+
|
|
298
|
+
// Attributes para Dashboard
|
|
299
|
+
write(
|
|
300
|
+
'src/attributes/AttributesAcessarPagina.ts',
|
|
301
|
+
`import { type ILocator, TestContext } from '@silasfmartins/testhub'
|
|
302
|
+
|
|
303
|
+
export class AttributesAcessarPagina {
|
|
304
|
+
protected get modal(): ILocator {
|
|
305
|
+
return TestContext.page.locator('//h5[text()="Acesso Ferramentas"]')
|
|
306
|
+
}
|
|
307
|
+
}
|
|
308
|
+
`,
|
|
309
|
+
)
|
|
310
|
+
|
|
311
|
+
// Exemplo de teste básico (padrão recomendado)
|
|
312
|
+
write(
|
|
313
|
+
'tests/login.spec.ts',
|
|
314
|
+
`import { type TestInfo, test, TestAnnotations } from '@silasfmartins/testhub'
|
|
315
|
+
import AcessarPagina from '../src/pages/AcessarPagina.js'
|
|
316
|
+
|
|
317
|
+
test.describe('Página Inicial', () => {
|
|
318
|
+
test('Deve visitar a página inicial [octane-123456]', async ({}, testInfo: TestInfo) => {
|
|
319
|
+
TestAnnotations.Frontend.testInfo = testInfo
|
|
320
|
+
await TestAnnotations.setSystem('MEU_SISTEMA')
|
|
321
|
+
await new AcessarPagina().navigateToLoginPage()
|
|
322
|
+
})
|
|
323
|
+
})
|
|
324
|
+
`,
|
|
325
|
+
)
|
|
326
|
+
|
|
327
|
+
// Pipeline Azure DevOps
|
|
328
|
+
write(
|
|
329
|
+
'.azuredevops/azure-pipeline.yml',
|
|
330
|
+
`trigger:
|
|
331
|
+
batch: true
|
|
332
|
+
branches:
|
|
333
|
+
include:
|
|
334
|
+
- 'master'
|
|
335
|
+
paths:
|
|
336
|
+
include:
|
|
337
|
+
- '*'
|
|
338
|
+
exclude:
|
|
339
|
+
- .azuredevops/*
|
|
340
|
+
- docs/*
|
|
341
|
+
- catalog-info.yaml
|
|
342
|
+
- mkdocs.yml
|
|
343
|
+
- scripts.py
|
|
344
|
+
- catalog/*
|
|
345
|
+
|
|
346
|
+
resources:
|
|
347
|
+
repositories:
|
|
348
|
+
- repository: CodePlay
|
|
349
|
+
name: DevOps/Vivo.CodePlay.Pipelines
|
|
350
|
+
type: git
|
|
351
|
+
ref: refs/heads/test-playwright
|
|
352
|
+
endpoint: CodePlay
|
|
353
|
+
|
|
354
|
+
pool:
|
|
355
|
+
name: GeneralPurposeLinuxAgentsCI
|
|
356
|
+
|
|
357
|
+
extends:
|
|
358
|
+
template: tech_products/qa/build/pipeline_node_npm.yml@CodePlay
|
|
359
|
+
parameters:
|
|
360
|
+
jobName: 'build_${projectNameUnderscore}_pkg'
|
|
361
|
+
commitSHA: '$(Build.SourceVersion)'
|
|
362
|
+
registryServiceConnection: 'ACR-DEVOPS'
|
|
363
|
+
govAppAcronym: ''
|
|
364
|
+
skipScan: false # Alterado para false para executar Fortify e SonarQube
|
|
365
|
+
`,
|
|
366
|
+
)
|
|
367
|
+
|
|
368
|
+
// SonarQube configuration
|
|
369
|
+
write(
|
|
370
|
+
'.azuredevops/sonar-project.properties',
|
|
371
|
+
`################### NÃO ALTERAR!!! ###################
|
|
372
|
+
# Informações gerais sobre o projeto. #
|
|
373
|
+
# Todas as variáveis de ambiente são fornecidas pela #
|
|
374
|
+
# automação, não alterar! #
|
|
375
|
+
######################################################
|
|
376
|
+
|
|
377
|
+
sonar.projectDescription=Projeto Frontend com AutoCore
|
|
378
|
+
sonar.analysis.orgName=\${env.AZ_ORG_NAME}
|
|
379
|
+
sonar.analysis.buildAuthor=\${env.AZ_BUILD_AUTHOR}
|
|
380
|
+
sonar.scm.exclusions.disabled=false
|
|
381
|
+
sonar.scm.forceReloadAll=true
|
|
382
|
+
sonar.log.level=DEBUG
|
|
383
|
+
sonar.verbose=true
|
|
384
|
+
sonar.sourceEncoding=UTF-8
|
|
385
|
+
|
|
386
|
+
# Diretórios e arquivos relevantes para Node.js/TypeScript
|
|
387
|
+
sonar.sources=src
|
|
388
|
+
sonar.inclusions=**/*.ts
|
|
389
|
+
sonar.test.inclusions=**/*.spec.ts,**/*.test.ts
|
|
390
|
+
sonar.typescript.lcov.reportPaths=coverage/lcov.info
|
|
391
|
+
sonar.javascript.lcov.reportPaths=coverage/lcov.info
|
|
392
|
+
|
|
393
|
+
# Exclusões de cobertura e análise
|
|
394
|
+
sonar.exclusions=node_modules/**,dist/**,coverage/**,**/*.config.js,**/*.config.ts
|
|
395
|
+
sonar.coverage.exclusions=**/*.d.ts,node_modules/**,dist/**,coverage/**,**/*.config.js,**/*.config.ts,**/*.spec.ts,**/*.test.ts
|
|
396
|
+
sonar.test.exclusions=node_modules/**,dist/**,coverage/**
|
|
397
|
+
|
|
398
|
+
# Configurações específicas para projetos Frontend
|
|
399
|
+
sonar.javascript.environments=browser,node
|
|
400
|
+
sonar.typescript.node=true
|
|
401
|
+
`,
|
|
402
|
+
)
|
|
403
|
+
|
|
404
|
+
// ✅ Estrutura de testes
|
|
405
|
+
console.log('📝 Criando estrutura de testes...')
|
|
406
|
+
|
|
407
|
+
// tests/example.spec.ts - Teste E2E com Playwright
|
|
408
|
+
write(
|
|
409
|
+
'tests/example.spec.ts',
|
|
410
|
+
`import { type TestInfo, test, TestAnnotations } from '@silasfmartins/testhub'
|
|
411
|
+
import AcessarPagina from '../src/pages/AcessarPagina.js'
|
|
412
|
+
|
|
413
|
+
test.describe('Página Inicial', () => {
|
|
414
|
+
test('Deve visitar a página inicial [octane-123456]', async ({}, testInfo: TestInfo) => {
|
|
415
|
+
TestAnnotations.Frontend.testInfo = testInfo
|
|
416
|
+
await TestAnnotations.setSystem('MEU_SISTEMA')
|
|
417
|
+
await new AcessarPagina().navigateToLoginPage()
|
|
418
|
+
})
|
|
419
|
+
})
|
|
420
|
+
`,
|
|
421
|
+
)
|
|
422
|
+
|
|
423
|
+
// README.md
|
|
424
|
+
write(
|
|
425
|
+
'README.md',
|
|
426
|
+
`# ${projectName}
|
|
427
|
+
|
|
428
|
+
Projeto de automação de testes Frontend baseado no TestHub (AutoCore).
|
|
429
|
+
|
|
430
|
+
## 🚀 Como usar
|
|
431
|
+
|
|
432
|
+
### Instalação de dependências
|
|
433
|
+
\`\`\`bash
|
|
434
|
+
npm install
|
|
435
|
+
\`\`\`
|
|
436
|
+
|
|
437
|
+
### Executar testes
|
|
438
|
+
\`\`\`bash
|
|
439
|
+
# Ambiente preprod
|
|
440
|
+
npm run test:preprod
|
|
441
|
+
|
|
442
|
+
# Ambiente esteira1
|
|
443
|
+
npm run test:esteira1
|
|
444
|
+
|
|
445
|
+
# Ambiente esteira2
|
|
446
|
+
npm run test:esteira2
|
|
447
|
+
|
|
448
|
+
# Ambiente prodlike
|
|
449
|
+
npm run test:prodlike
|
|
450
|
+
\`\`\`
|
|
451
|
+
|
|
452
|
+
### Gerar Artefato para Projetos de Cenários
|
|
453
|
+
npm run build
|
|
454
|
+
|
|
455
|
+
### Configuração de ambiente
|
|
456
|
+
|
|
457
|
+
1. Configure as variáveis de ambiente nos arquivos \`.env.*\`
|
|
458
|
+
2. Defina BASE_URL para cada ambiente
|
|
459
|
+
3. Configure viewport, timeouts conforme necessário
|
|
460
|
+
|
|
461
|
+
## 📋 Estrutura do projeto
|
|
462
|
+
|
|
463
|
+
\`\`\`
|
|
464
|
+
${projectName}/
|
|
465
|
+
├── src/
|
|
466
|
+
│ ├── pages/ # Page Objects para interação com páginas
|
|
467
|
+
│ └── attributes/ # Seletores e elementos das páginas
|
|
468
|
+
│ └── setup/fixtures # Fixtures e setup customizado (opcional)
|
|
469
|
+
| └── env.ts # Configuração de environment
|
|
470
|
+
├── tests/ # Arquivos de teste
|
|
471
|
+
├── .env.* # Variáveis de ambiente por ambiente
|
|
472
|
+
├── playwright.config.ts # Configuração do Playwright
|
|
473
|
+
├── tsconfig.json # Configuração TypeScript (sincronizada)
|
|
474
|
+
├── biome.json # Configuração Biome (sincronizada)
|
|
475
|
+
└── README.md # Esta documentação
|
|
476
|
+
\`\`\`
|
|
477
|
+
|
|
478
|
+
## 🔧 Desenvolvimento
|
|
479
|
+
|
|
480
|
+
- **TypeScript**: Configurado e sincronizado com AutoCore
|
|
481
|
+
- **Playwright**: Framework de testes E2E
|
|
482
|
+
- **AutoCore**: Biblioteca de utilitários para automação
|
|
483
|
+
- **Page Object Model**: Padrão de design implementado
|
|
484
|
+
- **Suporte a múltiplos browsers**: Chrome, Firefox, Safari
|
|
485
|
+
- **Biome**: Linting e formatação (configuração sincronizada)
|
|
486
|
+
- **Ultracite**: Experiência de desenvolvimento aprimorada
|
|
487
|
+
|
|
488
|
+
## 📊 Relatórios
|
|
489
|
+
|
|
490
|
+
Os relatórios são gerados automaticamente em:
|
|
491
|
+
- \`playwright-report/\` - Relatório HTML visual
|
|
492
|
+
- \`test-results/\` - Resultados detalhados e artifacts
|
|
493
|
+
- Logs estruturados no console
|
|
494
|
+
- Screenshots automáticos em falhas
|
|
495
|
+
- Vídeos de execução (quando habilitados)
|
|
496
|
+
|
|
497
|
+
## 🧪 Exemplos de Uso
|
|
498
|
+
|
|
499
|
+
### Teste básico de página
|
|
500
|
+
\`\`\`typescript
|
|
501
|
+
// ✅ Importe 'test' do @silasfmartins/testhub - a page é injetada automaticamente!
|
|
502
|
+
import { type TestInfo, test, TestAnnotations } from '@silasfmartins/testhub'
|
|
503
|
+
import PageLogin from '../src/pages/PageLogin.js';
|
|
504
|
+
|
|
505
|
+
test.describe('Login', () => {
|
|
506
|
+
test('Login test', async ({}, testInfo: TestInfo) => {
|
|
507
|
+
TestAnnotations.Frontend.testInfo = testInfo;
|
|
508
|
+
await TestAnnotations.setSystem('MEU_SISTEMA');
|
|
509
|
+
|
|
510
|
+
await new PageLogin().navigateToLogin();
|
|
511
|
+
});
|
|
512
|
+
});
|
|
513
|
+
\`\`\`
|
|
514
|
+
|
|
515
|
+
### Page Object personalizado
|
|
516
|
+
\`\`\`typescript
|
|
517
|
+
import { WebActions, TestContext } from '@silasfmartins/testhub';
|
|
518
|
+
import { AttributesMyPage } from '../attributes/AttributesMyPage.js';
|
|
519
|
+
|
|
520
|
+
export class MyPage extends AttributesMyPage {
|
|
521
|
+
async clickButton(buttonName: string) {
|
|
522
|
+
// Exemplo seguro sem usar template-placeholder dentro do README template
|
|
523
|
+
// const button = TestContext.page.locator("button:has-text('" + buttonName + "')");
|
|
524
|
+
await WebActions.click(this.button, 'Clicando em ' + buttonName);
|
|
525
|
+
}
|
|
526
|
+
}
|
|
527
|
+
\`\`\`
|
|
528
|
+
|
|
529
|
+
## 🔧 Comandos Úteis
|
|
530
|
+
|
|
531
|
+
\`\`\`bash
|
|
532
|
+
# Desenvolvimento
|
|
533
|
+
npm run test:preprod # Executar testes em preprod
|
|
534
|
+
npm run test:preprod:chromium # Executar apenas no Chrome
|
|
535
|
+
npm run ui:preprod # Interface visual dos testes
|
|
536
|
+
npm run debug:preprod # Modo debug
|
|
537
|
+
|
|
538
|
+
# Qualidade de código
|
|
539
|
+
npx biome check # Verificar código com Biome
|
|
540
|
+
npx biome format # Formatar código com Biome
|
|
541
|
+
npx biome check --apply # Aplicar correções automáticas
|
|
542
|
+
|
|
543
|
+
# Debug avançado
|
|
544
|
+
npm run test:preprod -- --debug # Executar em modo debug
|
|
545
|
+
npm run test:preprod -- --headed # Executar com interface visual
|
|
546
|
+
npm run test:preprod -- --ui # Executar com UI do Playwright
|
|
547
|
+
npm run test:preprod -- --trace=on # Executar com traces habilitados
|
|
548
|
+
\`\`\`
|
|
549
|
+
|
|
550
|
+
## 🎯 Configuração de Ambiente
|
|
551
|
+
|
|
552
|
+
### Para debug local:
|
|
553
|
+
\`\`\`bash
|
|
554
|
+
# Ativar modo lento
|
|
555
|
+
SLOW_MO=1000 npm run test:preprod
|
|
556
|
+
\`\`\`
|
|
557
|
+
|
|
558
|
+
## 🔄 Sincronização com AutoCore
|
|
559
|
+
|
|
560
|
+
Este projeto mantém sincronização automática com o AutoCore para:
|
|
561
|
+
|
|
562
|
+
- **tsconfig.json**: Configuração de compilação TypeScript
|
|
563
|
+
- **biome.json**: Configuração de linting e formatação
|
|
564
|
+
- **Versões de dependências**: Sempre atualizadas
|
|
565
|
+
|
|
566
|
+
Para sincronizar manualmente:
|
|
567
|
+
\`\`\`bash
|
|
568
|
+
npm i
|
|
569
|
+
\`\`\`
|
|
570
|
+
|
|
571
|
+
## 📈 Métricas e Monitoramento
|
|
572
|
+
|
|
573
|
+
- **Relatórios HTML**: Visualização rica dos resultados
|
|
574
|
+
- **Logs estruturados**: Para análise e debugging
|
|
575
|
+
- **Screenshots automáticos**: Em caso de falhas
|
|
576
|
+
- **Vídeos de execução**: Para análise detalhada
|
|
577
|
+
- **Traces do Playwright**: Para debug avançado
|
|
578
|
+
- **Métricas de performance**: Tempo de carregamento de páginas
|
|
579
|
+
|
|
580
|
+
## 🎨 Boas Práticas
|
|
581
|
+
|
|
582
|
+
### Page Object Model:
|
|
583
|
+
- **Separação clara**: Attributes (seletores) e Page Objects (ações)
|
|
584
|
+
- **Reutilização**: Métodos comuns entre páginas
|
|
585
|
+
- **Manutenibilidade**: Fácil atualização quando UI muda
|
|
586
|
+
|
|
587
|
+
### Seletores:
|
|
588
|
+
- **Prioridade**: data-testid > id > class > text
|
|
589
|
+
- **Estabilidade**: Evitar seletores frágeis como CSS complexos
|
|
590
|
+
- **Consistência**: Padrão de nomenclatura uniforme
|
|
591
|
+
|
|
592
|
+
### Testes:
|
|
593
|
+
- **Independência**: Cada teste deve ser independente
|
|
594
|
+
- **Limpeza**: Setup e teardown adequados
|
|
595
|
+
- **Assertivas**: Validações claras e específicas
|
|
596
|
+
|
|
597
|
+
## 🆘 Resolução de Problemas
|
|
598
|
+
|
|
599
|
+
### Erro de timeout
|
|
600
|
+
\`\`\`bash
|
|
601
|
+
# Aumentar timeout no playwright.config.ts
|
|
602
|
+
timeout: 120000 # 2 minutos
|
|
603
|
+
|
|
604
|
+
# Ou aumentar timeout específico
|
|
605
|
+
NAVIGATION_TIMEOUT=30000 npm run test:preprod
|
|
606
|
+
\`\`\`
|
|
607
|
+
|
|
608
|
+
### Problemas de seletores
|
|
609
|
+
\`\`\`bash
|
|
610
|
+
# Usar modo debug para inspecionar elementos
|
|
611
|
+
npm run debug:preprod
|
|
612
|
+
\`\`\`
|
|
613
|
+
|
|
614
|
+
### Performance lenta
|
|
615
|
+
\`\`\`bash
|
|
616
|
+
# Reduzir workers em CI
|
|
617
|
+
workers: process.env.WORKERS ? 1 : undefined
|
|
618
|
+
|
|
619
|
+
# Desabilitar recursos desnecessários
|
|
620
|
+
video: 'retain-on-failure' # Ao invés de 'on'
|
|
621
|
+
\`\`\`
|
|
622
|
+
|
|
623
|
+
### Atualizar dependências
|
|
624
|
+
\`\`\`bash
|
|
625
|
+
npx npm-check-updates -u && npm install
|
|
626
|
+
npx playwright install # Atualizar browsers
|
|
627
|
+
\`\`\`
|
|
628
|
+
|
|
629
|
+
## 📝 Contribuição
|
|
630
|
+
|
|
631
|
+
1. Mantenha os padrões de código (Biome configurado)
|
|
632
|
+
2. Adicione testes para novas funcionalidades
|
|
633
|
+
3. Use o Page Object Model
|
|
634
|
+
4. Documente seletores complexos
|
|
635
|
+
5. Valide em múltiplos browsers quando relevante
|
|
636
|
+
|
|
637
|
+
## 📚 Referências
|
|
638
|
+
|
|
639
|
+
- [AutoCore WebSite](http://brtlvlty0559pl:3002/)
|
|
640
|
+
- [Playwright Documentation](https://playwright.dev/)
|
|
641
|
+
- [Page Object Model](https://playwright.dev/docs/pom)
|
|
642
|
+
- [Best Practices](https://playwright.dev/docs/best-practices)
|
|
643
|
+
|
|
644
|
+
---
|
|
645
|
+
|
|
646
|
+
**Gerado automaticamente pelo AutoCore v${versions?.dependencies?.['@silasfmartins/testhub'] || 'latest'}**
|
|
647
|
+
`,
|
|
648
|
+
)
|
|
649
|
+
|
|
650
|
+
// 📊 README específico para Coverage
|
|
651
|
+
const coverageReadmeTemplate = generateCoverageReadme(projectName)
|
|
652
|
+
write('docs/COVERAGE.md', coverageReadmeTemplate)
|
|
653
|
+
|
|
654
|
+
console.log('📊 Documentação de cobertura criada: docs/COVERAGE.md')
|
|
655
|
+
|
|
656
|
+
// 📦 Instalação de dependências NPM
|
|
657
|
+
console.log('📦 Instalando dependências NPM...')
|
|
658
|
+
try {
|
|
659
|
+
execSync('npm install', {
|
|
660
|
+
stdio: 'inherit',
|
|
661
|
+
cwd: root,
|
|
662
|
+
})
|
|
663
|
+
console.log('✅ Dependências NPM instaladas com sucesso')
|
|
664
|
+
} catch (err) {
|
|
665
|
+
console.warn('⚠️ Erro ao instalar dependências automaticamente', err)
|
|
666
|
+
console.log('💡 Execute manualmente: npm install')
|
|
667
|
+
}
|
|
668
|
+
|
|
669
|
+
// 🎭 CRÍTICO: Sempre instalar browsers Playwright
|
|
670
|
+
console.log('🎭 Instalando browsers Playwright...')
|
|
671
|
+
try {
|
|
672
|
+
execSync('npx playwright install', {
|
|
673
|
+
stdio: 'inherit',
|
|
674
|
+
cwd: root,
|
|
675
|
+
})
|
|
676
|
+
console.log('✅ Browsers Playwright instalados com sucesso')
|
|
677
|
+
} catch (err) {
|
|
678
|
+
console.warn('⚠️ Erro ao instalar browsers automaticamente', err)
|
|
679
|
+
console.log('💡 Execute manualmente: npx playwright install')
|
|
680
|
+
}
|
|
681
|
+
|
|
682
|
+
// ✅ Configurar Ultracite automaticamente
|
|
683
|
+
console.log('🤖 Configurando ambiente de desenvolvimento...')
|
|
684
|
+
await setupUltracite(root)
|
|
685
|
+
|
|
686
|
+
// ✅ Garantir sincronização final do biome.json
|
|
687
|
+
console.log('🔧 Sincronizando configuração do Biome...')
|
|
688
|
+
const finalBiomeConfig = generateBiomeConfigString()
|
|
689
|
+
write('biome.json', finalBiomeConfig)
|
|
690
|
+
|
|
691
|
+
// ✅ Instalação finalizada com sucesso
|
|
692
|
+
|
|
693
|
+
console.log('')
|
|
694
|
+
console.log('🎉 Projeto Frontend gerado com sucesso!')
|
|
695
|
+
console.log('')
|
|
696
|
+
console.log('📋 Próximos passos:')
|
|
697
|
+
console.log(' 1. Configure suas variáveis de ambiente nos arquivos .env.*')
|
|
698
|
+
console.log(' 2. Adicione sua BASE_URL nos ambientes')
|
|
699
|
+
console.log(' 3. Execute: npm run test:preprod')
|
|
700
|
+
console.log(' 4. O Ultracite está configurado para VS Code')
|
|
701
|
+
console.log('')
|
|
702
|
+
console.log('🛠️ Comandos úteis:')
|
|
703
|
+
console.log(' npm run test:preprod - Executar testes em preprod')
|
|
704
|
+
console.log(' npm run test:esteira1 - Executar testes em esteira1')
|
|
705
|
+
console.log(' npm run test:esteira2 - Executar testes em esteira2')
|
|
706
|
+
console.log(' npm run test:prodlike - Executar testes em prodlike')
|
|
707
|
+
console.log(' npm run ui:preprod - Interface visual dos testes')
|
|
708
|
+
console.log(' npm run debug:preprod - Modo debug')
|
|
709
|
+
console.log(' npx biome check - Verificar código com Biome')
|
|
710
|
+
console.log(' npx biome format - Formatar código com Biome')
|
|
711
|
+
console.log('')
|
|
712
|
+
console.log('✅ Configurações sincronizadas com AutoCore:')
|
|
713
|
+
console.log(' 📝 tsconfig.json - Compilação TypeScript')
|
|
714
|
+
console.log(' 🎨 biome.json - Linting e formatação (SINCRONIZADO)')
|
|
715
|
+
console.log(' 🤖 Ultracite - Experiência de desenvolvimento')
|
|
716
|
+
console.log(' 📦 Dependências - Versões mais recentes')
|
|
717
|
+
console.log(' 🎭 Playwright - Configuração otimizada para frontend')
|
|
718
|
+
console.log(' 🌐 Browsers - Chromium, Firefox e WebKit instalados')
|
|
719
|
+
console.log('')
|
|
720
|
+
console.log('🚀 Projeto pronto para desenvolvimento de testes frontend!')
|
|
721
|
+
}
|
|
722
|
+
|
|
723
|
+
// Executar função principal
|
|
724
|
+
main().catch((error) => {
|
|
725
|
+
console.error('❌ Erro durante inicialização:', error)
|
|
726
|
+
process.exit(1)
|
|
727
|
+
})
|