mirror of
https://github.com/EchoSixHIYA/WebSpeak-client-for-TeamSpeak.git
synced 2026-12-03 20:12:52 +08:00
feat: complete runtime and KAAK skin updates
This commit is contained in:
1 parent
c994722016
commit
7fd1ea96fe
40 files changed
+3436
-1088
No files matched your search
@@ -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: [] });
|
||||
|
||||
@@ -414,6 +414,40 @@ test("own messages and conversation switches reveal the latest message, unrelate
|
||||
assert.equal(chat.listElement.value.scrollTop, 800);
|
||||
});
|
||||
|
||||
test("chat history stays scoped to its channel, server, or private conversation", async t => {
|
||||
const socket = await connect();
|
||||
socket.receive({ type: "connected", tsClientId: 1, members: [{ id: 7, uid: "alice", nickname: "Alice" }] });
|
||||
const chat = chatView(t, { currentChannel: ref(undefined) });
|
||||
voice.chatMessages.push(
|
||||
{ id: "history-channel-current", scope: "channel", targetId: "1", invokerName: "Alice", message: "Current room", timestamp: 1, isHistory: true },
|
||||
{ id: "history-channel-other", scope: "channel", targetId: "2", invokerName: "Alice", message: "Other room", timestamp: 2, isHistory: true },
|
||||
{ id: "history-channel-legacy", scope: "channel", invokerName: "Alice", message: "Legacy room message", timestamp: 3, isHistory: true },
|
||||
{ id: "history-server", scope: "server", invokerName: "Alice", message: "Server message", timestamp: 4, isHistory: true },
|
||||
{ id: "history-private", scope: "private", conversationId: "7", conversationKey: "uid:alice", conversationName: "Alice", invokerName: "Alice", message: "Private message", timestamp: 5, isHistory: true },
|
||||
);
|
||||
|
||||
assert.deepEqual(chat.visibleMessages.value.map(message => message.id), ["history-channel-current", "history-channel-legacy"]);
|
||||
chat.tab.value = "server";
|
||||
assert.deepEqual(chat.visibleMessages.value.map(message => message.id), ["history-server"]);
|
||||
chat.openPrivateChat(7);
|
||||
assert.deepEqual(chat.visibleMessages.value.map(message => message.id), ["history-private"]);
|
||||
assert.equal(chat.conversations.value[0].name, "Alice");
|
||||
});
|
||||
|
||||
test("opening a first private chat creates its tab and expands a collapsed chat panel", async t => {
|
||||
const socket = await connect();
|
||||
socket.receive({ type: "connected", tsClientId: 1, members: [{ id: 7, uid: "alice", nickname: "Alice" }] });
|
||||
const chat = chatView(t);
|
||||
chat.togglePanel();
|
||||
assert.equal(chat.panelOpen.value, false);
|
||||
|
||||
chat.openPrivateChat(7);
|
||||
assert.equal(chat.tab.value, "private");
|
||||
assert.equal(chat.panelOpen.value, true);
|
||||
assert.deepEqual(chat.conversations.value.map(conversation => conversation.name), ["Alice"]);
|
||||
assert.equal(chat.visibleMessages.value.length, 0, "a new conversation still renders its empty state");
|
||||
});
|
||||
|
||||
test("hidden mobile chat defers scrolling until shown and ignores zero-height scroll events", async t => {
|
||||
const section = ref("voice");
|
||||
const chat = chatView(t, { isMobileViewport: ref(true), mobileSection: section });
|
||||
@@ -2442,3 +2476,76 @@ test("voice STUN configuration reaches the browser peer and resets on a legacy c
|
||||
await nextTurn();
|
||||
assert.deepEqual(TestPeer.instances.at(-1).config.iceServers, []);
|
||||
});
|
||||
|
||||
test("connecting restores browser-local chat history before it is displayed", async t => {
|
||||
let queriedServerKey = "";
|
||||
const records = [
|
||||
{ id: "channel-current", serverKey: "history.example:9987", conversationKey: "channel:1", messages: [
|
||||
{ id: "saved-channel", scope: "channel", targetId: "1", invokerName: "Alice", message: "Saved channel message", timestamp: 1 },
|
||||
] },
|
||||
{ id: "channel-other", serverKey: "history.example:9987", conversationKey: "channel:2", messages: [
|
||||
{ id: "other-channel", scope: "channel", targetId: "2", invokerName: "Alice", message: "Other channel", timestamp: 2 },
|
||||
] },
|
||||
{ id: "server", serverKey: "history.example:9987", conversationKey: "server", messages: [
|
||||
{ id: "saved-server", scope: "server", invokerName: "Alice", message: "Saved server message", timestamp: 3 },
|
||||
] },
|
||||
{ id: "private", serverKey: "history.example:9987", conversationKey: "private:uid:alice", messages: [
|
||||
{ id: "saved-private", scope: "private", conversationId: "7", conversationKey: "uid:alice", conversationName: "Alice", invokerName: "Alice", message: "Saved private message", timestamp: 4 },
|
||||
] },
|
||||
];
|
||||
const descriptor = Object.getOwnPropertyDescriptor(globalThis, "indexedDB");
|
||||
const database = {
|
||||
onversionchange: undefined,
|
||||
close() {},
|
||||
transaction() {
|
||||
const transaction = { oncomplete: undefined };
|
||||
return Object.assign(transaction, {
|
||||
objectStore() {
|
||||
return {
|
||||
index() {
|
||||
return {
|
||||
getAll(serverKey) {
|
||||
queriedServerKey = serverKey;
|
||||
const request = {};
|
||||
queueMicrotask(() => {
|
||||
request.result = records.filter(record => record.serverKey === serverKey);
|
||||
request.onsuccess?.();
|
||||
transaction.oncomplete?.();
|
||||
});
|
||||
return request;
|
||||
},
|
||||
};
|
||||
},
|
||||
};
|
||||
},
|
||||
});
|
||||
},
|
||||
};
|
||||
Object.defineProperty(globalThis, "indexedDB", {
|
||||
configurable: true,
|
||||
value: { open: () => {
|
||||
const request = { result: database };
|
||||
queueMicrotask(() => request.onsuccess?.());
|
||||
return request;
|
||||
} },
|
||||
});
|
||||
t.after(() => {
|
||||
if (descriptor) Object.defineProperty(globalThis, "indexedDB", descriptor);
|
||||
else Reflect.deleteProperty(globalThis, "indexedDB");
|
||||
});
|
||||
|
||||
const chat = chatView(t, { serverKey: ref("history.example:9987") });
|
||||
const socket = await connect();
|
||||
socket.receive({ type: "connected", tsClientId: 1, members: [{ id: 7, uid: "alice", nickname: "Alice" }] });
|
||||
await nextTurn();
|
||||
await nextTick();
|
||||
|
||||
assert.equal(queriedServerKey, "history.example:9987");
|
||||
assert.deepEqual(voice.chatMessages.map(message => message.id), ["saved-channel", "other-channel", "saved-server", "saved-private"]);
|
||||
assert.ok(voice.chatMessages.every(message => message.isHistory), "restored messages are marked so they are not written back as new traffic");
|
||||
assert.deepEqual(chat.visibleMessages.value.map(message => message.id), ["saved-channel"]);
|
||||
chat.tab.value = "server";
|
||||
assert.deepEqual(chat.visibleMessages.value.map(message => message.id), ["saved-server"]);
|
||||
chat.openPrivateChat(7);
|
||||
assert.deepEqual(chat.visibleMessages.value.map(message => message.id), ["saved-private"]);
|
||||
});
|
||||
Reference in new issue
Block a user