feat(ui): update ui style

This commit is contained in:
RhenCloud 2026-08-16 21:25:57 +08:00
parent ca6dfd3f64
commit 47d7c9105b
No known key found for this signature in database
GPG key ID: A574A617378C4E0B
35 changed files with 1577 additions and 591 deletions

View file

@ -1,4 +1,4 @@
import { describe, it, expect } from "bun:test";
import { describe, it, expect, beforeEach } from "bun:test";
import {
adminGroupRename,
adminGroupRoutesGet,
@ -6,7 +6,7 @@ import {
adminApiMe,
} from "../server/lib/web/admin";
import { createAdminSession, adminCookie } from "../server/lib/web/session";
import { loadGroups } from "../server/lib/web/groups";
import { loadGroups, invalidateGroupsCache } from "../server/lib/web/groups";
import { loadRoutes } from "../server/lib/config";
import { createInvite, listInvites } from "../server/lib/web/invites";
import { getTenantSecret, setTenantSecret } from "../server/lib/web/tenants";
@ -57,6 +57,8 @@ function createEnv(overrides: Partial<Env> = {}): Env {
}
describe("admin handlers (h3)", () => {
beforeEach(() => invalidateGroupsCache());
it("renames an owned group and follows routes, secret and invites", async () => {
const kv = createMockKV();
await kv.put(

View file

@ -13,6 +13,7 @@ import {
ensureInstallationGroup,
loadGroups,
saveGroups,
invalidateGroupsCache,
} from "../server/lib/web/groups";
import { validateGroups } from "../server/lib/web/admin";
import {
@ -97,6 +98,7 @@ describe("admin-session", () => {
beforeEach(() => {
kv = createMockKV();
invalidateGroupsCache();
});
it("creates and retrieves a session from cookie", async () => {

View file

@ -1,4 +1,4 @@
import { describe, it, expect } from "bun:test";
import { describe, it, expect, beforeEach } from "bun:test";
import { getDeliveryMetrics } from "../server/lib/observability/metrics";
import {
getSendLogByDelivery,
@ -7,6 +7,7 @@ import {
} from "../server/lib/lib/send-log";
import { adminApiMetrics, adminApiDelivery } from "../server/lib/web/admin";
import { createAdminSession, adminCookie } from "../server/lib/web/session";
import { invalidateGroupsCache } from "../server/lib/web/groups";
import { makeEvent, responseStatus } from "./helpers";
import type { Env } from "../server/lib/types";
@ -156,6 +157,7 @@ describe("delivery metrics", () => {
});
describe("admin metrics/delivery handlers", () => {
beforeEach(() => invalidateGroupsCache());
it("returns global metrics for super admins", async () => {
const kv = createMockKV();
const db = createMetricsDB({ "COUNT(*) AS total": [{ total: 5, ok: 4 }] });

View file

@ -2,6 +2,7 @@ import { describe, it, expect, beforeEach, afterEach } from "bun:test";
import { sendMessage } from "../server/lib/drivers/discord/rest";
import { renderNeutralMessage } from "../server/lib/drivers/discord/render";
import { dispatchEvent } from "../server/lib/core/dispatch";
import { invalidateGroupsCache } from "../server/lib/web/groups";
import type { Env, Route } from "../server/lib/types";
function mockFetch(handler: (url: string, init?: RequestInit) => Response): void {
@ -102,6 +103,7 @@ describe("discord role mentions", () => {
});
describe("dispatchEvent fallback routing", () => {
beforeEach(() => invalidateGroupsCache());
function createMockKV(): KVNamespace {
const store = new Map<string, string>();
return {

View file

@ -7,7 +7,7 @@ import {
handleTokenDelete,
} from "../server/lib/web/oauth";
import { createAdminSession, adminCookie } from "../server/lib/web/session";
import { loadGroups } from "../server/lib/web/groups";
import { loadGroups, invalidateGroupsCache } from "../server/lib/web/groups";
import { getInstallationAccount } from "../server/lib/github/oauth";
import { makeEvent, responseStatus, responseHeader } from "./helpers";
import type { Env } from "../server/lib/types";
@ -123,6 +123,7 @@ describe("GET /auth/github/install", () => {
const restoredFetch = globalThis.fetch;
beforeEach(() => {
invalidateGroupsCache();
globalThis.fetch = (input: RequestInfo | URL, init?: RequestInit): Promise<Response> => {
void init;
return Promise.resolve(
@ -195,6 +196,7 @@ describe("POST /auth/github/install/bind", () => {
const restoredFetch = globalThis.fetch;
beforeEach(() => {
invalidateGroupsCache();
globalThis.fetch = (input: RequestInfo | URL, init?: RequestInit): Promise<Response> => {
void init;
return Promise.resolve(

View file

@ -6,7 +6,7 @@ import {
revokeInvite,
acceptInvite,
} from "../server/lib/web/invites";
import { saveGroups, loadGroups } from "../server/lib/web/groups";
import { saveGroups, loadGroups, invalidateGroupsCache } from "../server/lib/web/groups";
import type { Group } from "../server/lib/types";
function createMockKV(): KVNamespace {
@ -49,6 +49,7 @@ describe("invites", () => {
beforeEach(() => {
kv = createMockKV();
invalidateGroupsCache();
});
it("creates and reads back an invite", async () => {

View file

@ -31,7 +31,7 @@ describe("kvMessageTracker", () => {
expect(await tracker.get("missing", "channel-1")).toBeNull();
});
it("uses the msg:{eventId}:{targetId} key with a 7-day TTL", async () => {
it("uses the msg:{eventId}:{targetId} key with a 24h TTL", async () => {
const kv = createMockKV();
const keys = new Map<string, string>();
const ttls = new Map<string, number>();
@ -46,7 +46,7 @@ describe("kvMessageTracker", () => {
const tracker = kvMessageTracker(kv);
await tracker.set("event-1", "target-1", "msg-7");
expect(keys.has("msg:event-1:target-1")).toBe(true);
expect(ttls.get("msg:event-1:target-1")).toBe(604800);
expect(ttls.get("msg:event-1:target-1")).toBe(86400);
});
it("deletes tracked entries", async () => {

View file

@ -1,6 +1,7 @@
import { describe, it, expect, beforeEach, mock } from "bun:test";
import { handleQueueBatch } from "../server/lib/queue/consumer";
import { invalidateConfigCache } from "../server/lib/config";
import { invalidateGroupsCache } from "../server/lib/web/groups";
import type { Env } from "../server/lib/types";
import type { DeliveryMessage, DispatchSummary } from "../server/lib/queue/delivery";
@ -86,6 +87,7 @@ const STATE_KEY = "delivery-state:github:global:d1";
describe("handleQueueBatch", () => {
beforeEach(() => {
invalidateConfigCache();
invalidateGroupsCache();
summary = { attempts: 0, failures: [] };
dispatchCalls = 0;
});

View file

@ -2,7 +2,7 @@ import { describe, it, expect, beforeEach, afterEach } from "bun:test";
import { createHmac } from "crypto";
import { processWebhook } from "../server/lib/webhook";
import { invalidateConfigCache } from "../server/lib/config";
import { loadGroups } from "../server/lib/web/groups";
import { invalidateGroupsCache, loadGroups } from "../server/lib/web/groups";
import type { Env, Route } from "../server/lib/types";
function githubSign(body: string, secret: string): string {
@ -70,6 +70,7 @@ describe("processWebhook", () => {
beforeEach(() => {
invalidateConfigCache();
invalidateGroupsCache();
});
/** waitUntil collector: lets the test await the dispatched work. */