-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathverify-build.js
More file actions
176 lines (152 loc) · 5.42 KB
/
verify-build.js
File metadata and controls
176 lines (152 loc) · 5.42 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
#!/usr/bin/env node
/**
* Build Verification Script
* Verifies that the website builds successfully and key features are present
*/
import { execSync } from 'child_process';
import fs from 'fs';
import path from 'path';
import { fileURLToPath } from 'url';
const __filename = fileURLToPath(import.meta.url);
const __dirname = path.dirname(__filename);
const webDir = path.join(__dirname, 'web');
const outDir = path.join(webDir, 'out');
let passedTests = 0;
let failedTests = 0;
function test(name, fn) {
try {
fn();
console.log(`✓ ${name}`);
passedTests++;
} catch (error) {
console.error(`✗ ${name}`);
console.error(` Error: ${error.message}`);
failedTests++;
}
}
console.log('\n🧪 Running Build Verification Tests...\n');
// Test 1: Build succeeds
test('Build completes successfully', () => {
try {
execSync('npm run build', { cwd: webDir, stdio: 'pipe' });
} catch (error) {
throw new Error('Build failed');
}
});
// Test 2: Output directory exists
test('Output directory exists', () => {
if (!fs.existsSync(outDir)) {
throw new Error('Output directory not found');
}
});
// Test 3: Index HTML exists
test('Homepage HTML generated', () => {
const indexPath = path.join(outDir, 'index.html');
if (!fs.existsSync(indexPath)) {
throw new Error('index.html not found');
}
});
// Test 4: Check for key page content
test('Homepage contains "Dev Workflow"', () => {
const indexPath = path.join(outDir, 'index.html');
const content = fs.readFileSync(indexPath, 'utf-8');
if (!content.includes('Dev Workflow')) {
throw new Error('Dev Workflow text not found');
}
});
// Test 5: Check for hero section
test('Homepage contains hero section', () => {
const indexPath = path.join(outDir, 'index.html');
const content = fs.readFileSync(indexPath, 'utf-8');
if (!content.includes('Master Your') || !content.includes('Workflow')) {
throw new Error('Hero section not found');
}
});
// Test 6: Check for dark mode support
test('Dark mode classes included', () => {
const indexPath = path.join(outDir, 'index.html');
const content = fs.readFileSync(indexPath, 'utf-8');
if (!content.includes('dark:')) {
throw new Error('Dark mode classes not found');
}
});
// Test 7: Check for responsive design
test('Responsive design classes included', () => {
const indexPath = path.join(outDir, 'index.html');
const content = fs.readFileSync(indexPath, 'utf-8');
if (!content.includes('sm:') || !content.includes('md:') || !content.includes('lg:')) {
throw new Error('Responsive classes not found');
}
});
// Test 8: Check for features section
test('Features section present', () => {
const indexPath = path.join(outDir, 'index.html');
const content = fs.readFileSync(indexPath, 'utf-8');
if (!content.includes('Your Coding Conscience')) {
throw new Error('Features section not found');
}
});
// Test 9: Check for history section
test('History section present', () => {
const indexPath = path.join(outDir, 'index.html');
const content = fs.readFileSync(indexPath, 'utf-8');
if (!content.includes('Workflow History')) {
throw new Error('History section not found');
}
});
// Test 10: Check for theme toggle
test('Theme toggle button present', () => {
const indexPath = path.join(outDir, 'index.html');
const content = fs.readFileSync(indexPath, 'utf-8');
// Check for theme toggle in minified form or readable form
if (!content.includes('toggleTheme') && !content.includes('theme') && !content.includes('Moon') && !content.includes('Sun')) {
throw new Error('Theme toggle not found');
}
});
// Test 11: Check for viewport meta tag
test('Viewport meta tag for mobile', () => {
const indexPath = path.join(outDir, 'index.html');
const content = fs.readFileSync(indexPath, 'utf-8');
if (!content.includes('viewport') || !content.includes('width=device-width')) {
throw new Error('Viewport meta tag not found');
}
});
// Test 12: Check for localStorage theme persistence
test('Theme persistence in Navbar component', () => {
const navbarPath = path.join(webDir, 'components', 'Navbar.tsx');
const content = fs.readFileSync(navbarPath, 'utf-8');
if (!content.includes('localStorage')) {
throw new Error('localStorage not found in Navbar');
}
});
// Test 13: Check for system preference detection
test('System color scheme preference detection', () => {
const navbarPath = path.join(webDir, 'components', 'Navbar.tsx');
const content = fs.readFileSync(navbarPath, 'utf-8');
if (!content.includes('prefers-color-scheme')) {
throw new Error('prefers-color-scheme not found');
}
});
// Test 14: Check for responsive Navbar
test('Responsive Navbar implementation', () => {
const navbarPath = path.join(webDir, 'components', 'Navbar.tsx');
const content = fs.readFileSync(navbarPath, 'utf-8');
if (!content.includes('md:hidden') && !content.includes('hidden md:')) {
throw new Error('Responsive Navbar not found');
}
});
// Test 15: Check for vertical monitor optimization
test('Vertical monitor responsive design', () => {
const heroPath = path.join(webDir, 'components', 'Hero.tsx');
const content = fs.readFileSync(heroPath, 'utf-8');
if (!content.includes('xl:grid-cols-2')) {
throw new Error('Vertical monitor optimization not found');
}
});
console.log(`\n📊 Test Results: ${passedTests} passed, ${failedTests} failed\n`);
if (failedTests > 0) {
process.exit(1);
} else {
console.log('✅ All tests passed!\n');
process.exit(0);
}