FN-7003: stabilize core test fixture state
Stabilize @fusion/core tests by resetting stale plugin-store database handles and aligning fixture assertions. - Add a PluginStore close method that disposes local and central database connections. - Reset the lazy plugin store before the shared test harness clears global settings storage. - Cover plugin-store reopening from the built-in workflow harness. - Assert the runtime FN task-prefix fallback without requiring serialized defaults. Files changed: packages/core/src/__tests__/builtin-workflows.test.ts | 6 ++++++ packages/core/src/__tests__/store-test-helpers.ts | 8 ++++++++ packages/core/src/__tests__/test-project.test.ts | 8 +++++++- packages/core/src/plugin-store.ts | 12 ++++++++++++ 4 files changed, 33 insertions(+), 1 deletion(-) Fusion-Task-Id: FN-7003 Fusion-Task-Lineage: ec4d6e45-61ea-4e6a-b296-3af3acf7ba4b
This commit is contained in:
@@ -549,6 +549,12 @@ describe("built-in workflows", () => {
|
||||
expect(await store.getWorkflowDefinition("builtin:compound-engineering")).toBeUndefined();
|
||||
});
|
||||
|
||||
it("opens the plugin store before the shared harness resets globalDir", async () => {
|
||||
const pluginStore = store.getPluginStore();
|
||||
await pluginStore.init();
|
||||
expect(await pluginStore.listPlugins()).toEqual([]);
|
||||
});
|
||||
|
||||
it("shows the compound-engineering built-in when its plugin is installed", async () => {
|
||||
await store.getPluginStore().registerPlugin({
|
||||
manifest: {
|
||||
|
||||
@@ -94,6 +94,14 @@ function resetMockPassThroughs() {
|
||||
}
|
||||
|
||||
async function resetStoreFilesystem(rootDir: string, globalDir: string, store: TaskStore): Promise<void> {
|
||||
/*
|
||||
* FNXC:CoreTests 2026-06-25-03:32:
|
||||
* The shared harness reuses a TaskStore while clearing globalDir between tests.
|
||||
* Close and null the lazy PluginStore first so its file-backed central DB never survives after fusion-central.db is removed.
|
||||
*/
|
||||
(store as any).pluginStore?.close?.();
|
||||
(store as any).pluginStore = null;
|
||||
|
||||
const fusionDir = store.getFusionDir();
|
||||
await clearDirectoryContents(join(fusionDir, "tasks"));
|
||||
await clearDirectoryContents(join(fusionDir, "task-documents"));
|
||||
|
||||
@@ -44,8 +44,12 @@ describe("test-project fixture", () => {
|
||||
const configRaw = await readFile(join(fixture.rootDir, ".fusion", "config.json"), "utf-8");
|
||||
const config = JSON.parse(configRaw);
|
||||
expect(config.nextId).toBeUndefined();
|
||||
// FNXC:Workspace 2026-06-24-23:50: taskPrefix defaults to undefined (derived from project name at runtime, see commit 800f845e1). The "FN" fallback is applied in store.ts createTask, not persisted in config.json.
|
||||
/*
|
||||
* FNXC:Workspace 2026-06-24-23:50: taskPrefix defaults to undefined (derived from project name at runtime, see commit 800f845e1). The "FN" fallback is applied in store.ts createTask, not persisted in config.json.
|
||||
* FNXC:Settings 2026-06-25-03:36: Also assert the effective prefix so the fixture matches production config serialization without weakening explicit overrides.
|
||||
*/
|
||||
expect(config.settings.taskPrefix).toBeUndefined();
|
||||
expect(config.settings.taskPrefix ?? "FN").toBe("FN");
|
||||
|
||||
const tasks = await fixture.store.listTasks();
|
||||
expect(tasks).toHaveLength(0);
|
||||
|
||||
@@ -129,6 +129,18 @@ export class PluginStore extends EventEmitter<PluginStoreEvents> {
|
||||
return this._centralDb;
|
||||
}
|
||||
|
||||
/**
|
||||
* FNXC:Plugins 2026-06-25-03:31:
|
||||
* Shared test harnesses clear the file-backed global settings directory between tests while reusing one TaskStore.
|
||||
* Dispose both plugin database handles first so future plugin access reopens a fresh central DB instead of writing through a connection whose backing file was removed.
|
||||
*/
|
||||
close(): void {
|
||||
this._localDb?.close();
|
||||
this._localDb = null;
|
||||
this._centralDb?.close();
|
||||
this._centralDb = null;
|
||||
}
|
||||
|
||||
async init(): Promise<void> {
|
||||
const _ = this.localDb;
|
||||
const __ = this.centralDb;
|
||||
|
||||
Reference in New Issue
Block a user