-
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathe2e.test.js
More file actions
58 lines (47 loc) Β· 2.03 KB
/
Copy pathe2e.test.js
File metadata and controls
58 lines (47 loc) Β· 2.03 KB
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
const puppeteer = require('puppeteer');
const http = require('http');
const serveStatic = require('serve-static');
const finalhandler = require('finalhandler');
const serve = serveStatic('.', { 'index': ['index.html'] });
const server = http.createServer(function onRequest (req, res) {
serve(req, res, finalhandler(req, res));
});
server.listen(8000);
(async () => {
let browser;
try {
browser = await puppeteer.launch();
const page = await browser.newPage();
await page.goto('http://localhost:8000', { waitUntil: 'networkidle0' });
console.log("Starting e2e tests...");
// Test 1: Page load & Title
const title = await page.title();
if (!title.includes("Pelle Nyberg")) throw new Error("Title mismatch");
console.log("β Page title correct");
// Test 2: Hero Section
const heroVisible = await page.$eval('.hero', el => !!el);
if (!heroVisible) throw new Error("Hero section missing");
console.log("β Hero section visible");
// Test 3: 3D GAPbot integration
const botContainer = await page.$eval('#gapbot-3d-container', el => !!el);
if (!botContainer) throw new Error("3D container missing");
console.log("β 3D container present");
// Test 4: Web3 Demo
const web3Demo = await page.$eval('#web3-demo', el => !!el);
const connectBtn = await page.$eval('#connect-wallet-btn', el => !!el);
if (!web3Demo || !connectBtn) throw new Error("Web3 Demo missing");
console.log("β Web3 Demo present");
// Test 5: Blog Section
const blogSection = await page.$eval('#insights', el => !!el);
const blogCardsCount = await page.$$eval('#blog-grid .feature-card', els => els.length);
if (!blogSection || blogCardsCount < 3) throw new Error("Blog section or cards missing");
console.log("β Blog Section present with " + blogCardsCount + " cards");
console.log("All e2e tests passed successfully!");
} catch (err) {
console.error("Test failed:", err);
process.exitCode = 1;
} finally {
if (browser) await browser.close();
server.close();
}
})();