![]() Server : Apache/2 System : Linux server-15-235-50-60 5.15.0-164-generic #174-Ubuntu SMP Fri Nov 14 20:25:16 UTC 2025 x86_64 User : gositeme ( 1004) PHP Version : 8.2.29 Disable Function : exec,system,passthru,shell_exec,proc_close,proc_open,dl,popen,show_source,posix_kill,posix_mkfifo,posix_getpwuid,posix_setpgid,posix_setsid,posix_setuid,posix_setgid,posix_seteuid,posix_setegid,posix_uname Directory : /home/gositeme/domains/lavocat.quebec/private_html/scripts/ |
const fs = require('fs');
const path = require('path');
function testHowToSchemaImplementation() {
console.log('๐งช Testing HowTo Schema Implementation (Simple Validation)...\n');
let allTestsPassed = true;
// Test 1: Check if createHowToStructuredData function exists
console.log('๐ Test 1: Checking createHowToStructuredData function...');
try {
const structuredDataPath = path.join(__dirname, '../src/components/StructuredData.tsx');
const structuredDataContent = fs.readFileSync(structuredDataPath, 'utf8');
if (structuredDataContent.includes('createHowToStructuredData')) {
console.log('โ
PASS: createHowToStructuredData function found');
} else {
console.log('โ FAIL: createHowToStructuredData function not found');
allTestsPassed = false;
}
} catch (error) {
console.log(`โ ERROR: Could not read StructuredData.tsx - ${error.message}`);
allTestsPassed = false;
}
// Test 2: Check if HowTo interface is defined
console.log('\n๐ Test 2: Checking HowTo interface definition...');
try {
const structuredDataPath = path.join(__dirname, '../src/components/StructuredData.tsx');
const structuredDataContent = fs.readFileSync(structuredDataPath, 'utf8');
if (structuredDataContent.includes('interface HowToStructuredData')) {
console.log('โ
PASS: HowToStructuredData interface found');
} else {
console.log('โ FAIL: HowToStructuredData interface not found');
allTestsPassed = false;
}
} catch (error) {
console.log(`โ ERROR: Could not read StructuredData.tsx - ${error.message}`);
allTestsPassed = false;
}
// Test 3: Check class action page implementation
console.log('\n๐ Test 3: Checking class action page implementation...');
try {
const classActionPath = path.join(__dirname, '../src/pages/class-action.tsx');
const classActionContent = fs.readFileSync(classActionPath, 'utf8');
const checks = [
{ name: 'OpenGraphMeta import', pattern: 'import OpenGraphMeta' },
{ name: 'StructuredData import', pattern: 'import StructuredData' },
{ name: 'createHowToStructuredData import', pattern: 'createHowToStructuredData' },
{ name: 'OpenGraphMeta component usage', pattern: '<OpenGraphMeta' },
{ name: 'StructuredData component usage', pattern: '<StructuredData' },
{ name: 'HowTo schema type', pattern: 'type="howTo"' },
{ name: 'HowTo steps array', pattern: 'steps: [' },
{ name: 'Class action specific content', pattern: 'Join the Class Action Against Quebec' }
];
let pageChecksPassed = 0;
checks.forEach(check => {
if (classActionContent.includes(check.pattern)) {
console.log(`โ
PASS: ${check.name}`);
pageChecksPassed++;
} else {
console.log(`โ FAIL: ${check.name}`);
}
});
if (pageChecksPassed === checks.length) {
console.log('โ
PASS: All class action page checks passed');
} else {
console.log(`โ FAIL: ${checks.length - pageChecksPassed} class action page checks failed`);
allTestsPassed = false;
}
} catch (error) {
console.log(`โ ERROR: Could not read class-action.tsx - ${error.message}`);
allTestsPassed = false;
}
// Test 4: Check new case page implementation
console.log('\n๐ Test 4: Checking new case page implementation...');
try {
const newCasePath = path.join(__dirname, '../src/pages/hire/new-case.tsx');
const newCaseContent = fs.readFileSync(newCasePath, 'utf8');
const checks = [
{ name: 'OpenGraphMeta import', pattern: 'import OpenGraphMeta' },
{ name: 'StructuredData import', pattern: 'import StructuredData' },
{ name: 'createHowToStructuredData import', pattern: 'createHowToStructuredData' },
{ name: 'OpenGraphMeta component usage', pattern: '<OpenGraphMeta' },
{ name: 'StructuredData component usage', pattern: '<StructuredData' },
{ name: 'HowTo schema type', pattern: 'type="howTo"' },
{ name: 'HowTo steps array', pattern: 'steps: [' },
{ name: 'Case creation specific content', pattern: 'How to Create a New Legal Case' }
];
let pageChecksPassed = 0;
checks.forEach(check => {
if (newCaseContent.includes(check.pattern)) {
console.log(`โ
PASS: ${check.name}`);
pageChecksPassed++;
} else {
console.log(`โ FAIL: ${check.name}`);
}
});
if (pageChecksPassed === checks.length) {
console.log('โ
PASS: All new case page checks passed');
} else {
console.log(`โ FAIL: ${checks.length - pageChecksPassed} new case page checks failed`);
allTestsPassed = false;
}
} catch (error) {
console.log(`โ ERROR: Could not read new-case.tsx - ${error.message}`);
allTestsPassed = false;
}
// Test 5: Validate schema structure
console.log('\n๐ Test 5: Validating schema structure...');
try {
const structuredDataPath = path.join(__dirname, '../src/components/StructuredData.tsx');
const structuredDataContent = fs.readFileSync(structuredDataPath, 'utf8');
const requiredFields = [
'@context',
'@type',
'name',
'description',
'step'
];
let structureChecksPassed = 0;
requiredFields.forEach(field => {
if (structuredDataContent.includes(field)) {
console.log(`โ
PASS: ${field} field found`);
structureChecksPassed++;
} else {
console.log(`โ FAIL: ${field} field not found`);
}
});
if (structureChecksPassed === requiredFields.length) {
console.log('โ
PASS: All required schema fields present');
} else {
console.log(`โ FAIL: ${requiredFields.length - structureChecksPassed} required fields missing`);
allTestsPassed = false;
}
} catch (error) {
console.log(`โ ERROR: Could not validate schema structure - ${error.message}`);
allTestsPassed = false;
}
console.log('\n๐ Test Summary:');
console.log(allTestsPassed ? 'โ
All tests passed!' : 'โ Some tests failed');
if (allTestsPassed) {
console.log('\n๐ HowTo Schema Implementation Complete!');
console.log('\n๐ What was implemented:');
console.log(' โข createHowToStructuredData helper function');
console.log(' โข HowToStructuredData interface');
console.log(' โข Class Action page with HowTo schema (5 steps)');
console.log(' โข New Case Creation page with HowTo schema (9 steps)');
console.log(' โข Open Graph meta tags for both pages');
console.log('\n๐ Next steps:');
console.log(' โข Test pages with Google Rich Results Test');
console.log(' โข Verify schema appears in search results');
console.log(' โข Monitor for rich snippets in Google Search');
}
return allTestsPassed;
}
// Run the test if this file is executed directly
if (require.main === module) {
testHowToSchemaImplementation();
}
module.exports = { testHowToSchemaImplementation };