mirror of
https://github.com/shishantbiswas/bknd.git
synced 2026-03-16 12:37:20 +00:00
* fix strategy forms handling, add register route and hidden fields Refactored strategy forms to include hidden fields for type and name. Added a registration route with necessary adjustments to the admin controller and routes. Corrected field handling within relevant forms and components. * fix admin access permissions and refactor routing structure display a fixed error for unmet permissions when retrieving the schema. moved auth routes outside of BkndProvider and reorganized remaining routes to include BkndWrapper. * fix: properly type BkndWrapper * bump fix release version * ModuleManager: update diff checking and AppData validation Revised diff handling includes validation of diffs, reverting changes on failure, and enforcing module constraints with onBeforeUpdate hooks. Introduced `validateDiffs` and backup of stable configs. Applied changes in related modules, tests, and UI layer to align with updated diff logic. * fix: cli: running from config file were using invalid args * fix: cli: improve sequence of onBuilt trigger to allow custom routes from cli * fix e2e tests
52 lines
1.6 KiB
TypeScript
52 lines
1.6 KiB
TypeScript
import { beforeEach, describe, expect, test } from "bun:test";
|
|
import { parse } from "../../src/core/utils";
|
|
import { fieldsSchema } from "../../src/data/data-schema";
|
|
import { AppData, type ModuleBuildContext } from "../../src/modules";
|
|
import { makeCtx, moduleTestSuite } from "./module-test-suite";
|
|
import * as proto from "data/prototype";
|
|
|
|
describe("AppData", () => {
|
|
moduleTestSuite(AppData);
|
|
|
|
let ctx: ModuleBuildContext;
|
|
beforeEach(() => {
|
|
ctx = makeCtx();
|
|
});
|
|
|
|
test("field config construction", () => {
|
|
expect(parse(fieldsSchema, { type: "text" })).toBeDefined();
|
|
});
|
|
|
|
test("should prevent multi-deletion of entities in single request", async () => {
|
|
const schema = proto.em({
|
|
one: proto.entity("one", {
|
|
text: proto.text(),
|
|
}),
|
|
two: proto.entity("two", {
|
|
text: proto.text(),
|
|
}),
|
|
three: proto.entity("three", {
|
|
text: proto.text(),
|
|
}),
|
|
});
|
|
const check = () => {
|
|
const expected = ["one", "two", "three"];
|
|
const fromConfig = Object.keys(data.config.entities ?? {});
|
|
const fromEm = data.em.entities.map((e) => e.name);
|
|
expect(fromConfig).toEqual(expected);
|
|
expect(fromEm).toEqual(expected);
|
|
};
|
|
|
|
// auth must be enabled, otherwise default config is returned
|
|
const data = new AppData(schema.toJSON(), ctx);
|
|
await data.build();
|
|
check();
|
|
|
|
expect(data.schema().remove("entities")).rejects.toThrow(/more than one entity/);
|
|
check();
|
|
|
|
await data.setContext(makeCtx()).build();
|
|
check();
|
|
});
|
|
});
|