MCPcopy Index your code
hub / github.com/MALSync/MALSync / testPageCase

Function testPageCase

test/headless/test.js:498–545  ·  view source on GitHub ↗
(block, testPage, b)

Source from the content-addressed store, hash-verified

496}
497
498async function testPageCase(block, testPage, b) {
499 log(block, '');
500 log(block, testPage.title);
501 if (testPage.unreliable) logC(block, 'Unreliable', 1, 'yellow');
502 let passed = 1;
503
504 if (typeof testPage.offline === 'undefined') testPage.offline = false;
505 if (testPage.offline) {
506 logC(block, 'Offline', 1, 'yellow');
507 return;
508 }
509
510 for (const testCase of testPage.testCases) {
511 const page = await openPage(b);
512 try {
513 logC(block, testCase.url, 1);
514 await Promise.race([
515 singleCase(block, testCase, page, testPage),
516 new Promise((_, reject) => setTimeout(() => reject('timeout'), 100 * 1000)),
517 ]);
518 logC(block, 'Passed', 2, 'green');
519 } catch (e) {
520 logC(block, 'Failed', 2, 'red');
521 if (typeof e.showDiff !== 'undefined') {
522 log(block, e.message, 3);
523 log(block, `Recieved: ${e.actual}`, 4);
524 log(block, `Expected: ${e.expected}`, 4);
525 } else {
526 logEr(block, e, 3);
527 if (e === 'Captcha') {
528 throw 'Captcha';
529 }
530 if (e === 'Blocked') {
531 throw 'Blocked';
532 }
533 }
534 passed = 0;
535 }
536 await page.close();
537 }
538
539 if (!mode.quiet || (mode.quiet && !passed)) printLogBlock(block);
540 if (!passed && !testPage.unreliable && !testPage.offline) buildFailed = true;
541 if (passed && testPage.offline) {
542 console.log(' Reset offline');
543 resetOnline(testPage.path);
544 }
545}
546
547async function loopEl(testPage, headless = true) {
548 if (OnlyPage && testPage.title !== OnlyPage) return;

Callers 1

loopElFunction · 0.85

Calls 7

logFunction · 0.85
logCFunction · 0.85
openPageFunction · 0.85
singleCaseFunction · 0.85
logErFunction · 0.85
printLogBlockFunction · 0.85
resetOnlineFunction · 0.85

Tested by

no test coverage detected