183 lines
5.6 KiB
HTML
183 lines
5.6 KiB
HTML
<!DOCTYPE html>
|
|
<html lang="en">
|
|
<head>
|
|
<meta charset="UTF-8" />
|
|
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
|
<title>Logout Fix Test - Sky Art Shop</title>
|
|
<link
|
|
href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/css/bootstrap.min.css"
|
|
rel="stylesheet"
|
|
/>
|
|
<link
|
|
rel="stylesheet"
|
|
href="https://cdn.jsdelivr.net/npm/bootstrap-icons@1.11.3/font/bootstrap-icons.min.css"
|
|
/>
|
|
<style>
|
|
body {
|
|
padding: 20px;
|
|
font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
|
|
sans-serif;
|
|
}
|
|
.test-section {
|
|
margin: 20px 0;
|
|
padding: 20px;
|
|
border: 1px solid #ddd;
|
|
border-radius: 8px;
|
|
}
|
|
.btn-logout {
|
|
background: #dc3545;
|
|
color: white;
|
|
border: none;
|
|
padding: 10px 20px;
|
|
border-radius: 5px;
|
|
cursor: pointer;
|
|
}
|
|
.btn-logout:hover {
|
|
background: #c82333;
|
|
}
|
|
.log-output {
|
|
background: #f8f9fa;
|
|
padding: 15px;
|
|
border-radius: 5px;
|
|
margin-top: 10px;
|
|
max-height: 300px;
|
|
overflow-y: auto;
|
|
font-family: monospace;
|
|
font-size: 12px;
|
|
}
|
|
.log-entry {
|
|
margin: 5px 0;
|
|
padding: 5px;
|
|
border-left: 3px solid #007bff;
|
|
padding-left: 10px;
|
|
}
|
|
.log-success {
|
|
border-left-color: #28a745;
|
|
}
|
|
.log-error {
|
|
border-left-color: #dc3545;
|
|
}
|
|
</style>
|
|
</head>
|
|
<body>
|
|
<div class="container">
|
|
<h1>🔍 Logout Fix Verification Test</h1>
|
|
<p class="text-muted">
|
|
This page tests that the logout confirmation dialog appears correctly.
|
|
</p>
|
|
|
|
<div class="test-section">
|
|
<h3>Test 1: Dashboard-style Button (onclick via event listener)</h3>
|
|
<p>This simulates how the dashboard logout button works:</p>
|
|
<button class="btn-logout" id="logoutBtn">
|
|
<i class="bi bi-box-arrow-right"></i> Logout (Dashboard Style)
|
|
</button>
|
|
</div>
|
|
|
|
<div class="test-section">
|
|
<h3>Test 2: Other Pages-style Button (inline onclick)</h3>
|
|
<p>
|
|
This simulates how other pages (settings, blog, etc.) logout buttons
|
|
work:
|
|
</p>
|
|
<button class="btn-logout" onclick="logout()">
|
|
<i class="bi bi-box-arrow-right"></i> Logout (Inline onclick)
|
|
</button>
|
|
</div>
|
|
|
|
<div class="test-section">
|
|
<h3>Test 3: Direct window.logout() Call</h3>
|
|
<p>This tests the global logout function directly:</p>
|
|
<button class="btn btn-warning" onclick="window.logout()">
|
|
<i class="bi bi-box-arrow-right"></i> Test window.logout()
|
|
</button>
|
|
</div>
|
|
|
|
<div class="test-section">
|
|
<h3>Expected Behavior</h3>
|
|
<ul>
|
|
<li>✅ All buttons should show the same confirmation dialog</li>
|
|
<li>✅ Dialog should say "Confirm Logout"</li>
|
|
<li>✅ Dialog should have "Cancel" and "Logout" buttons</li>
|
|
<li>✅ Cancel should close the dialog without logging out</li>
|
|
<li>
|
|
✅ Logout should proceed (for this test, it will redirect to login)
|
|
</li>
|
|
</ul>
|
|
</div>
|
|
|
|
<div class="test-section">
|
|
<h3>Test Log</h3>
|
|
<div class="log-output" id="logOutput"></div>
|
|
<button class="btn btn-secondary btn-sm mt-2" onclick="clearLog()">
|
|
Clear Log
|
|
</button>
|
|
</div>
|
|
</div>
|
|
|
|
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/js/bootstrap.bundle.min.js"></script>
|
|
<script src="/admin/js/auth.js"></script>
|
|
<script>
|
|
// Test logging
|
|
function addLog(message, type = "info") {
|
|
const logOutput = document.getElementById("logOutput");
|
|
const entry = document.createElement("div");
|
|
entry.className = `log-entry ${
|
|
type === "success"
|
|
? "log-success"
|
|
: type === "error"
|
|
? "log-error"
|
|
: ""
|
|
}`;
|
|
entry.textContent = `[${new Date().toLocaleTimeString()}] ${message}`;
|
|
logOutput.appendChild(entry);
|
|
logOutput.scrollTop = logOutput.scrollHeight;
|
|
}
|
|
|
|
function clearLog() {
|
|
document.getElementById("logOutput").innerHTML = "";
|
|
}
|
|
|
|
// Override performLogout to prevent actual logout during testing
|
|
const originalPerformLogout = window.performLogout;
|
|
if (typeof performLogout !== "undefined") {
|
|
window.performLogout = async function () {
|
|
addLog(
|
|
"✅ Logout confirmed! (Redirect disabled for testing)",
|
|
"success"
|
|
);
|
|
console.log("Logout would execute here");
|
|
};
|
|
}
|
|
|
|
// Monitor logout function calls
|
|
const originalLogout = window.logout;
|
|
window.logout = function (skipConfirm) {
|
|
addLog(`🔵 logout() called with skipConfirm=${skipConfirm}`);
|
|
if (originalLogout) {
|
|
return originalLogout(skipConfirm);
|
|
}
|
|
};
|
|
|
|
// Page loaded
|
|
document.addEventListener("DOMContentLoaded", function () {
|
|
addLog("✅ Page loaded successfully");
|
|
addLog(
|
|
`✅ window.logout exists: ${typeof window.logout === "function"}`
|
|
);
|
|
addLog(
|
|
`✅ window.showLogoutConfirm exists: ${
|
|
typeof window.showLogoutConfirm === "function"
|
|
}`
|
|
);
|
|
|
|
// Test that auth.js event listeners are attached
|
|
const logoutBtn = document.getElementById("logoutBtn");
|
|
if (logoutBtn) {
|
|
addLog("✅ Dashboard-style logout button found and ready");
|
|
}
|
|
});
|
|
</script>
|
|
</body>
|
|
</html>
|