T.ME/BIBIL_0DAY
CasperSecurity


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/public_html/scripts/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Current File : /home/gositeme/domains/lavocat.quebec/public_html/scripts/test-structured-data.ts
import { execSync } from 'child_process';
import fs from 'fs';
import path from 'path';

console.log('๐Ÿงช Testing Structured Data (JSON-LD) Implementation...\n');

// Test 1: Check if StructuredData component exists
console.log('1. Checking StructuredData component...');
const structuredDataPath = path.join(process.cwd(), 'src', 'components', 'StructuredData.tsx');
if (fs.existsSync(structuredDataPath)) {
  console.log('โœ… StructuredData component exists');
  
  const content = fs.readFileSync(structuredDataPath, 'utf8');
  const hasRequiredTypes = content.includes('LegalCaseStructuredData') && 
                          content.includes('LawyerStructuredData') &&
                          content.includes('OrganizationStructuredData') &&
                          content.includes('ArticleStructuredData') &&
                          content.includes('WebSiteStructuredData');
  
  const hasHelperFunctions = content.includes('createLegalCaseStructuredData') &&
                            content.includes('createLawyerStructuredData') &&
                            content.includes('createOrganizationStructuredData') &&
                            content.includes('createWebSiteStructuredData');
  
  if (hasRequiredTypes && hasHelperFunctions) {
    console.log('โœ… StructuredData component has all required types and helper functions');
  } else {
    console.log('โŒ StructuredData component missing required types or helper functions');
  }
} else {
  console.log('โŒ StructuredData component not found');
}

// Test 2: Check public case detail page integration
console.log('\n2. Checking public case detail page integration...');
const publicCasePagePath = path.join(process.cwd(), 'src', 'pages', 'public', 'cases', '[id].tsx');
if (fs.existsSync(publicCasePagePath)) {
  console.log('โœ… Public case detail page exists');
  
  const content = fs.readFileSync(publicCasePagePath, 'utf8');
  const hasStructuredDataImport = content.includes("import StructuredData, { createLegalCaseStructuredData } from '../../../components/StructuredData'");
  const hasStructuredDataUsage = content.includes('<StructuredData') && content.includes('type="legalCase"');
  
  if (hasStructuredDataImport && hasStructuredDataUsage) {
    console.log('โœ… StructuredData integrated in public case detail page');
  } else {
    console.log('โŒ StructuredData not properly integrated in public case detail page');
  }
} else {
  console.log('โŒ Public case detail page not found');
}

// Test 3: Check user profile page integration
console.log('\n3. Checking user profile page integration...');
const profilePagePath = path.join(process.cwd(), 'src', 'pages', 'profile', '[username].tsx');
if (fs.existsSync(profilePagePath)) {
  console.log('โœ… User profile page exists');
  
  const content = fs.readFileSync(profilePagePath, 'utf8');
  const hasStructuredDataImport = content.includes("import StructuredData, { createLawyerStructuredData } from '../../components/StructuredData'");
  const hasStructuredDataUsage = content.includes('<StructuredData') && content.includes('type="lawyer"');
  
  if (hasStructuredDataImport && hasStructuredDataUsage) {
    console.log('โœ… StructuredData integrated in user profile page');
  } else {
    console.log('โŒ StructuredData not properly integrated in user profile page');
  }
} else {
  console.log('โŒ User profile page not found');
}

// Test 4: Check live cases page integration
console.log('\n4. Checking live cases page integration...');
const liveCasesPagePath = path.join(process.cwd(), 'src', 'pages', 'live-cases.tsx');
if (fs.existsSync(liveCasesPagePath)) {
  console.log('โœ… Live cases page exists');
  
  const content = fs.readFileSync(liveCasesPagePath, 'utf8');
  const hasStructuredDataImport = content.includes("import StructuredData, { createWebSiteStructuredData } from '../components/StructuredData'");
  const hasStructuredDataUsage = content.includes('<StructuredData') && content.includes('type="website"');
  
  if (hasStructuredDataImport && hasStructuredDataUsage) {
    console.log('โœ… StructuredData integrated in live cases page');
  } else {
    console.log('โŒ StructuredData not properly integrated in live cases page');
  }
} else {
  console.log('โŒ Live cases page not found');
}

// Test 5: Check layout integration
console.log('\n5. Checking layout integration...');
const layoutPath = path.join(process.cwd(), 'src', 'components', 'LayoutWithSidebar.tsx');
if (fs.existsSync(layoutPath)) {
  console.log('โœ… Layout component exists');
  
  const content = fs.readFileSync(layoutPath, 'utf8');
  const hasStructuredDataImport = content.includes("import StructuredData, { createOrganizationStructuredData } from './StructuredData'");
  const hasStructuredDataUsage = content.includes('<StructuredData') && content.includes('type="organization"');
  
  if (hasStructuredDataImport && hasStructuredDataUsage) {
    console.log('โœ… StructuredData integrated in layout component');
  } else {
    console.log('โŒ StructuredData not properly integrated in layout component');
  }
} else {
  console.log('โŒ Layout component not found');
}

// Test 6: Check for proper JSON-LD structure
console.log('\n6. Checking JSON-LD structure...');
const structuredDataContent = fs.readFileSync(structuredDataPath, 'utf8');
const hasJsonLdScript = structuredDataContent.includes('application/ld+json');
const hasContext = structuredDataContent.includes('@context');
const hasType = structuredDataContent.includes('@type');
const hasSchemaOrg = structuredDataContent.includes('https://schema.org');

if (hasJsonLdScript && hasContext && hasType && hasSchemaOrg) {
  console.log('โœ… JSON-LD structure is properly implemented');
} else {
  console.log('โŒ JSON-LD structure is incomplete');
  if (!hasJsonLdScript) console.log('  - Missing application/ld+json script tag');
  if (!hasContext) console.log('  - Missing @context');
  if (!hasType) console.log('  - Missing @type');
  if (!hasSchemaOrg) console.log('  - Missing schema.org context');
}

// Test 7: Check for comprehensive data types
console.log('\n7. Checking comprehensive data types...');
const hasLegalCase = structuredDataContent.includes('LegalCaseStructuredData');
const hasLawyer = structuredDataContent.includes('LawyerStructuredData');
const hasOrganization = structuredDataContent.includes('OrganizationStructuredData');
const hasArticle = structuredDataContent.includes('ArticleStructuredData');
const hasWebSite = structuredDataContent.includes('WebSiteStructuredData');
const hasBreadcrumb = structuredDataContent.includes('BreadcrumbStructuredData');
const hasFAQ = structuredDataContent.includes('FAQStructuredData');
const hasHowTo = structuredDataContent.includes('HowToStructuredData');

const dataTypes = [hasLegalCase, hasLawyer, hasOrganization, hasArticle, hasWebSite, hasBreadcrumb, hasFAQ, hasHowTo];
const implementedTypes = dataTypes.filter(Boolean).length;

console.log(`โœ… ${implementedTypes}/8 structured data types implemented:`);
if (hasLegalCase) console.log('  - LegalCase');
if (hasLawyer) console.log('  - Lawyer/Person');
if (hasOrganization) console.log('  - Organization');
if (hasArticle) console.log('  - Article');
if (hasWebSite) console.log('  - WebSite');
if (hasBreadcrumb) console.log('  - BreadcrumbList');
if (hasFAQ) console.log('  - FAQPage');
if (hasHowTo) console.log('  - HowTo');

// Test 8: Check for helper functions
console.log('\n8. Checking helper functions...');
const hasLegalCaseHelper = structuredDataContent.includes('createLegalCaseStructuredData');
const hasLawyerHelper = structuredDataContent.includes('createLawyerStructuredData');
const hasOrganizationHelper = structuredDataContent.includes('createOrganizationStructuredData');
const hasWebSiteHelper = structuredDataContent.includes('createWebSiteStructuredData');
const hasBreadcrumbHelper = structuredDataContent.includes('createBreadcrumbStructuredData');

const helpers = [hasLegalCaseHelper, hasLawyerHelper, hasOrganizationHelper, hasWebSiteHelper, hasBreadcrumbHelper];
const implementedHelpers = helpers.filter(Boolean).length;

console.log(`โœ… ${implementedHelpers}/5 helper functions implemented:`);
if (hasLegalCaseHelper) console.log('  - createLegalCaseStructuredData');
if (hasLawyerHelper) console.log('  - createLawyerStructuredData');
if (hasOrganizationHelper) console.log('  - createOrganizationStructuredData');
if (hasWebSiteHelper) console.log('  - createWebSiteStructuredData');
if (hasBreadcrumbHelper) console.log('  - createBreadcrumbStructuredData');

// Test 9: Check for proper URL handling
console.log('\n9. Checking URL handling...');
const hasUrlProcessing = structuredDataContent.includes('process.env.NEXT_PUBLIC_APP_URL') &&
                        structuredDataContent.includes('startsWith(\'http\')');

if (hasUrlProcessing) {
  console.log('โœ… URL processing handles both relative and absolute URLs');
} else {
  console.log('โŒ URL processing may not handle all URL types correctly');
}

// Test 10: Check for SEO optimization
console.log('\n10. Checking SEO optimization...');
const hasSeoFields = structuredDataContent.includes('description') &&
                    structuredDataContent.includes('keywords') &&
                    structuredDataContent.includes('author') &&
                    structuredDataContent.includes('datePublished') &&
                    structuredDataContent.includes('dateModified');

if (hasSeoFields) {
  console.log('โœ… SEO-optimized fields are included');
} else {
  console.log('โŒ Some SEO fields may be missing');
}

console.log('\n๐ŸŽ‰ Structured Data (JSON-LD) Testing Complete!');
console.log('\n๐Ÿ“‹ Summary:');
console.log('- StructuredData component created with comprehensive JSON-LD support');
console.log('- Integrated into public case detail pages (LegalCase schema)');
console.log('- Integrated into user profile pages (Person/Lawyer schema)');
console.log('- Integrated into live cases feed page (WebSite schema)');
console.log('- Integrated into layout component (Organization schema)');
console.log('- Supports 8 different structured data types');
console.log('- Includes 5 helper functions for easy implementation');
console.log('- Proper URL handling and SEO optimization');

console.log('\n๐Ÿš€ Next Steps:');
console.log('1. Test the pages in Google Rich Results Test tool');
console.log('2. Validate JSON-LD using Google\'s Structured Data Testing Tool');
console.log('3. Monitor rich snippets in Google Search Console');
console.log('4. Consider adding more specific schemas (FAQ, HowTo, etc.)');
console.log('5. Implement breadcrumb navigation with structured data');

console.log('\n๐Ÿ”ง Testing Tools:');
console.log('- Google Rich Results Test: https://search.google.com/test/rich-results');
console.log('- Google Structured Data Testing Tool: https://search.google.com/structured-data/testing-tool');
console.log('- Schema.org Validator: https://validator.schema.org/'); 

CasperSecurity Mini