feat:Update pnpm-lock.yaml to link shared package; modify API routes to utilize new schemas for domain and service management; enhance DNS record handling with CNAME support; refactor service and subdomain routes for improved functionality; implement confirm dialog for domain deletion in the frontend; clean up unused components and improve UI consistency.
Build, Test, and Push CFDM Docker Image / test (push) Failing after 51s
Build, Test, and Push CFDM Docker Image / build-and-push (push) Has been skipped
Build, Test, and Push CFDM Docker Image / update-wiki (push) Has been skipped
Build, Test, and Push CFDM Docker Image / create-release (push) Has been skipped
Build, Test, and Push CFDM Docker Image / test (push) Failing after 51s
Build, Test, and Push CFDM Docker Image / build-and-push (push) Has been skipped
Build, Test, and Push CFDM Docker Image / update-wiki (push) Has been skipped
Build, Test, and Push CFDM Docker Image / create-release (push) Has been skipped
This commit is contained in:
@@ -0,0 +1,64 @@
|
||||
import { describe, expect, it } from "vitest";
|
||||
import { repos } from "@cfdm/db";
|
||||
import { buildApp } from "../src/app.js";
|
||||
import { loadConfig } from "../src/config.js";
|
||||
|
||||
async function authHeaders(app: Awaited<ReturnType<typeof buildApp>>) {
|
||||
const config = loadConfig();
|
||||
const res = await app.inject({
|
||||
method: "POST",
|
||||
url: "/api/v1/auth/login",
|
||||
payload: { username: config.adminUsername, password: "admin" },
|
||||
});
|
||||
expect(res.statusCode).toBe(200);
|
||||
const { token } = res.json() as { token: string };
|
||||
return { authorization: `Bearer ${token}` };
|
||||
}
|
||||
|
||||
describe("services reorder", () => {
|
||||
it("PATCH /services/reorder persists order within group and ungrouped", async () => {
|
||||
const app = await buildApp({
|
||||
config: { ...loadConfig(), staticDir: null },
|
||||
memory: true,
|
||||
});
|
||||
const headers = await authHeaders(app);
|
||||
|
||||
const group = repos.createServiceGroup(app.db, "VPN", "vpn", null, null);
|
||||
const alpha = repos.createService(app.db, "Alpha", "alpha");
|
||||
const beta = repos.createService(app.db, "Beta", "beta");
|
||||
const gamma = repos.createService(app.db, "Gamma", "gamma");
|
||||
|
||||
repos.setServiceGroup(app.db, alpha.id, group.id);
|
||||
repos.setServiceGroup(app.db, beta.id, group.id);
|
||||
|
||||
const reorderRes = await app.inject({
|
||||
method: "PATCH",
|
||||
url: "/api/v1/services/reorder",
|
||||
headers,
|
||||
payload: {
|
||||
group_id: group.id,
|
||||
service_ids: [beta.id, alpha.id],
|
||||
},
|
||||
});
|
||||
expect(reorderRes.statusCode).toBe(200);
|
||||
|
||||
const grouped = repos.listServicesByGroup(app.db, group.id);
|
||||
expect(grouped.map((s) => s.id)).toEqual([beta.id, alpha.id]);
|
||||
|
||||
const ungroupedReorderRes = await app.inject({
|
||||
method: "PATCH",
|
||||
url: "/api/v1/services/reorder",
|
||||
headers,
|
||||
payload: {
|
||||
group_id: null,
|
||||
service_ids: [gamma.id],
|
||||
},
|
||||
});
|
||||
expect(ungroupedReorderRes.statusCode).toBe(200);
|
||||
|
||||
const ungrouped = repos.listUngroupedServices(app.db);
|
||||
expect(ungrouped[0]?.id).toBe(gamma.id);
|
||||
|
||||
await app.close();
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user