feat: animate sidebar and refine account menu with Google avatars

This commit is contained in:
2026-11-06 00:28:13 +08:00
parent 71bf8b0f5e
commit f6315a6435
11 changed files with 430 additions and 108 deletions
+24 -8
View File
@@ -5,6 +5,10 @@ import { once } from "node:events";
import { fileURLToPath } from "node:url";
const host = "http://127.0.0.1:3005";
const graphs = new Map();
let mockProfile = {
id: "user", username: "test", display_name: "Test User", email: "test@example.com",
avatar_url: "https://lh3.googleusercontent.com/test-avatar=s96-c",
};
const upstream = createServer(async (req, res) => {
res.setHeader("Content-Type", "application/json");
if (req.url.endsWith("/auth/logout")) {
@@ -36,13 +40,13 @@ const upstream = createServer(async (req, res) => {
} else if (req.url.endsWith("/profile")) {
res.statusCode =
req.headers.authorization === "Bearer test-only-session" ? 200 : 401;
res.end(
JSON.stringify(
res.statusCode === 200
? { username: "test" }
: { error: "invalid_session" },
),
);
if (res.statusCode === 200 && req.method === "PATCH") {
let raw = "";
for await (const chunk of req) raw += chunk;
const input = JSON.parse(raw);
mockProfile = { ...mockProfile, username: input.username, display_name: input.display_name };
}
res.end(JSON.stringify(res.statusCode === 200 ? mockProfile : { error: "invalid_session" }));
} else {
res.statusCode = 404;
res.end("{}");
@@ -116,6 +120,18 @@ try {
200,
);
assert.equal((await fetch(host + "/api/foundry/profile")).status, 401);
const profile = await (await fetch(host + "/api/foundry/profile", { headers: { Cookie: session } })).json();
assert.equal(profile.avatar_url, "https://lh3.googleusercontent.com/test-avatar=s96-c");
const updated = await fetch(host + "/api/foundry/profile", {
method: "PATCH",
headers: { "Content-Type": "application/json", Cookie: session, Origin: host },
body: JSON.stringify({ username: "test", display_name: "Updated name" }),
});
assert.equal(updated.status, 200);
const updatedProfile = await updated.json();
assert.equal(updatedProfile.display_name, "Updated name");
assert.equal(updatedProfile.avatar_url, profile.avatar_url);
const create = await fetch(host + "/api/foundry/workspaces/space/materials", {
method: "POST",
headers: { "Content-Type": "application/json", Cookie: session, Origin: host },
@@ -179,7 +195,7 @@ try {
assert.equal(await logout.text(), "");
assert.match(logout.headers.get("set-cookie"), /Max-Age=0/);
console.log(
"PASS: App Router pages and metadata, body validation, method and query filtering, OAuth redirects, logout, session cookie, token removal, authenticated proxy, invalid session, cross-origin rejection, path allowlist, OAuth validation",
"PASS: avatar and profile updates, App Router pages and metadata, body validation, method and query filtering, OAuth redirects, logout, session cookie, token removal, authenticated proxy, invalid session, cross-origin rejection, path allowlist, OAuth validation",
);
} finally {
const exited = once(app, "exit");