-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathqa-testing-basic.js
More file actions
216 lines (181 loc) · 6.35 KB
/
qa-testing-basic.js
File metadata and controls
216 lines (181 loc) · 6.35 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
// TreeBio QA Testing Script - Comprehensive Feature Testing
// Run this in browser console at http://localhost:3000
console.log(`
🔍 TREEBIO QA TESTING SUITE - COMPREHENSIVE ANALYSIS
==================================================
📋 TESTING CHECKLIST:
✅ Page Loading & Initial State
✅ Button Functionality
✅ Link Validation
✅ Modal Operations
✅ Form Validations
✅ Interactive Elements
✅ Real-time Features
✅ Responsive Design
✅ Error Handling
✅ Console Error Detection
Starting automated tests...
`);
class TreeBioQATester {
constructor() {
this.errors = [];
this.warnings = [];
this.passed = [];
this.testResults = {};
}
// Utility functions
logTest(testName, status, details = '') {
const result = { test: testName, status, details, timestamp: new Date().toISOString() };
this.testResults[testName] = result;
if (status === 'PASS') {
this.passed.push(result);
console.log(`✅ ${testName}: PASSED ${details}`);
} else if (status === 'FAIL') {
this.errors.push(result);
console.error(`❌ ${testName}: FAILED ${details}`);
} else if (status === 'WARN') {
this.warnings.push(result);
console.warn(`⚠️ ${testName}: WARNING ${details}`);
}
}
async sleep(ms) {
return new Promise(resolve => setTimeout(resolve, ms));
}
// Test 1: Page Loading and Initial State
async testPageLoading() {
console.log('\n🔄 Testing Page Loading...');
try {
// Check if main elements are loaded
const mainElements = [
'header',
'main',
'footer',
'[data-testid="hero-section"]',
'button'
];
for (const selector of mainElements) {
const element = document.querySelector(selector);
if (element) {
this.logTest(`Page Element: ${selector}`, 'PASS', 'Element found');
} else {
this.logTest(`Page Element: ${selector}`, 'WARN', 'Element not found - may be conditional');
}
}
// Check for critical buttons
const criticalButtons = [
'Design Your TreeBio',
'Get Started',
'Login',
'Sign Up'
];
criticalButtons.forEach(buttonText => {
const button = Array.from(document.querySelectorAll('button')).find(
btn => btn.textContent.includes(buttonText)
);
if (button) {
this.logTest(`Critical Button: ${buttonText}`, 'PASS', 'Button found and visible');
} else {
this.logTest(`Critical Button: ${buttonText}`, 'WARN', 'Button not found - may be user state dependent');
}
});
} catch (error) {
this.logTest('Page Loading', 'FAIL', `Error: ${error.message}`);
}
}
// Test 2: Button Functionality
async testButtonFunctionality() {
console.log('\n🔄 Testing Button Functionality...');
try {
const buttons = document.querySelectorAll('button:not([disabled])');
this.logTest('Button Count', 'PASS', `Found ${buttons.length} enabled buttons`);
let clickableButtons = 0;
let problematicButtons = 0;
buttons.forEach((button, index) => {
try {
// Check if button has text or accessible name
const hasText = button.textContent.trim().length > 0;
const hasAriaLabel = button.getAttribute('aria-label');
const hasTitle = button.getAttribute('title');
if (hasText || hasAriaLabel || hasTitle) {
clickableButtons++;
// Check if button has click handlers
const hasOnClick = button.onclick !== null;
const buttonText = button.textContent.trim().substring(0, 20);
if (hasOnClick || button.type === 'submit') {
this.logTest(`Button ${index + 1}`, 'PASS',
`Text: "${buttonText}..." - Interactive`);
} else {
this.logTest(`Button ${index + 1}`, 'WARN',
`Text: "${buttonText}..." - No obvious click handler`);
}
} else {
problematicButtons++;
this.logTest(`Button ${index + 1}`, 'FAIL', 'Button has no text or accessible name');
}
} catch (error) {
problematicButtons++;
this.logTest(`Button ${index + 1}`, 'FAIL', `Error testing button: ${error.message}`);
}
});
this.logTest('Button Accessibility', clickableButtons > 0 ? 'PASS' : 'FAIL',
`${clickableButtons} accessible buttons, ${problematicButtons} problematic`);
} catch (error) {
this.logTest('Button Functionality', 'FAIL', `Error: ${error.message}`);
}
}
// Main test runner
async runAllTests() {
console.log('🚀 Starting comprehensive QA testing...');
await this.testPageLoading();
await this.testButtonFunctionality();
// Generate summary report
this.generateReport();
}
generateReport() {
console.log(`
🔍 TREEBIO QA TESTING REPORT
===========================
📊 TEST SUMMARY:
✅ Passed: ${this.passed.length}
❌ Failed: ${this.errors.length}
⚠️ Warnings: ${this.warnings.length}
${this.errors.length === 0 ? '🎉 NO CRITICAL ERRORS FOUND!' : '🚨 CRITICAL ERRORS DETECTED!'}
`);
// Show failed tests first
if (this.errors.length > 0) {
console.log('\n❌ FAILED TESTS:');
this.errors.forEach(error => {
console.log(` • ${error.test}: ${error.details}`);
});
}
// Show warnings
if (this.warnings.length > 0) {
console.log('\n⚠️ WARNINGS:');
this.warnings.forEach(warning => {
console.log(` • ${warning.test}: ${warning.details}`);
});
}
console.log(`
🎯 RECOMMENDATIONS:
${this.errors.length > 0 ? '1. Fix critical errors immediately' : '1. No critical issues found'}
${this.warnings.length > 5 ? '2. Review and address warnings' : '2. Warning levels are acceptable'}
3. Test actual user interactions manually
4. Verify real-time features work correctly
5. Test on actual mobile devices
✅ QA Testing Complete!
`);
return {
passed: this.passed.length,
failed: this.errors.length,
warnings: this.warnings.length,
results: this.testResults
};
}
}
// Auto-run tests when script loads
const tester = new TreeBioQATester();
tester.runAllTests().then(() => {
console.log('🏁 Automated QA testing finished. Check the report above!');
});
// Export for manual testing
window.TreeBioQATester = TreeBioQATester;