Reorganize repo structure and standards references
This commit is contained in:
1 parent
3cb93a81be
commit
be2054274d
5885 files changed
+2588
-195
No files matched your search
@@ -0,0 +1,69 @@
|
||||
import { existsSync, readFileSync } from "node:fs";
|
||||
import { resolve } from "node:path";
|
||||
import { describe, expect, it } from "vitest";
|
||||
import {
|
||||
ALL_SEARCH_INDEXES,
|
||||
BULK_REINDEX_SUPPORTED_INDEXES,
|
||||
BULK_REINDEX_SUPPORTED_INDEX_NAMES,
|
||||
crmContactsIndex,
|
||||
usersIndex,
|
||||
getSearchIndexSchema,
|
||||
kbArticlesIndex,
|
||||
rowsIndex,
|
||||
} from "./index.js";
|
||||
|
||||
describe("search index catalog", () => {
|
||||
it("declares tenantId as a filterable attribute on every index", () => {
|
||||
for (const schema of ALL_SEARCH_INDEXES) {
|
||||
expect(schema.filterableAttributes).toContain("tenantId");
|
||||
}
|
||||
});
|
||||
|
||||
it("includes tenantId in the allowed document fields", () => {
|
||||
for (const schema of ALL_SEARCH_INDEXES) {
|
||||
expect(schema.allowedDocumentFields).toContain("tenantId");
|
||||
expect(schema.allowedDocumentFields).toContain(schema.primaryKey);
|
||||
}
|
||||
});
|
||||
|
||||
it("exposes every schema via getSearchIndexSchema", () => {
|
||||
for (const schema of ALL_SEARCH_INDEXES) {
|
||||
expect(getSearchIndexSchema(schema.name)).toBe(schema);
|
||||
}
|
||||
});
|
||||
|
||||
it("returns undefined for unknown index names", () => {
|
||||
expect(getSearchIndexSchema("does-not-exist")).toBeUndefined();
|
||||
});
|
||||
|
||||
it("limits bulk-reindex support to indexes with registered pagers", () => {
|
||||
expect([...BULK_REINDEX_SUPPORTED_INDEX_NAMES]).toEqual([
|
||||
kbArticlesIndex.name,
|
||||
crmContactsIndex.name,
|
||||
rowsIndex.name,
|
||||
usersIndex.name,
|
||||
]);
|
||||
expect(BULK_REINDEX_SUPPORTED_INDEXES.map((schema) => schema.name)).toEqual([
|
||||
...BULK_REINDEX_SUPPORTED_INDEX_NAMES,
|
||||
]);
|
||||
});
|
||||
|
||||
it("keeps every supported bulk-reindex name in the search catalog", () => {
|
||||
for (const name of BULK_REINDEX_SUPPORTED_INDEX_NAMES) {
|
||||
expect(getSearchIndexSchema(name)?.name).toBe(name);
|
||||
}
|
||||
});
|
||||
|
||||
it("keeps operator docs explicit about the current bulk-reindex scope", () => {
|
||||
const featureDocs = readRepoFile("docs/features/search.md");
|
||||
expect(featureDocs).toContain("`kb-articles`, `crm-contacts`, `rows`, and `users`");
|
||||
expect(featureDocs).toMatch(/Entities still require\s+a dedicated bulk pager/);
|
||||
});
|
||||
});
|
||||
|
||||
function readRepoFile(path: string): string {
|
||||
const candidates = [resolve(process.cwd(), path), resolve(process.cwd(), "../..", path)];
|
||||
const found = candidates.find((candidate) => existsSync(candidate));
|
||||
if (!found) throw new Error(`Could not find ${path} from ${process.cwd()}`);
|
||||
return readFileSync(found, "utf8");
|
||||
}
|
||||
Reference in new issue
Block a user