mirror of
https://github.com/tiddly-gittly/TidGi-Desktop.git
synced 2026-03-09 08:20:32 -07:00
fix: exclude tidgi.config.json from e2e template copy and fix unit test paths for cross-platform
This commit is contained in:
parent
b070896923
commit
b39bd0ea19
2 changed files with 18 additions and 12 deletions
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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,
|
||||
}),
|
||||
);
|
||||
});
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue