mirror of
https://git.quad4.io/RNS-Things/MeshChatX.git
synced 2026-05-30 13:04:00 +00:00
refactor(tests): update test selectors
This commit is contained in:
@@ -62,8 +62,10 @@ describe("BotsPage.vue", () => {
|
||||
const wrapper = mountBotsPage();
|
||||
await vi.waitFor(() => expect(wrapper.vm.loading).toBe(false));
|
||||
|
||||
const templateCard = wrapper.find(".glass-card[class*='cursor-pointer']");
|
||||
await templateCard.trigger("click");
|
||||
const selectBtn = wrapper
|
||||
.findAll("button")
|
||||
.find((b) => b.text().includes("bots.select"));
|
||||
await selectBtn.trigger("click");
|
||||
|
||||
expect(wrapper.vm.selectedTemplate).not.toBeNull();
|
||||
expect(wrapper.text()).toContain("bots.start_bot: Echo Bot");
|
||||
|
||||
@@ -37,14 +37,14 @@ describe("Interface.vue", () => {
|
||||
|
||||
it("emits disable when Disable button is clicked", async () => {
|
||||
const wrapper = mountInterface();
|
||||
const disableBtn = wrapper.find("button.secondary-chip");
|
||||
const disableBtn = wrapper.find('button[title="interface.disable"]');
|
||||
await disableBtn.trigger("click");
|
||||
expect(wrapper.emitted("disable")).toHaveLength(1);
|
||||
});
|
||||
|
||||
it("emits enable when Enable button is clicked for disabled interface", async () => {
|
||||
const wrapper = mountInterface({ enabled: false });
|
||||
const enableBtn = wrapper.find("button.primary-chip");
|
||||
const enableBtn = wrapper.find('button[title="interface.enable"]');
|
||||
await enableBtn.trigger("click");
|
||||
expect(wrapper.emitted("enable")).toHaveLength(1);
|
||||
});
|
||||
@@ -93,9 +93,11 @@ describe("Interface.vue", () => {
|
||||
|
||||
it("action buttons and dropdown have shrink-0 to prevent squashing", () => {
|
||||
const wrapper = mountInterface();
|
||||
const actionsCol = wrapper.find(".flex.flex-col.sm\\:flex-row.gap-2");
|
||||
const actionsCol = wrapper.find(
|
||||
".absolute.top-2.right-2.z-20.flex.flex-row.items-center.gap-1.sm\\:static",
|
||||
);
|
||||
expect(actionsCol.classes()).toContain("sm:shrink-0");
|
||||
const btn = wrapper.find("button.secondary-chip");
|
||||
const btn = wrapper.find('button[title="interface.disable"]');
|
||||
expect(btn.classes()).toContain("shrink-0");
|
||||
});
|
||||
|
||||
|
||||
@@ -21,6 +21,7 @@ describe("ToolsPage.vue", () => {
|
||||
{ path: "/paper-message", name: "paper-message", component: { template: "div" } },
|
||||
{ path: "/rnode-flasher", name: "rnode-flasher", component: { template: "div" } },
|
||||
{ path: "/debug-logs", name: "debug-logs", component: { template: "div" } },
|
||||
{ path: "/mesh-server", name: "mesh-server", component: { template: "div" } },
|
||||
],
|
||||
});
|
||||
|
||||
@@ -47,11 +48,10 @@ describe("ToolsPage.vue", () => {
|
||||
expect(wrapper.text()).toContain("tools.power_tools");
|
||||
});
|
||||
|
||||
it("renders all tool cards", () => {
|
||||
it("renders all tool rows", () => {
|
||||
const wrapper = mountToolsPage();
|
||||
const toolCards = wrapper.findAll(".tool-card");
|
||||
// tools count in ToolsPage.vue is 17 (including coming soon ones)
|
||||
expect(toolCards.length).toBe(17);
|
||||
const toolRows = wrapper.findAll(".tool-row");
|
||||
expect(toolRows.length).toBe(17);
|
||||
});
|
||||
|
||||
it("filters tools based on search query", async () => {
|
||||
|
||||
@@ -485,7 +485,7 @@ describe("Visibility Checks", () => {
|
||||
await wrapper.vm.$nextTick();
|
||||
|
||||
const colorInputs = wrapper.findAll('input[type="color"]');
|
||||
expect(colorInputs.length).toBe(3);
|
||||
expect(colorInputs.length).toBe(2);
|
||||
|
||||
delete window.api;
|
||||
});
|
||||
|
||||
@@ -245,7 +245,7 @@ describe("NetworkVisualiser Optimization and Abort", () => {
|
||||
expect(end - start).toBeLessThan(100); // Should be very fast
|
||||
});
|
||||
|
||||
it("performance: icon cache hit vs miss for 500 nodes", async () => {
|
||||
it("reuses one cached icon for 500 nodes with identical lxmf_user_icon", async () => {
|
||||
vi.spyOn(NetworkVisualiser.methods, "init").mockImplementation(() => {});
|
||||
const wrapper = mountVisualiser();
|
||||
|
||||
@@ -266,30 +266,21 @@ describe("NetworkVisualiser Optimization and Abort", () => {
|
||||
return acc;
|
||||
}, {});
|
||||
|
||||
// Mock createIconImage to have some delay for the "miss" case
|
||||
wrapper.vm.createIconImage = vi.fn().mockImplementation(async () => {
|
||||
// Add a tiny delay to ensure "miss" is always measurable
|
||||
wrapper.vm.createIconImage = vi.fn(async function (iconName, foregroundColor, backgroundColor, size = 64) {
|
||||
const cacheKey = `${iconName}-${foregroundColor}-${backgroundColor}-${size}`;
|
||||
if (this.iconCache[cacheKey]) {
|
||||
return this.iconCache[cacheKey];
|
||||
}
|
||||
await new Promise((r) => setTimeout(r, 0));
|
||||
return "blob:mock-icon";
|
||||
const url = "blob:mock-icon";
|
||||
this.iconCache[cacheKey] = url;
|
||||
return url;
|
||||
});
|
||||
|
||||
const startMiss = performance.now();
|
||||
await wrapper.vm.processVisualization();
|
||||
const endMiss = performance.now();
|
||||
const missTime = endMiss - startMiss;
|
||||
expect(wrapper.vm.createIconImage).toHaveBeenCalledTimes(1);
|
||||
|
||||
// Second run will hit the cache check in processVisualization
|
||||
// so it won't even call createIconImage.
|
||||
const startHit = performance.now();
|
||||
await wrapper.vm.processVisualization();
|
||||
const endHit = performance.now();
|
||||
const hitTime = endHit - startHit;
|
||||
|
||||
console.log(`Icon cache MISS for 500 nodes: ${missTime.toFixed(2)}ms`);
|
||||
console.log(`Icon cache HIT for 500 nodes: ${hitTime.toFixed(2)}ms`);
|
||||
|
||||
// Cache hit should be significantly faster, but we allow for some
|
||||
// environmental noise in CI environments.
|
||||
expect(hitTime).toBeLessThan(missTime + 200);
|
||||
expect(wrapper.vm.createIconImage).toHaveBeenCalledTimes(1);
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user