generated from polymech/site-template
url:screenshot:user-data
This commit is contained in:
parent
0086189e08
commit
cbb7b83ae5
@ -23,7 +23,7 @@
|
||||
"format": "unix-time"
|
||||
}
|
||||
],
|
||||
"default": "2025-03-29T15:12:49.089Z"
|
||||
"default": "2025-03-29T16:05:34.037Z"
|
||||
},
|
||||
"description": {
|
||||
"type": "string",
|
||||
|
||||
@ -670,7 +670,7 @@
|
||||
},
|
||||
"https://scholarworks.uni.edu/cgi/viewcontent.cgi?article=3680%5C&context=grp": {
|
||||
"isValid": false,
|
||||
"timestamp": 1743261170564
|
||||
"timestamp": 1743264335400
|
||||
},
|
||||
"https://pmc.ncbi.nlm.nih.gov/articles/PMC10489002/": {
|
||||
"isValid": true,
|
||||
@ -754,7 +754,7 @@
|
||||
},
|
||||
"https://journals.plos.org/plosone/article?id=10.1371%252Fjournal.pone.0288696": {
|
||||
"isValid": false,
|
||||
"timestamp": 1743261171019
|
||||
"timestamp": 1743264335845
|
||||
},
|
||||
"https://www.youtube.com/watch?v=_a7usMe_K38": {
|
||||
"isValid": true,
|
||||
@ -841,7 +841,7 @@
|
||||
},
|
||||
"https://www.toraytac.com/media/c3feb206-1398-4e0e-bca6-df7780f11745/tcCurg/TenCate%2520Advanced%2520Composites/Documents/Technical%2520papers/TenCate_chopped_fiber_thermoplastics_compression_molding_technical_paper.pdf": {
|
||||
"isValid": false,
|
||||
"timestamp": 1743261171190
|
||||
"timestamp": 1743264336017
|
||||
},
|
||||
"https://youtu.be/qtZv96cifIU": {
|
||||
"isValid": true,
|
||||
|
||||
3
.gitignore
vendored
3
.gitignore
vendored
@ -1,9 +1,8 @@
|
||||
# Build output
|
||||
dist/
|
||||
|
||||
# Dependencies
|
||||
node_modules/
|
||||
|
||||
.cache/chromium
|
||||
# Logs
|
||||
npm-debug.log*
|
||||
yarn-debug.log*
|
||||
|
||||
@ -31,7 +31,7 @@ export default defineConfig({
|
||||
enabled: false,
|
||||
},
|
||||
i18n: {
|
||||
locales: ["en"],
|
||||
locales: ["en","es"],
|
||||
defaultLocale: "en",
|
||||
},
|
||||
alias: {
|
||||
|
||||
@ -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,
|
||||
|
||||
@ -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'
|
||||
|
||||
Loading…
Reference in New Issue
Block a user