Files
cannaiq/backend/archive/test-sol-flower-age-gate.ts
Kelly d91c55a344 feat: Add stale process monitor, users route, landing page, archive old scripts
- Add backend stale process monitoring API (/api/stale-processes)
- Add users management route
- Add frontend landing page and stale process monitor UI on /scraper-tools
- Move old development scripts to backend/archive/
- Update frontend build with new features

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-12-05 04:07:31 -07:00

111 lines
3.8 KiB
TypeScript
Raw Blame History

This file contains invisible Unicode characters
This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
import puppeteer from 'puppeteer';
import { setAgeGateCookies, bypassAgeGate, hasAgeGate } from './src/utils/age-gate';
const TEST_URL = 'https://dutchie.com/dispensary/sol-flower-dispensary';
async function testSolFlowerAgeGate() {
console.log('\n🧪 Testing Sol Flower Dispensary Age Gate\n');
console.log(`URL: ${TEST_URL}\n`);
const browser = await puppeteer.launch({
headless: true, // Run in headless mode
args: [
'--no-sandbox',
'--disable-setuid-sandbox',
'--disable-blink-features=AutomationControlled',
'--disable-features=IsolateOrigins,site-per-process',
'--user-agent=Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36'
]
});
try {
const page = await browser.newPage();
// Set viewport
await page.setViewport({ width: 1280, height: 720 });
console.log('📍 Step 1: Setting age gate cookies...');
await setAgeGateCookies(page, TEST_URL, 'Arizona');
console.log('📍 Step 2: Navigating to page...');
await page.goto(TEST_URL, { waitUntil: 'domcontentloaded', timeout: 60000 });
await page.waitForTimeout(3000);
const currentUrl = page.url();
console.log(`Current URL: ${currentUrl}`);
console.log('\n📍 Step 3: Checking for age gate...');
const hasGate = await hasAgeGate(page);
if (hasGate) {
console.log('✅ Age gate detected!');
// Take screenshot before bypass
await page.screenshot({ path: '/tmp/sol-flower-before-bypass.png' });
console.log('📸 Screenshot saved: /tmp/sol-flower-before-bypass.png');
// Get page HTML to analyze structure
const bodyHTML = await page.evaluate(() => document.body.innerHTML);
console.log('\n🔍 Page HTML (first 1000 chars):');
console.log(bodyHTML.substring(0, 1000));
console.log('\n📍 Step 4: Attempting to bypass age gate...');
const bypassed = await bypassAgeGate(page, 'Arizona');
if (bypassed) {
console.log('✅ Age gate bypass succeeded!');
// Take screenshot after bypass
await page.screenshot({ path: '/tmp/sol-flower-after-bypass.png' });
console.log('📸 Screenshot saved: /tmp/sol-flower-after-bypass.png');
const finalUrl = page.url();
console.log(`Final URL: ${finalUrl}`);
// Check if we can see products
await page.waitForTimeout(3000);
const hasProducts = await page.evaluate(() => {
const bodyText = document.body.textContent || '';
return bodyText.includes('Add to cart') ||
bodyText.includes('products') ||
bodyText.includes('shop');
});
console.log(`Can see products: ${hasProducts ? '✅' : '❌'}`);
} else {
console.log('❌ Age gate bypass failed');
// Take screenshot after failed bypass
await page.screenshot({ path: '/tmp/sol-flower-failed-bypass.png' });
console.log('📸 Screenshot saved: /tmp/sol-flower-failed-bypass.png');
}
} else {
console.log(' No age gate detected - cookies may have worked!');
// Take screenshot
await page.screenshot({ path: '/tmp/sol-flower-no-gate.png' });
console.log('📸 Screenshot saved: /tmp/sol-flower-no-gate.png');
// Check if we can see products
const hasProducts = await page.evaluate(() => {
const bodyText = document.body.textContent || '';
return bodyText.includes('Add to cart') ||
bodyText.includes('products') ||
bodyText.includes('shop');
});
console.log(`Can see products: ${hasProducts ? '✅' : '❌'}`);
}
// Don't pause in headless mode
} catch (error) {
console.error('❌ Error:', error);
} finally {
await browser.close();
console.log('\n✅ Test completed');
}
}
testSolFlowerAgeGate();