diff --git a/features/stepDefinitions/wiki.ts b/features/stepDefinitions/wiki.ts index 9c3e8da2..fe1bc8a2 100644 --- a/features/stepDefinitions/wiki.ts +++ b/features/stepDefinitions/wiki.ts @@ -969,14 +969,16 @@ When('I create a new wiki workspace with name {string}', async function(this: Ap // Construct the full wiki path const wikiPath = path.join(getWikiTestRootPath(this), workspaceName); - // Create the wiki folder using the template + // Create the wiki folder using the template (same filter as createWiki in wiki/index.ts) const templatePath = path.join(process.cwd(), 'template', 'wiki'); - await fs.copy(templatePath, wikiPath); - - // Remove the copied .git directory from the template to start fresh - const gitPath = path.join(wikiPath, '.git'); - await fs.remove(gitPath).catch(() => { - // Ignore if .git doesn't exist + await fs.copy(templatePath, wikiPath, { + filter: (source: string) => { + // Skip .git folder + if (source.endsWith('.git')) return false; + // Skip template's tidgi.config.json so new wiki gets a clean name + if (path.basename(source) === 'tidgi.config.json') return false; + return true; + }, }); // Initialize fresh git repository for the new wiki using dugite diff --git a/src/services/wiki/plugin/watchFileSystemAdaptor/__tests__/FileSystemAdaptor.routing.test.ts b/src/services/wiki/plugin/watchFileSystemAdaptor/__tests__/FileSystemAdaptor.routing.test.ts index a60f1069..32883bf7 100644 --- a/src/services/wiki/plugin/watchFileSystemAdaptor/__tests__/FileSystemAdaptor.routing.test.ts +++ b/src/services/wiki/plugin/watchFileSystemAdaptor/__tests__/FileSystemAdaptor.routing.test.ts @@ -1,8 +1,12 @@ import { workspace } from '@services/wiki/wikiWorker/services'; import type { IWikiWorkspace } from '@services/workspaces/interface'; +import path from 'path'; import type { IFileInfo, Tiddler, Wiki } from 'tiddlywiki'; import { beforeEach, describe, expect, it, vi } from 'vitest'; import { FileSystemAdaptor } from '../FileSystemAdaptor'; + +// path.resolve makes paths absolute; on Windows '/test/wiki/tiddlers' becomes 'C:\test\wiki\tiddlers' +const RESOLVED_TIDDLERS_PATH = path.resolve('/test/wiki/tiddlers'); // @ts-expect-error TS2459: Module declares 'matchTiddlerToWorkspace' locally, but it is not exported. Ignore: TiddlyWiki uses exports.xxx style. import { isWikiWorkspaceWithRouting, matchTiddlerToWorkspace } from '../routingUtilities'; @@ -104,7 +108,7 @@ describe('FileSystemAdaptor - Routing Logic', () => { expect(mockUtils.generateTiddlerFileInfo).toHaveBeenCalledWith( tiddler, expect.objectContaining({ - directory: '/test/wiki/tiddlers', + directory: RESOLVED_TIDDLERS_PATH, pathFilters: undefined, wiki: mockWiki, }), @@ -180,7 +184,7 @@ describe('FileSystemAdaptor - Routing Logic', () => { it('should return existing fileInfo with overwrite flag when file is in correct directory', async () => { const existingFileInfo: IFileInfo = { - filepath: '/test/wiki/tiddlers/old.tid', // Already in the correct tiddlers directory + filepath: path.join(RESOLVED_TIDDLERS_PATH, 'old.tid'), // Already in the correct tiddlers directory type: 'application/x-tiddler', hasMetaFile: false, }; @@ -395,7 +399,7 @@ describe('FileSystemAdaptor - Routing Logic', () => { expect(mockUtils.generateTiddlerFileInfo).toHaveBeenCalledWith( tiddler, expect.objectContaining({ - directory: '/test/wiki/tiddlers', + directory: RESOLVED_TIDDLERS_PATH, }), ); }); @@ -615,7 +619,7 @@ describe('FileSystemAdaptor - Routing Logic', () => { expect(mockUtils.generateTiddlerFileInfo).toHaveBeenCalledWith( tiddler, expect.objectContaining({ - directory: '/test/wiki/tiddlers', + directory: RESOLVED_TIDDLERS_PATH, }), ); }); @@ -719,7 +723,7 @@ describe('FileSystemAdaptor - Routing Logic', () => { expect(mockUtils.generateTiddlerFileInfo).toHaveBeenCalledWith( tiddler, expect.objectContaining({ - directory: '/test/wiki/tiddlers', + directory: RESOLVED_TIDDLERS_PATH, }), ); });