generated from polymech/site-template
url:screenshot:user-data
This commit is contained in:
@@ -96,19 +96,13 @@ describe('URL Checker', () => {
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('checkUrl convenience function', () => {
|
||||
it('should use the default checker', async () => {
|
||||
const result = await checkUrl('https://example.com');
|
||||
expect(result.valid).toBe(true);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('url screenshot', () => {
|
||||
const testUrl = 'https://www.youtube.com/watch?v=4LrrFz802To';
|
||||
const testOutputDir = path.join(__dirname, '../../test-output');
|
||||
const screenshotPath = path.join(testOutputDir, 'test-screenshot.png');
|
||||
const chromiumDir = path.join(process.cwd(), '.cache', 'chromium');
|
||||
|
||||
// Create test output directory if it doesn't exist
|
||||
beforeAll(() => {
|
||||
@@ -130,6 +124,13 @@ describe('url screenshot', () => {
|
||||
}
|
||||
});
|
||||
|
||||
it('should create and use chromium user data directory', async () => {
|
||||
await screenshot(testUrl);
|
||||
expect(fs.existsSync(chromiumDir)).toBe(true);
|
||||
// Check for typical Chrome profile directories
|
||||
expect(fs.existsSync(path.join(chromiumDir, 'Default'))).toBe(true);
|
||||
}, 60000);
|
||||
|
||||
it('should take a screenshot with explicit path', async () => {
|
||||
const resultPath = await screenshot(testUrl, {
|
||||
dstPath: screenshotPath,
|
||||
|
||||
+8
-1
@@ -46,9 +46,16 @@ async function getGlobalBrowser(): Promise<puppeteer.Browser> {
|
||||
return browserInitPromise;
|
||||
}
|
||||
|
||||
// Create chromium user data directory if it doesn't exist
|
||||
const userDataDir = path.join(process.cwd(), '.cache', 'chromium');
|
||||
if (!fs.existsSync(userDataDir)) {
|
||||
fs.mkdirSync(userDataDir, { recursive: true });
|
||||
}
|
||||
|
||||
browserInitPromise = puppeteer.launch({
|
||||
headless: 'new' as any,
|
||||
args: ['--ignore-certificate-errors', '--no-sandbox', '--disable-setuid-sandbox']
|
||||
args: ['--ignore-certificate-errors', '--no-sandbox', '--disable-setuid-sandbox'],
|
||||
userDataDir
|
||||
});
|
||||
|
||||
try {
|
||||
|
||||
@@ -8,7 +8,7 @@ export const OSR_ROOT = () => path.resolve(resolve("${OSR_ROOT}"))
|
||||
|
||||
export const LOGGING_NAMESPACE = 'polymech-site'
|
||||
export const TRANSLATE_CONTENT = true
|
||||
export const LANGUAGES = ['en']
|
||||
export const LANGUAGES = ['en', 'es']
|
||||
export const LANGUAGES_SITE = ['en', 'ar', 'de', 'ja', 'es', 'zh', 'fr']
|
||||
export const LANGUAGES_PROD = ['en']
|
||||
export const isRTL = (lang) => lang === 'ar'
|
||||
|
||||
Reference in New Issue
Block a user