feat: complete runtime and KAAK skin updates

This commit is contained in:
illusia committed 2026-10-12 23:06:55 +08:00
1 parent c994722016
commit 7fd1ea96fe
40 files changed
+3436 -1088

No files matched your search

+16 -4
View File
@@ -14,23 +14,23 @@ before(async () => {
});
after(async () => { await vite?.close(); });
function mount(t) {
const scope = effectScope(), errors = ref(""), message = ref(""), switched = ref(""), connected = ref(false), calls = [], connectCalls = [];
const scope = effectScope(), errors = ref(""), message = ref(""), switched = ref(""), connected = ref(false), connecting = ref(false), calls = [], connectCalls = [], disconnectCalls = [], toasts = [];
const dialog = reactive({ open: true, channelId: "2", password: "draft", error: "", submitting: false });
const serverPasswordDialog = reactive({ open: false, password: "", errorCode: "" });
const serverHost = ref("fixture.invalid"), serverPort = ref("9987");
const connection = scope.run(() => useWebClientConnection({
initialized: ref(true), accessMode: ref("fixed"), isConnecting: ref(false), isConnected: connected, errorCode: errors,
initialized: ref(true), accessMode: ref("fixed"), isConnecting: connecting, isConnected: connected, errorCode: errors,
errorMessage: message, channelSwitchedChannelId: switched,
nickname: ref("Preview"), channelName: ref("Room"), serverHost, serverPort,
serverPassword: ref(""), rememberIdentity: ref(false), identityMaterial: ref(""), accelerationRelayId: ref(""),
inviteToken: "", selectedChannelId: ref("2"), channels: ref([]), clientId: ref(1),
channelPasswordDialog: dialog, serverPasswordDialog,
chatTab: ref("channel"), switchChannel: (...args) => calls.push(args),
connect: (...args) => connectCalls.push(args), disconnect() {}, saveNickname() {}, showToast() {},
connect: (...args) => connectCalls.push(args), disconnect() { disconnectCalls.push(true); connecting.value = false; }, saveNickname() {}, showToast: message => toasts.push(message),
clearError: () => { errors.value = ""; message.value = ""; }, t: key => key,
}));
t.after(() => scope.stop());
return { dialog, serverPasswordDialog, connection, errors, message, switched, calls, connectCalls, connected, serverHost, serverPort };
return { dialog, serverPasswordDialog, connection, errors, message, switched, calls, connectCalls, disconnectCalls, toasts, connecting, connected, serverHost, serverPort };
}
test("pasting a nickname clears the prefilled port and preserves a custom override", t => {
@@ -86,6 +86,18 @@ test("a server-password retry proceeds when browser storage is unavailable", asy
// IndexedDB is unavailable in this test runtime, so persistence is a no-op.
});
test("a pending server connection can be cancelled without showing the leave-room toast", t => {
const { connection, connecting, disconnectCalls, toasts, dialog } = mount(t);
connecting.value = true;
dialog.open = false;
connection.doDisconnect(false);
assert.deepEqual(disconnectCalls, [true]);
assert.equal(connecting.value, false);
assert.deepEqual(toasts, []);
});
test("channel selection falls back to the normal switch when no local password exists", async t => {
const { connection, calls } = mount(t);
connection.selectChannel({ id: "42", name: "Locked room", members: [] });