test(frontend): add vitest test suite and apply code formatting
This commit is contained in:
1 parent
e4ffa0b356
commit
6632df0bc7
23 files changed
+2209
-815
No files matched your search
@@ -1,67 +1,65 @@
|
||||
<!doctype html>
|
||||
<html lang="en">
|
||||
|
||||
<head>
|
||||
<head>
|
||||
<meta charset="UTF-8" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
<title>Linear Void Admin Login</title>
|
||||
<link rel="stylesheet" href="../../src/style.css" />
|
||||
</head>
|
||||
</head>
|
||||
|
||||
<body class="auth-body">
|
||||
<body class="auth-body">
|
||||
<main class="auth-shell" aria-label="Admin authentication">
|
||||
<section class="auth-card" aria-labelledby="auth-title">
|
||||
<p class="auth-kicker">Linear Void</p>
|
||||
<h1 id="auth-title">Admin Login</h1>
|
||||
<p class="auth-subtitle">Authenticate to access protected admin controls.</p>
|
||||
<section class="auth-card" aria-labelledby="auth-title">
|
||||
<p class="auth-kicker">Linear Void</p>
|
||||
<h1 id="auth-title">Admin Login</h1>
|
||||
<p class="auth-subtitle">Authenticate to access protected admin controls.</p>
|
||||
|
||||
<form id="login-form" class="form-stack" novalidate>
|
||||
<label for="username">Username</label>
|
||||
<input id="username" type="text" class="text-input" autocomplete="username" required />
|
||||
<form id="login-form" class="form-stack" novalidate>
|
||||
<label for="username">Username</label>
|
||||
<input id="username" type="text" class="text-input" autocomplete="username" required />
|
||||
|
||||
<label for="password">Password</label>
|
||||
<input id="password" type="password" class="text-input" autocomplete="current-password" required />
|
||||
<label for="password">Password</label>
|
||||
<input id="password" type="password" class="text-input" autocomplete="current-password" required />
|
||||
|
||||
<button id="submit" type="submit" class="btn btn-primary btn-block">Sign in</button>
|
||||
<p id="status" class="status-line" aria-live="polite"></p>
|
||||
</form>
|
||||
</section>
|
||||
<button id="submit" type="submit" class="btn btn-primary btn-block">Sign in</button>
|
||||
<p id="status" class="status-line" aria-live="polite"></p>
|
||||
</form>
|
||||
</section>
|
||||
</main>
|
||||
|
||||
<script>
|
||||
const form = document.getElementById('login-form');
|
||||
const username = document.getElementById('username');
|
||||
const password = document.getElementById('password');
|
||||
const submit = document.getElementById('submit');
|
||||
const status = document.getElementById('status');
|
||||
const form = document.getElementById("login-form");
|
||||
const username = document.getElementById("username");
|
||||
const password = document.getElementById("password");
|
||||
const submit = document.getElementById("submit");
|
||||
const status = document.getElementById("status");
|
||||
|
||||
form.addEventListener('submit', async (event) => {
|
||||
event.preventDefault();
|
||||
submit.disabled = true;
|
||||
status.textContent = 'Signing in...';
|
||||
status.className = 'status-line';
|
||||
form.addEventListener("submit", async (event) => {
|
||||
event.preventDefault();
|
||||
submit.disabled = true;
|
||||
status.textContent = "Signing in...";
|
||||
status.className = "status-line";
|
||||
|
||||
try {
|
||||
const response = await fetch('/api/admin/login', {
|
||||
method: 'POST',
|
||||
headers: { 'Content-Type': 'application/json' },
|
||||
body: JSON.stringify({ username: username.value, password: password.value })
|
||||
});
|
||||
try {
|
||||
const response = await fetch("/api/admin/login", {
|
||||
method: "POST",
|
||||
headers: { "Content-Type": "application/json" },
|
||||
body: JSON.stringify({ username: username.value, password: password.value }),
|
||||
});
|
||||
|
||||
if (!response.ok) {
|
||||
throw new Error(`HTTP ${response.status}`);
|
||||
}
|
||||
if (!response.ok) {
|
||||
throw new Error(`HTTP ${response.status}`);
|
||||
}
|
||||
|
||||
window.location.href = '/admin/';
|
||||
} catch (error) {
|
||||
console.error('Failed to sign in', error);
|
||||
status.textContent = 'Login failed. Check your credentials.';
|
||||
status.className = 'status-line status-error';
|
||||
} finally {
|
||||
submit.disabled = false;
|
||||
}
|
||||
});
|
||||
window.location.href = "/admin/";
|
||||
} catch (error) {
|
||||
console.error("Failed to sign in", error);
|
||||
status.textContent = "Login failed. Check your credentials.";
|
||||
status.className = "status-line status-error";
|
||||
} finally {
|
||||
submit.disabled = false;
|
||||
}
|
||||
});
|
||||
</script>
|
||||
</body>
|
||||
|
||||
</html>
|
||||
</body>
|
||||
</html>
|
||||
Reference in new issue
Block a user