forked from keploy/docs
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathglossary.js
More file actions
320 lines (300 loc) · 10.2 KB
/
glossary.js
File metadata and controls
320 lines (300 loc) · 10.2 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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
import React, { useState, useRef, useEffect } from "react";
import Layout from "@theme/Layout";
import Head from "@docusaurus/Head";
import clsx from "clsx";
function Glossary() {
// Initialize refs for each section
const sectionRefs = useRef({});
// Track which section is in view for navbar highlight
const [activeLetter, setActiveLetter] = useState("A");
// Initialize state for toggling sections
const [expandedSections, setExpandedSections] = useState(() => {
const sections = {};
"ABCEFGIMRSTUW".split('').forEach(letter => {
sections[letter] = true;
});
return sections;
});
// Scroll to section when navbar letter is clicked
// Lock highlight on clicked letter until its section is at the top
const [scrollTargetLetter, setScrollTargetLetter] = useState(null);
const scrollToSection = (letter) => {
// Always expand the section before scroll
setExpandedSections(prev => ({ ...prev, [letter]: true }));
setScrollTargetLetter(letter);
setActiveLetter(letter);
setTimeout(() => {
if (sectionRefs.current[letter]) {
sectionRefs.current[letter].scrollIntoView({ behavior: 'instant', block: 'start' });
// Offset for sticky navbar (default 150px)
window.scrollBy({ top: -150, behavior: 'smooth' });
}
}, 0);
};
// Intersection Observer for active section
useEffect(() => {
const handleScroll = () => {
// Get all refs in DOM order
const sectionList = Object.entries(sectionRefs.current)
.filter(([letter, ref]) => !!ref && expandedSections[letter])
.map(([letter, ref]) => ({ letter, top: ref.getBoundingClientRect().top }));
// If a scroll target is set, keep highlight until its section is at the top
if (scrollTargetLetter) {
const targetSection = sectionList.find(s => s.letter === scrollTargetLetter);
if (targetSection && Math.abs(targetSection.top) < 4) {
setActiveLetter(scrollTargetLetter);
setScrollTargetLetter(null); // Unlock
} else {
setActiveLetter(scrollTargetLetter);
}
return;
}
// Find the section closest to (but not below) the top of viewport, only among expanded
let closest = null;
let minDist = Infinity;
sectionList.forEach(({ letter, top }) => {
if (top <= 150 && Math.abs(top) < minDist) {
minDist = Math.abs(top);
closest = letter;
}
});
// Fallback: if no section is visible, keep the last activeLetter
if (closest) {
setActiveLetter(closest);
}
// else do not update activeLetter, keep last clicked
};
window.addEventListener('scroll', handleScroll, { passive: true });
// Call once to set initial
handleScroll();
return () => window.removeEventListener('scroll', handleScroll);
}, [expandedSections, scrollTargetLetter]);
const toggleSection = (letter) => {
setExpandedSections(prev => ({
...prev,
[letter]: !prev[letter]
}));
};
const entries = {
A: [
{
name: "Acceptance Testing",
link: "/docs/concepts/reference/glossary/acceptance-testing",
},
{
name: "Agile Unit Testing",
link: "/docs/concepts/reference/glossary/agile-unit-testing",
},
{
name: "AI Test Completion",
link: "/docs/concepts/reference/glossary/ai-test-completion",
},
],
B: [
{
name: "BDD",
link: "/docs/concepts/reference/glossary/behaviour-driven-development",
},
{
name: "Beta Testing",
link: "/docs/concepts/reference/glossary/beta-testing",
},
{
name: "Black Box Testing",
link: "/docs/concepts/reference/glossary/black-box-testing",
},
],
C: [
{
name: "Code Coverage",
link: "/docs/concepts/reference/glossary/code-coverage",
},
{
name: "Cucumber Testing",
link: "/docs/concepts/reference/glossary/cucumber-testing",
},
],
E: [
{
name: "End To End Testing",
link: "/docs/concepts/reference/glossary/end-to-end-testing",
},
{
name: "Error Guessing",
link: "/docs/concepts/reference/glossary/error-guessing",
},
],
F: [
{
name: "Functional Testing",
link: "/docs/concepts/reference/glossary/functional-testing",
},
],
G: [
{
name: "Gray Box Testing",
link: "/docs/concepts/reference/glossary/gray-box-testing",
},
],
I: [
{
name: "Integration Testing",
link: "/docs/concepts/reference/glossary/integration-testing",
},
{
name: "Idempotency",
link: "/docs/concepts/reference/glossary/idempotency",
},
],
M: [
{
name: "Manual Testing",
link: "/docs/concepts/reference/glossary/manual-testing",
},
{
name: "Mocks",
link: "/docs/concepts/reference/glossary/mocks",
},
{
name: "Microservice Testing",
link: "/docs/concepts/reference/glossary/microservice-testing",
},
],
R: [
{
name: "Regression Testing",
link: "/docs/concepts/reference/glossary/regression-testing",
},
],
S: [
{
name: "Stubs",
link: "/docs/concepts/reference/glossary/stubs",
},
{
name: "Software Testing Life Cycle",
link: "/docs/concepts/reference/glossary/software-testing-life-cycle",
},
],
T: [
{
name: "Test Driven TDD",
link: "/docs/concepts/reference/glossary/test-driven-development",
},
{
name: "Test Data Generation",
link: "/docs/concepts/reference/glossary/test-data-generation",
},
],
U: [
{
name: "Unit Test Automation",
link: "/docs/concepts/reference/glossary/unit-test-automation",
},
{
name: "Unit Testing",
link: "/docs/concepts/reference/glossary/unit-testing",
},
],
W: [
{
name: "White Box Testing",
link: "/docs/concepts/reference/glossary/white-box-testing",
},
],
};
return (
<Layout
title="Glossary | Keploy Documentation"
permalink="/reference/glossary"
description="Comprehensive glossary of testing and development terms used in Keploy documentation"
wrapperClassName="min-h-screen"
>
<Head>
<meta name="keywords" content="glossary, testing terms, development terms, Keploy, API testing, unit testing" />
</Head>
<main className="container mx-auto px-4 py-8">
<div className="text-center mb-8">
<h1 className="text-3xl md:text-4xl font-bold mb-2">
Developer Glossary
</h1>
<p className="text-gray-600 text-lg opacity-80">
Browse our comprehensive glossary of testing and development terms used throughout Keploy's documentation.
</p>
</div>
{/* Alphabet Navigation */}
<div className="sticky top-16 z-10 py-4 mb-8 border-b border-gray-200 bg-white/90 backdrop-blur-sm">
<div className="flex flex-wrap justify-center gap-1 sm:gap-2">
{Array.from({ length: 26 }, (_, i) => {
const letter = String.fromCharCode(65 + i);
const hasTerms = entries[letter] !== undefined;
const isActive = expandedSections[letter];
return (
<button
key={letter}
onClick={() => scrollToSection(letter)}
disabled={!hasTerms}
className={clsx(
'w-10 h-10 flex items-center justify-center rounded-lg transition-all duration-200 font-medium',
{
'bg-orange-200 text-orange-900 font-bold shadow-md': activeLetter === letter && hasTerms,
'text-gray-400 cursor-not-allowed': !hasTerms,
'text-gray-700 hover:bg-gray-100': activeLetter !== letter && hasTerms
}
)}
aria-label={`Scroll to ${letter} section`}
>
{letter}
</button>
);
})}
</div>
</div>
{/* Glossary Terms */}
<div className="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-6">
{Object.entries(entries).map(([letter, terms]) =>
expandedSections[letter] && (
<div
key={letter}
ref={el => (sectionRefs.current[letter] = el)}
className="space-y-4"
>
<div className="flex items-center mb-4">
<h2 className="text-2xl font-bold text-gray-900">
{letter}
</h2>
<span className="ml-3 text-sm text-gray-500 bg-gray-100 px-2 py-1 rounded-full">
{terms.length} {terms.length === 1 ? 'term' : 'terms'}
</span>
</div>
<div className="space-y-3">
{terms.map(({ name, link }, index) => (
<a
key={index}
href={link}
className="block p-4 bg-white rounded-lg border border-gray-200 hover:border-orange-300 transition-all duration-200 hover:shadow-md"
>
<div className="flex items-center">
<div className="flex-1">
<h3 className="font-medium text-gray-900">
{name}
</h3>
</div>
<div className="ml-2 text-orange-500">
<svg className="w-4 h-4" fill="none" stroke="currentColor" viewBox="0 0 24 24">
<path strokeLinecap="round" strokeLinejoin="round" strokeWidth={2} d="M9 5l7 7-7 7" />
</svg>
</div>
</div>
</a>
))}
</div>
</div>
)
)}
</div>
</main>
</Layout>
);
}
export default Glossary;