forked from Real-Dev-Squad/website-dashboard
-
Notifications
You must be signed in to change notification settings - Fork 0
/
footerTest.js
66 lines (58 loc) · 2.02 KB
/
footerTest.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
const puppeteer = require('puppeteer');
let config = {
launchOptions: {
headless: 'new',
ignoreHTTPSErrors: true,
},
};
let urls = [
'https://dashboard.realdevsquad.com/index.html',
'https://dashboard.realdevsquad.com/profile/index.html',
'https://dashboard.realdevsquad.com/goal/index.html',
'https://dashboard.realdevsquad.com/task/index.html',
'https://dashboard.realdevsquad.com/users/index.html',
'https://dashboard.realdevsquad.com/users/details/index.html',
'https://dashboard.realdevsquad.com/taskevents/index.html',
'https://dashboard.realdevsquad.com/featureflag/index.html',
'https://dashboard.realdevsquad.com/wallet/index.html',
'https://dashboard.realdevsquad.com/online-members/online-members.html',
];
const test_footer = async (url, index) => {
await puppeteer.launch(config.launchOptions).then(async (browser) => {
const context = await browser.createIncognitoBrowserContext();
const page = await context.newPage();
await page.goto(url, { waitUntil: ['load', 'networkidle2'] });
await page.content();
page.setDefaultNavigationTimeout(0);
const footer = await page.$('footer');
if (footer) {
// is the text same in footer?
const footer_text = await page.evaluate(() => {
const element = document.querySelector('.info-repo');
return (
element &&
element.innerText ===
'The contents of this website are deployed from this open sourced repo'
);
});
console.log(`✅ footer text:${footer_text} index:${index}:${url}`);
if (footer_text) {
// links inside footer are working or not
await page.click('.info-repo a', { delay: 2000 });
console.log(`✅ link works for ${url}`);
}
} else {
console.log(`❌no footer at ${url}`);
}
context.close();
});
};
async function runTest() {
for (let url of urls) {
await test_footer(url, urls.indexOf(url));
if (urls.indexOf(url) === urls.length - 1) {
process.exit(0);
}
}
}
runTest();