mirror of
https://github.com/Termix-SSH/Termix.git
synced 2026-10-29 14:45:24 +00:00
fix: finish 2.9.0 plugin moves and get every check green
This commit is contained in:
1 parent
8c1e02af89
commit
6489b62ece
335 files changed
+29878
-17749
No files matched your search
@@ -0,0 +1,57 @@
|
||||
import { afterEach, describe, expect, it } from "vitest";
|
||||
import {
|
||||
clearTransferProfiles,
|
||||
flushTransferProfiles,
|
||||
getTransferProfile,
|
||||
initializeTransferProfiles,
|
||||
recordTransferProfile,
|
||||
setTransferProfileStore,
|
||||
type PersistedProfiles,
|
||||
} from "../../src/backend/transfer-tuning.js";
|
||||
|
||||
afterEach(() => {
|
||||
setTransferProfileStore(null);
|
||||
clearTransferProfiles();
|
||||
});
|
||||
|
||||
function memoryStore() {
|
||||
let saved: PersistedProfiles | undefined;
|
||||
return {
|
||||
store: {
|
||||
read: async () => saved,
|
||||
write: async (value: PersistedProfiles) => {
|
||||
saved = JSON.parse(JSON.stringify(value));
|
||||
},
|
||||
},
|
||||
saved: () => saved,
|
||||
};
|
||||
}
|
||||
|
||||
describe("transfer profile store", () => {
|
||||
it("saves learned profiles and reads them back after a restart", async () => {
|
||||
const memory = memoryStore();
|
||||
setTransferProfileStore(memory.store);
|
||||
await initializeTransferProfiles();
|
||||
|
||||
recordTransferProfile("host-a:host-b", {
|
||||
bytes: 50 * 1024 * 1024,
|
||||
durationMs: 5000,
|
||||
lanes: 4,
|
||||
pipelineConcurrency: 8,
|
||||
failed: false,
|
||||
now: Date.now(),
|
||||
});
|
||||
await flushTransferProfiles();
|
||||
expect(Object.keys(memory.saved()?.profiles ?? {})).toHaveLength(1);
|
||||
|
||||
// A fresh activation starts from what the store holds.
|
||||
setTransferProfileStore(memory.store);
|
||||
await initializeTransferProfiles();
|
||||
expect(getTransferProfile("host-a:host-b")).toBeDefined();
|
||||
});
|
||||
|
||||
it("works without a store", async () => {
|
||||
await initializeTransferProfiles();
|
||||
expect(getTransferProfile("nothing")).toBeUndefined();
|
||||
});
|
||||
});
|
||||
@@ -59,17 +59,19 @@ beforeEach(() => {
|
||||
id: 1,
|
||||
name: "prod",
|
||||
ip: "10.0.0.1",
|
||||
enableFileManager: true,
|
||||
connectionType: "ssh",
|
||||
defaultPath: "/srv",
|
||||
pluginSettings: {
|
||||
"file-manager": { enableFileManager: true, defaultPath: "/srv" },
|
||||
},
|
||||
},
|
||||
{
|
||||
id: 2,
|
||||
name: "backup",
|
||||
ip: "10.0.0.2",
|
||||
enableFileManager: true,
|
||||
connectionType: "ssh",
|
||||
defaultPath: "/srv",
|
||||
pluginSettings: {
|
||||
"file-manager": { enableFileManager: true, defaultPath: "/srv" },
|
||||
},
|
||||
},
|
||||
]);
|
||||
api.ensureSSHSessionForHost.mockImplementation(async (host) => ({
|
||||
|
||||
@@ -52,9 +52,9 @@ describe(`${manifest.id} activate`, () => {
|
||||
);
|
||||
});
|
||||
|
||||
it("registers the files host editor section", async () => {
|
||||
it("leaves its host fields to the schema-driven Plugins tab", async () => {
|
||||
rendered = await renderWithApp(plugin, { manifest, locales });
|
||||
expect(rendered.registered.hostEditorSections()).toContain("files");
|
||||
expect(rendered.registered.hostEditorSections()).toEqual([]);
|
||||
});
|
||||
|
||||
it("registers files.openHost and files.openEditor actions", async () => {
|
||||
|
||||
@@ -8,7 +8,7 @@ vi.mock("sonner", () => ({
|
||||
}));
|
||||
|
||||
vi.mock("@/main-axios.ts", () => ({}));
|
||||
vi.mock("../../../features/file-manager/transferNotificationStore.ts", () => ({
|
||||
vi.mock("../../src/frontend/transferNotificationStore.ts", () => ({
|
||||
markTransferNotified: vi.fn(),
|
||||
}));
|
||||
|
||||
|
||||
Reference in new issue
Block a user