feat(tests): add comprehensive benchmarks for database performance, memory usage, and application stability, including new test files for various frontend and backend functionalities

This commit is contained in:
2026-01-03 16:08:07 -06:00
parent e88dad7a86
commit 950abef79c
60 changed files with 8324 additions and 217 deletions

View File

@@ -0,0 +1,88 @@
import { mount } from "@vue/test-utils";
import { describe, it, expect, vi } from "vitest";
import MessagesSidebar from "@/components/messages/MessagesSidebar.vue";
describe("MessagesSidebar.vue", () => {
const defaultProps = {
peers: {},
conversations: [],
selectedDestinationHash: "",
isLoading: false,
};
const mountMessagesSidebar = (props = {}) => {
return mount(MessagesSidebar, {
props: { ...defaultProps, ...props },
global: {
mocks: {
$t: (key) => key,
},
stubs: {
MaterialDesignIcon: true,
},
},
});
};
it("handles long conversation names and message previews with truncation", () => {
const longName = "Very ".repeat(20) + "Long Name";
const longPreview = "Message ".repeat(50);
const conversations = [
{
destination_hash: "hash1",
display_name: longName,
latest_message_preview: longPreview,
updated_at: new Date().toISOString(),
},
];
const wrapper = mountMessagesSidebar({ conversations });
const nameElement = wrapper.find(".truncate");
expect(nameElement.exists()).toBe(true);
expect(nameElement.text()).toContain("Long Name");
const previewElement = wrapper.findAll(".truncate").find((el) => el.text().includes("Message"));
expect(previewElement.exists()).toBe(true);
});
it("handles a large number of conversations with scroll overflow", async () => {
const manyConversations = Array.from({ length: 100 }, (_, i) => ({
destination_hash: `hash${i}`,
display_name: `User ${i}`,
latest_message_preview: `Last message ${i}`,
updated_at: new Date().toISOString(),
}));
const wrapper = mountMessagesSidebar({ conversations: manyConversations });
const scrollContainer = wrapper.find(".overflow-y-auto");
expect(scrollContainer.exists()).toBe(true);
expect(scrollContainer.classes()).toContain("overflow-y-auto");
const conversationItems = wrapper.findAll("div.overflow-y-auto .cursor-pointer");
expect(conversationItems.length).toBe(100);
});
it("handles long peer names in the announces tab", async () => {
const longPeerName = "Peer ".repeat(20) + "Extreme Name";
const peers = {
peer1: {
destination_hash: "peer1",
display_name: longPeerName,
updated_at: new Date().toISOString(),
hops: 1,
},
};
const wrapper = mountMessagesSidebar({ peers });
// Switch to announces tab
await wrapper.find("div.cursor-pointer:last-child").trigger("click");
expect(wrapper.vm.tab).toBe("announces");
const peerNameElement = wrapper.find(".truncate");
expect(peerNameElement.exists()).toBe(true);
expect(peerNameElement.text()).toContain("Extreme Name");
});
});