-
Notifications
You must be signed in to change notification settings - Fork 7
Expand file tree
/
Copy pathtest-filters.html
More file actions
70 lines (64 loc) · 2.7 KB
/
test-filters.html
File metadata and controls
70 lines (64 loc) · 2.7 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
59
60
61
62
63
64
65
66
67
68
69
70
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Filter Test</title>
</head>
<body>
<h1>API Filter Tests</h1>
<div id="results"></div>
<script>
async function testFilters() {
const tests = [
{
name: "Default (latest with type=github)",
url: "https://lb2-twitter-api.opensourceprojects.dev/threads?type=github"
},
{
name: "Search for 'react' with type=github",
url: "https://lb2-twitter-api.opensourceprojects.dev/threads?type=github&search=react"
},
{
name: "Sort by oldest with type=github",
url: "https://lb2-twitter-api.opensourceprojects.dev/threads?type=github&sort=oldest"
},
{
name: "Page 2 with type=github",
url: "https://lb2-twitter-api.opensourceprojects.dev/threads?type=github&page=2"
},
{
name: "Search + Sort + Page with type=github",
url: "https://lb2-twitter-api.opensourceprojects.dev/threads?type=github&search=javascript&sort=oldest&page=1"
}
];
const resultsDiv = document.getElementById('results');
for (const test of tests) {
const div = document.createElement('div');
div.innerHTML = `<h3>${test.name}</h3><p>Testing...</p>`;
resultsDiv.appendChild(div);
try {
const response = await fetch(test.url);
const data = await response.json();
div.innerHTML = `
<h3>✅ ${test.name}</h3>
<p><strong>URL:</strong> ${test.url}</p>
<p><strong>Total Items:</strong> ${data.pagination.total_items}</p>
<p><strong>Current Page:</strong> ${data.pagination.current_page}</p>
<p><strong>Total Pages:</strong> ${data.pagination.total_pages}</p>
<p><strong>First Post Date:</strong> ${data.threads[0]?.date}</p>
<hr>
`;
} catch (error) {
div.innerHTML = `
<h3>❌ ${test.name}</h3>
<p><strong>Error:</strong> ${error.message}</p>
<hr>
`;
}
}
}
testFilters();
</script>
</body>
</html>