-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest.html
More file actions
671 lines (630 loc) · 33.5 KB
/
test.html
File metadata and controls
671 lines (630 loc) · 33.5 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
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>ShadowdriverJS Testing Playground</title>
<link href="https://cdnjs.cloudflare.com/ajax/libs/bootstrap/5.3.2/css/bootstrap.min.css" rel="stylesheet">
<style>
.draggable {
cursor: move;
padding: 10px;
margin: 5px;
background-color: #f8f9fa;
border: 1px solid #dee2e6;
border-radius: 4px;
}
.dropzone {
min-height: 100px;
border: 2px dashed #dee2e6;
border-radius: 4px;
margin: 10px 0;
padding: 10px;
}
#mainContent {
display: none;
transition: opacity 0.3s ease-in-out;
opacity: 0;
}
#mainContent.visible {
display: block;
opacity: 1;
}
#loginSection {
transition: opacity 0.3s ease-out;
}
#loginSection.hidden {
display: none;
opacity: 0;
}
#loginBtn:disabled {
cursor: not-allowed;
}
.loading-overlay {
position: fixed;
top: 0;
left: 0;
width: 100%;
height: 100%;
background: rgba(255, 255, 255, 0.9);
display: none;
justify-content: center;
align-items: center;
z-index: 1000;
}
.loading-overlay.show {
display: flex;
}
.toast-container {
position: fixed;
top: 20px;
right: 20px;
z-index: 1000;
}
.hidden-content {
display: none;
}
.accordion-button:not(.collapsed)::after {
background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='%23fff'%3e%3cpath fill-rule='evenodd' d='M1.646 4.646a.5.5 0 0 1 .708 0L8 10.293l5.646-5.647a.5.5 0 0 1 .708.708l-6 6a.5.5 0 0 1-.708 0l-6-6a.5.5 0 0 1 0-.708z'/%3e%3c/svg%3e");
}
</style>
</head>
<body>
<!-- Toast Container -->
<div class="toast-container"></div>
<!-- Loading Overlay -->
<div class="loading-overlay" id="loadingOverlay">
<div class="text-center">
<div class="spinner-border text-primary" style="width: 3rem; height: 3rem;" role="status">
<span class="visually-hidden">Loading...</span>
</div>
<div class="mt-3 h5">Loading...</div>
</div>
</div>
<div class="container mt-5">
<!-- Login Form -->
<div id="loginSection" class="row justify-content-center mb-5">
<div class="col-md-6">
<div class="card">
<div class="card-header">
<h3 class="text-center">Login</h3>
</div>
<div class="card-body">
<form id="loginForm">
<div class="mb-3">
<label for="email" class="form-label">Email address</label>
<input type="email" class="form-control" id="email" required
data-testid="email-input">
</div>
<div class="mb-3">
<label for="password" class="form-label">Password</label>
<input type="password" class="form-control" id="password" required
data-testid="password-input"
pattern="^(?=.*[A-Za-z])(?=.*\d)[A-Za-z\d]{8,}$"
title="Password must be at least 8 characters long and contain at least one letter and one number">
<div class="invalid-feedback">
Password must be at least 8 characters long and contain at least one letter and one number
</div>
</div>
<div class="mb-3 form-check">
<input type="checkbox" class="form-check-input" id="rememberMe" data-testid="remember-checkbox">
<label class="form-check-label" for="rememberMe">Remember me</label>
</div>
<button type="submit" class="btn btn-primary w-100" id="loginBtn" data-testid="login-button">
<span class="normal-text">Login</span>
<span class="spinner-border spinner-border-sm ms-2 d-none" role="status" id="loginSpinner">
<span class="visually-hidden">Loading...</span>
</span>
</button>
</form>
</div>
</div>
</div>
</div>
<!-- Main Content (Hidden until login) -->
<div id="mainContent">
<!-- Tabs Navigation -->
<ul class="nav nav-tabs mb-4" id="mainTabs" role="tablist">
<li class="nav-item">
<a class="nav-link active" id="items-tab" data-bs-toggle="tab" href="#items" role="tab">Items Manager</a>
</li>
<li class="nav-item">
<a class="nav-link" id="dragdrop-tab" data-bs-toggle="tab" href="#dragdrop" role="tab">Drag & Drop</a>
</li>
<li class="nav-item">
<a class="nav-link" id="table-tab" data-bs-toggle="tab" href="#table" role="tab">Data Table</a>
</li>
<li class="nav-item">
<a class="nav-link" id="dynamic-tab" data-bs-toggle="tab" href="#dynamic" role="tab">Dynamic Content</a>
</li>
</ul>
<!-- Tab Content -->
<div class="tab-content" id="mainTabContent">
<!-- Items Manager Tab -->
<div class="tab-pane fade show active" id="items" role="tabpanel">
<div class="card mb-4">
<div class="card-header">
<h4>Add New Item</h4>
</div>
<div class="card-body">
<form id="addItemForm" class="row g-3">
<div class="col-md-6">
<label for="itemName" class="form-label">Item Name</label>
<input type="text" class="form-control" id="itemName" required
data-testid="item-name-input">
</div>
<div class="col-md-6">
<label for="itemCategory" class="form-label">Category</label>
<select class="form-select" id="itemCategory" required
data-testid="item-category-select">
<option value="">Choose...</option>
<option value="electronics">Electronics</option>
<option value="clothing">Clothing</option>
<option value="books">Books</option>
<option value="other">Other</option>
</select>
</div>
<div class="col-md-6">
<label for="itemPrice" class="form-label">Price</label>
<input type="number" class="form-control" id="itemPrice" required min="0" step="0.01"
data-testid="item-price-input">
</div>
<div class="col-md-6">
<label for="itemQuantity" class="form-label">Quantity</label>
<input type="number" class="form-control" id="itemQuantity" required min="1"
data-testid="item-quantity-input">
</div>
<div class="col-12">
<button type="submit" class="btn btn-success" data-testid="add-item-button">
Add Item
</button>
</div>
</form>
</div>
</div>
<div class="card">
<div class="card-header d-flex justify-content-between align-items-center">
<h4>Items List</h4>
<div class="input-group w-auto">
<input type="text" class="form-control" placeholder="Search items..."
id="itemSearch" data-testid="item-search-input">
<button class="btn btn-outline-secondary" type="button" id="clearSearch"
data-testid="clear-search-button">Clear</button>
</div>
</div>
<div class="card-body">
<div class="table-responsive">
<table class="table" id="itemsTable" data-testid="items-table">
<thead>
<tr>
<th>Name</th>
<th>Category</th>
<th>Price</th>
<th>Quantity</th>
<th>Actions</th>
</tr>
</thead>
<tbody></tbody>
</table>
</div>
</div>
</div>
</div>
<!-- Drag & Drop Tab -->
<div class="tab-pane fade" id="dragdrop" role="tabpanel">
<div class="row">
<div class="col-md-6">
<h5>Available Items</h5>
<div id="draggableItems">
<div class="draggable" draggable="true" data-testid="draggable-item-1">Item 1</div>
<div class="draggable" draggable="true" data-testid="draggable-item-2">Item 2</div>
<div class="draggable" draggable="true" data-testid="draggable-item-3">Item 3</div>
</div>
</div>
<div class="col-md-6">
<h5>Drop Zone</h5>
<div class="dropzone" id="dropZone" data-testid="drop-zone"></div>
</div>
</div>
</div>
<!-- Data Table Tab -->
<div class="tab-pane fade" id="table" role="tabpanel">
<div class="card">
<div class="card-header">
<div class="row align-items-center">
<div class="col">
<h4 class="mb-0">Employee Data</h4>
</div>
<div class="col-auto">
<div class="form-check form-switch">
<input class="form-check-input" type="checkbox" id="showInactiveEmployees"
data-testid="show-inactive-checkbox">
<label class="form-check-label" for="showInactiveEmployees">Show Inactive</label>
</div>
</div>
</div>
</div>
<div class="card-body">
<div class="table-responsive">
<table class="table table-striped table-hover" id="employeeTable"
data-testid="employee-table">
<thead class="table-dark">
<tr>
<th>ID</th>
<th>Name</th>
<th>Email</th>
<th>Department</th>
<th>Position</th>
<th>Status</th>
</tr>
</thead>
<tbody>
<!-- Employee data rows here -->
<tbody>
<tr>
<td>1</td>
<td>John Doe</td>
<td>john@example.com</td>
<td>IT</td>
<td>Developer</td>
<td><span class="badge bg-success">Active</span></td>
</tr>
<tr>
<td>2</td>
<td>Jane Smith</td>
<td>jane@example.com</td>
<td>HR</td>
<td>Manager</td>
<td><span class="badge bg-success">Active</span></td>
</tr>
<tr>
<td>3</td>
<td>Mike Johnson</td>
<td>mike@example.com</td>
<td>Sales</td>
<td>Executive</td>
<td><span class="badge bg-warning">On Leave</span></td>
</tr>
<tr>
<td>4</td>
<td>Sarah Williams</td>
<td>sarah@example.com</td>
<td>Marketing</td>
<td>Coordinator</td>
<td><span class="badge bg-success">Active</span></td>
</tr>
<tr>
<td>5</td>
<td>David Brown</td>
<td>david@example.com</td>
<td>IT</td>
<td>Designer</td>
<td><span class="badge bg-danger">Inactive</span></td>
</tr>
<tr>
<td>6</td>
<td>Emily Davis</td>
<td>emily@example.com</td>
<td>Finance</td>
<td>Analyst</td>
<td><span class="badge bg-success">Active</span></td>
</tr>
<tr>
<td>7</td>
<td>Chris Wilson</td>
<td>chris@example.com</td>
<td>Operations</td>
<td>Manager</td>
<td><span class="badge bg-success">Active</span></td>
</tr>
<tr>
<td>8</td>
<td>Lisa Anderson</td>
<td>lisa@example.com</td>
<td>HR</td>
<td>Recruiter</td>
<td><span class="badge bg-warning">On Leave</span></td>
</tr>
<tr>
<td>9</td>
<td>Tom Taylor</td>
<td>tom@example.com</td>
<td>Sales</td>
<td>Representative</td>
<td><span class="badge bg-success">Active</span></td>
</tr>
<tr>
<td>10</td>
<td>Amy Martinez</td>
<td>amy@example.com</td>
<td>Marketing</td>
<td>Director</td>
<td><span class="badge bg-success">Active</span></td>
</tr>
</tbody>
</tbody>
</table>
</div>
<nav aria-label="Page navigation">
<ul class="pagination justify-content-center" id="tablePagination">
<li class="page-item disabled">
<a class="page-link" href="#" tabindex="-1">Previous</a>
</li>
<li class="page-item active"><a class="page-link" href="#">1</a></li>
<li class="page-item"><a class="page-link" href="#">2</a></li>
<li class="page-item"><a class="page-link" href="#">3</a></li>
<li class="page-item">
<a class="page-link" href="#">Next</a>
</li>
</ul>
</nav>
</div>
</div>
</div>
<!-- Dynamic Content Tab -->
<div class="tab-pane fade" id="dynamic" role="tabpanel">
<div class="row">
<div class="col-md-6 mb-4">
<div class="card">
<div class="card-header">
<h5>Dynamic Content Loading</h5>
</div>
<div class="card-body">
<button class="btn btn-primary mb-3" id="loadContentBtn"
data-testid="load-content-button">
Load Content
</button>
<div id="dynamicContent" class="hidden-content"
data-testid="dynamic-content">
<!-- Content will be loaded here -->
</div>
</div>
</div>
</div>
<div class="col-md-6 mb-4">
<div class="card">
<div class="card-header">
<h5>Accordion Example</h5>
</div>
<div class="card-body">
<div class="accordion" id="testAccordion">
<div class="accordion-item">
<h2 class="accordion-header">
<button class="accordion-button" type="button" data-bs-toggle="collapse"
data-bs-target="#collapseOne" data-testid="accordion-button-1">
Accordion Item #1
</button>
</h2>
<div id="collapseOne" class="accordion-collapse collapse show"
data-bs-parent="#testAccordion">
<div class="accordion-body">
This is the first accordion item's content. It's shown by default.
</div>
</div>
</div>
<div class="accordion-item">
<h2 class="accordion-header">
<button class="accordion-button collapsed" type="button"
data-bs-toggle="collapse" data-bs-target="#collapseTwo"
data-testid="accordion-button-2">
Accordion Item #2
</button>
</h2>
<div id="collapseTwo" class="accordion-collapse collapse"
data-bs-parent="#testAccordion">
<div class="accordion-body">
This is the second accordion item's content.
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
<!-- Modal for testing -->
<div class="modal fade" id="testModal" tabindex="-1" aria-hidden="true">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title">Test Modal</h5>
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
</div>
<div class="modal-body">
<p>This is a test modal for automation testing.</p>
<form id="modalForm">
<div class="mb-3">
<label for="modalInput" class="form-label">Test Input</label>
<input type="text" class="form-control" id="modalInput"
data-testid="modal-input">
</div>
</form>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-secondary" data-bs-dismiss="modal">Close</button>
<button type="button" class="btn btn-primary" id="modalSaveBtn"
data-testid="modal-save-button">Save changes</button>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
<script src="https://cdnjs.cloudflare.com/ajax/libs/bootstrap/5.3.2/js/bootstrap.bundle.min.js"></script>
<script>
// Toast notification function
function showToast(message, type = 'success') {
const toastContainer = document.querySelector('.toast-container');
const toastHTML = `
<div class="toast align-items-center text-white bg-${type} border-0" role="alert" aria-live="assertive" aria-atomic="true">
<div class="d-flex">
<div class="toast-body">${message}</div>
<button type="button" class="btn-close btn-close-white me-2 m-auto" data-bs-dismiss="toast"></button>
</div>
</div>
`;
toastContainer.insertAdjacentHTML('beforeend', toastHTML);
const toast = toastContainer.lastElementChild;
const bsToast = new bootstrap.Toast(toast);
bsToast.show();
toast.addEventListener('hidden.bs.toast', () => toast.remove());
}
// Login Form Handler
document.getElementById('loginForm').addEventListener('submit', function(e) {
e.preventDefault();
// Form validation
const email = document.getElementById('email').value;
const password = document.getElementById('password').value;
if (!email.includes('@')) {
showToast('Please enter a valid email address', 'danger');
return;
}
if (password.length < 8) {
showToast('Password must be at least 8 characters long', 'danger');
return;
}
// Disable the login button and show spinner
const loginBtn = document.getElementById('loginBtn');
const loginSpinner = document.getElementById('loginSpinner');
const loadingOverlay = document.getElementById('loadingOverlay');
loginBtn.disabled = true;
loginSpinner.classList.remove('d-none');
// Hide login form
const loginSection = document.getElementById('loginSection');
loginSection.style.opacity = '0';
setTimeout(() => {
loginSection.classList.add('hidden');
loadingOverlay.classList.add('show');
// After 5 seconds, show the main content
setTimeout(() => {
loadingOverlay.classList.remove('show');
const mainContent = document.getElementById('mainContent');
mainContent.classList.add('visible');
// Reset login button state
loginBtn.disabled = false;
loginSpinner.classList.add('d-none');
// Show welcome toast
showToast(`Welcome ${email}!`);
}, 5000);
}, 300);
});
// Items Management
let items = [];
document.getElementById('addItemForm').addEventListener('submit', function(e) {
e.preventDefault();
const newItem = {
id: Date.now(),
name: document.getElementById('itemName').value,
category: document.getElementById('itemCategory').value,
price: parseFloat(document.getElementById('itemPrice').value),
quantity: parseInt(document.getElementById('itemQuantity').value)
};
items.push(newItem);
updateItemsTable();
this.reset();
showToast('Item added successfully');
});
function updateItemsTable() {
const tbody = document.querySelector('#itemsTable tbody');
tbody.innerHTML = '';
items.forEach(item => {
const row = `
<tr data-item-id="${item.id}">
<td>${item.name}</td>
<td>${item.category}</td>
<td>$${item.price.toFixed(2)}</td>
<td>${item.quantity}</td>
<td>
<button class="btn btn-sm btn-danger delete-item" data-testid="delete-item-${item.id}">
Delete
</button>
</td>
</tr>
`;
tbody.insertAdjacentHTML('beforeend', row);
});
}
// Item search functionality
document.getElementById('itemSearch').addEventListener('input', function(e) {
const searchTerm = e.target.value.toLowerCase();
const rows = document.querySelectorAll('#itemsTable tbody tr');
rows.forEach(row => {
const text = row.textContent.toLowerCase();
row.style.display = text.includes(searchTerm) ? '' : 'none';
});
});
document.getElementById('clearSearch').addEventListener('click', function() {
document.getElementById('itemSearch').value = '';
const rows = document.querySelectorAll('#itemsTable tbody tr');
rows.forEach(row => row.style.display = '');
});
// Drag and Drop Functionality
const draggables = document.querySelectorAll('.draggable');
const dropZone = document.getElementById('dropZone');
draggables.forEach(draggable => {
draggable.addEventListener('dragstart', () => {
draggable.classList.add('dragging');
});
draggable.addEventListener('dragend', () => {
draggable.classList.remove('dragging');
});
});
dropZone.addEventListener('dragover', e => {
e.preventDefault();
});
dropZone.addEventListener('drop', e => {
e.preventDefault();
const draggable = document.querySelector('.dragging');
const clone = draggable.cloneNode(true);
dropZone.appendChild(clone);
draggable.classList.remove('dragging');
showToast('Item dropped successfully');
});
// Dynamic Content Loading
document.getElementById('loadContentBtn').addEventListener('click', function() {
const content = document.getElementById('dynamicContent');
content.innerHTML = '<div class="spinner-border text-primary" role="status"></div>';
content.classList.remove('hidden-content');
setTimeout(() => {
content.innerHTML = `
<div class="alert alert-success">
Content loaded successfully!
</div>
<p>This is dynamically loaded content for testing purposes.</p>
`;
showToast('Content loaded successfully');
}, 2000);
});
// Delete item functionality
document.getElementById('itemsTable').addEventListener('click', function(e) {
if (e.target.classList.contains('delete-item')) {
const row = e.target.closest('tr');
const itemId = parseInt(row.dataset.itemId);
items = items.filter(item => item.id !== itemId);
row.remove();
showToast('Item deleted successfully');
}
});
// Modal handling
document.getElementById('modalSaveBtn').addEventListener('click', function() {
const modalInput = document.getElementById('modalInput').value;
if (modalInput) {
showToast('Modal data saved successfully');
const modal = bootstrap.Modal.getInstance(document.getElementById('testModal'));
modal.hide();
} else {
showToast('Please fill in the input field', 'danger');
}
});
// Show/Hide inactive employees
document.getElementById('showInactiveEmployees').addEventListener('change', function() {
const inactiveRows = document.querySelectorAll('tr:has(.badge-danger)');
inactiveRows.forEach(row => {
row.style.display = this.checked ? '' : 'none';
});
});
</script>
</body>
</html>