-
Notifications
You must be signed in to change notification settings - Fork 0
Feature/folder search #88
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
54 commits
Select commit
Hold shift + click to select a range
b12750a
test(main-processor): add test case for folder wide search helpers
Ashminita28 38c118b
fix(main-processor): validate Os file path
Ashminita28 bc7cd6f
feat(watcher): add unlink and error handler in file watcher
Ashminita28 e617f6a
Merge branch 'dev' into feature/folder-search
Ashminita28 fe62280
feat(main-processor): add debounce timer and its test case
Ashminita28 5fd185d
fix(toc): fix alignment of sidebar contents & deep collapsing
Ashminita28 683374c
fix: fix TOC sidebar auto-collapse logic and matching tests
Ashminita28 91fa58c
test(toc): refactor & toc tests for toc extraction using marked AST
Ashminita28 db4b62a
refactor(toc): update toc extraction from regex methor to marked AST …
Ashminita28 9ff5ed0
test(main-processor): mock electron app in setup
Ashminita28 4deef58
test(main-processor): add recursive depth limit test case
Ashminita28 91ff7cd
refactor(main-processor): add depth limit to avoid stack failures on …
Ashminita28 3a3fab3
test(file): add test for debounce cleanup afer file unwatch
Ashminita28 0e1ac62
feat: replace default vite icon, update prettier ignore, add prepush
Ashminita28 9e186a5
feat(ci): add dependency audit and filesystem vulnerability scan in ci
Ashminita28 c1cf730
refactor(ci): setup pnpm before node
Ashminita28 a0778f2
chore: update package to fix high vulnerabiliy
Ashminita28 bb99e05
test(settings): add validation tests for validate settings
Ashminita28 7f57594
feat(shared): add app settings type and add type module to shared types
Ashminita28 384fcbc
fix(settings): fix setting font size test
Ashminita28 4a93345
feat(settings): add settings ipc handler & functionality in main proc…
Ashminita28 7e815c2
refactor(shared): add settings menu constants & update markdown API
Ashminita28 12498ef
feat(renderer): connect settings feature to renderer
Ashminita28 ffd9cd2
feat(main-processor): add menu missing Theme submenu and dev tools hi…
Ashminita28 5b3f66f
refactor(shared): modify ipc type for menu event
Ashminita28 ca53017
feat(renderer): add os theme detection & connect theme submenu to ren…
Ashminita28 1873167
fix(export): fix embedding image issue
Ashminita28 83ac13a
fix: code rabbit issues
Ashminita28 8fed99d
feat: add unsigned install notice
Ashminita28 3b16643
fix(ci): change pnpm version and add secific version to security
Ashminita28 f325be6
fix(ci): fix pipeline issue by removing defined version of pnpm
Ashminita28 3583cc1
fix(security): update trivy action version
Ashminita28 64b6baf
refactor: modify test folder name
Ashminita28 7472b7b
feat: add folder serach types & props
Ashminita28 6373040
feat(renderer): add folder search menu events
Ashminita28 edc99ea
feat(main-processor): add folder search ipc handler and main processor
Ashminita28 be79e36
feat(renderer): add folder search to search bar component
Ashminita28 ee8ad9b
fix(test): fix name in test file
Ashminita28 c6a18d5
fix: fix error handling and props passing issues
Ashminita28 fe9e236
test: add failure test case
Ashminita28 d29a2a5
fix: menu events hook
Ashminita28 5276c12
refactor(renderer): fix folder search state and TOC handling
Ashminita28 67d9232
test(settings): add test validate all settings fields
Ashminita28 1a442a4
test(export): add temp directory clean up
Ashminita28 f94d8e2
refactor(settings): remove fallback process.cwd()
Ashminita28 039c105
refactor(types): separate default settings type, modify import
Ashminita28 8d58a35
refactor(settings): add keyboard dismissal and focus management
Ashminita28 618b7dd
fix(preload): add constrain onMenuEvent to known menu channels
Ashminita28 952d91e
fix(settings): add atomic writes to prevent settings corruption
Ashminita28 06f2341
fix(search): invalidate pending searches & rename test sentence
Ashminita28 0bad2a8
fix(search): remover folder search UI from depending on document sear…
Ashminita28 2fed732
fix(search): fix folder search query propagation and race conditions
Ashminita28 41c4480
Merge branch 'fix/system-hardening' into feature/folder-search
Ashminita28 4d3fb41
fix: code rabbit issues
Ashminita28 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,8 +1,40 @@ | ||
| node_modules | ||
| dist | ||
| build | ||
| # Dependencies | ||
| node_modules/ | ||
|
|
||
| # Build outputs | ||
| out/ | ||
| dist/ | ||
| build/ | ||
| release/ | ||
| *.tgz | ||
| .vite/ | ||
|
|
||
| # Electron builder | ||
| .cache/ | ||
|
|
||
| # Environment | ||
| .env | ||
| out | ||
| coverage | ||
| release | ||
| .vite/ | ||
| .env.local | ||
| .env.*.local | ||
|
|
||
| # Logs | ||
| *.log | ||
| npm-debug.log* | ||
| pnpm-debug.log* | ||
|
|
||
| # OS artifacts | ||
| .DS_Store | ||
| Thumbs.db | ||
|
|
||
| # IDE | ||
| .vscode/ | ||
| .idea/ | ||
| *.swp | ||
| *.swo | ||
|
|
||
| # Test coverage | ||
| coverage/ | ||
|
|
||
| # Docusaurus | ||
| docs/.docusaurus/ | ||
| docs/build/ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| pnpm test |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,4 +1,9 @@ | ||
| node_modules | ||
| dist | ||
| .next | ||
| build | ||
| build | ||
| out/ | ||
| release/ | ||
| coverage/ | ||
| docs/.docusaurus/ | ||
| docs/build/ |
File renamed without changes.
File renamed without changes.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,48 @@ | ||
| import { describe, it, expect, beforeAll, afterAll } from 'vitest'; | ||
| import { writeFileSync, mkdirSync, rmSync } from 'node:fs'; | ||
| import { join } from 'node:path'; | ||
| import { tmpdir } from 'node:os'; | ||
| import { searchFolder } from '../src/folder-search'; | ||
|
|
||
| const DIR = join(tmpdir(), 'md-search-test'); | ||
|
|
||
| beforeAll(() => { | ||
| mkdirSync(DIR, { recursive: true }); | ||
| writeFileSync(join(DIR, 'README.md'), '# Project\nThis project uses React.\nReact is great.'); | ||
| writeFileSync(join(DIR, 'CHANGELOG.md'), '# Changes\nVersion 1.0 released.'); | ||
| writeFileSync(join(DIR, 'notes.txt'), 'not a markdown file'); | ||
| }); | ||
| afterAll(() => { | ||
| rmSync(DIR, { recursive: true, force: true }); | ||
| }); | ||
|
Ashminita28 marked this conversation as resolved.
|
||
|
|
||
| describe('search folder', () => { | ||
| it('should find matches in .md files and returns results', async () => { | ||
| const results = await searchFolder(DIR, 'React'); | ||
| expect(results.length).toBeGreaterThan(0); | ||
| expect(results.some((r) => r.filePath.endsWith('README.md'))).toBe(true); | ||
| }); | ||
|
|
||
| it('does not search non .md files', async () => { | ||
| const results = await searchFolder(DIR, 'not a markdown'); | ||
| expect(results.every((r) => r.filePath.endsWith('.md'))).toBe(true); | ||
| }); | ||
|
|
||
| it('should return empty array when query matches nothing', async () => { | ||
| const results = await searchFolder(DIR, 'xyznotfound'); | ||
| expect(results).toHaveLength(0); | ||
| }); | ||
|
|
||
| it('has search case insensitive', async () => { | ||
| const lower = await searchFolder(DIR, 'react'); | ||
| const upper = await searchFolder(DIR, 'REACT'); | ||
| expect(lower.length).toBe(upper.length); | ||
| }); | ||
|
|
||
| it('returns an empty array if the directory does not exist', async () => { | ||
| const nonExistentDir = join(DIR, 'does-not-exist-folder'); | ||
|
|
||
| const results = await searchFolder(nonExistentDir, 'React'); | ||
| expect(results).toEqual([]); | ||
| }); | ||
| }); | ||
|
Ashminita28 marked this conversation as resolved.
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,22 @@ | ||
| import { describe, expect, it } from 'vitest'; | ||
| import { mkdtemp, mkdir, writeFile } from 'node:fs/promises'; | ||
| import { join } from 'node:path'; | ||
| import { tmpdir } from 'node:os'; | ||
| import { getFolder } from '../src/folder'; | ||
|
|
||
| describe('folder reader testing', async () => { | ||
| it('should enforce the recursion depth', async () => { | ||
| const root = await mkdtemp(join(tmpdir(), 'markdown-reader-folder-')); | ||
| let current = root; | ||
| for (let index = 0; index < 12; index += 1) { | ||
| current = join(current, `level-${index}`); | ||
| await mkdir(current); | ||
| await writeFile(join(current, `file-${index}.md`), '# test', 'utf-8'); | ||
| } | ||
|
|
||
| const tree = await getFolder(root, 2); | ||
| const first = tree.children?.find((child) => child.isDir); | ||
| const second = first?.children?.find((child) => child.isDir); | ||
| expect(second?.children).toEqual([]); | ||
| }); | ||
|
Ashminita28 marked this conversation as resolved.
|
||
| }); | ||
File renamed without changes.
File renamed without changes.
7 changes: 1 addition & 6 deletions
7
apps/main-processor/tests/recent.test.ts → apps/main-processor/__tests__/recent.test.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,60 @@ | ||
| import { describe, expect, it } from 'vitest'; | ||
| import { validateSettings } from '../src/utils/helper/setting-helper'; | ||
| import { READING_WIDTHS } from '../src/utils/constants/setting-constants'; | ||
| import { THEMES } from '@package/shared-constants'; | ||
| describe('settings validation', () => { | ||
| it('accepts valid settings', () => { | ||
| expect(validateSettings({ fontSize: 18 })).toEqual({ fontSize: 18 }); | ||
| }); | ||
|
|
||
| it('rejects unknown keys', () => { | ||
| expect(() => validateSettings({ unexpected: true } as never)).toThrow('Unknown settings key'); | ||
| }); | ||
|
|
||
| it('rejects invalid values', () => { | ||
| expect(() => validateSettings({ fontSize: 100 })).toThrow('Invalid fontSize'); | ||
| }); | ||
|
|
||
| it('validates theme values', () => { | ||
| expect(validateSettings({ theme: THEMES[0] })).toEqual({ theme: THEMES[0] }); | ||
| expect(() => validateSettings({ theme: 'unknown-theme' as never })).toThrow('Invalid theme'); | ||
| }); | ||
|
|
||
| it('validates readingWidth values', () => { | ||
| expect(READING_WIDTHS.has('default')).toBe(true); | ||
| expect(validateSettings({ readingWidth: 'default' })).toEqual({ readingWidth: 'default' }); | ||
| expect(() => validateSettings({ readingWidth: 'full' as never })).toThrow( | ||
| 'Invalid readingWidth' | ||
| ); | ||
| }); | ||
|
|
||
| it('validates boolean settings', () => { | ||
| expect(validateSettings({ lineNumbers: true })).toEqual({ lineNumbers: true }); | ||
| expect(validateSettings({ showHiddenFiles: false })).toEqual({ showHiddenFiles: false }); | ||
| expect(() => validateSettings({ lineNumbers: 'yes' as never })).toThrow('Invalid lineNumbers'); | ||
| expect(() => validateSettings({ showHiddenFiles: 'no' as never })).toThrow( | ||
| 'Invalid showHiddenFiles' | ||
| ); | ||
| }); | ||
|
|
||
| it('validates customCss values', () => { | ||
| expect(validateSettings({ customCss: '.markdown-body { color: red; }' })).toEqual({ | ||
| customCss: '.markdown-body { color: red; }', | ||
| }); | ||
| expect(() => validateSettings({ customCss: 42 as never })).toThrow('Invalid customCss'); | ||
| }); | ||
|
|
||
| it('validates zoom range', () => { | ||
| expect(validateSettings({ zoom: 50 })).toEqual({ zoom: 50 }); | ||
| expect(validateSettings({ zoom: 200 })).toEqual({ zoom: 200 }); | ||
| expect(() => validateSettings({ zoom: 49 })).toThrow('Invalid zoom'); | ||
| expect(() => validateSettings({ zoom: 201 })).toThrow('Invalid zoom'); | ||
| }); | ||
|
|
||
| it('validates recentFilesLimit range', () => { | ||
| expect(validateSettings({ recentFilesLimit: 1 })).toEqual({ recentFilesLimit: 1 }); | ||
| expect(validateSettings({ recentFilesLimit: 50 })).toEqual({ recentFilesLimit: 50 }); | ||
| expect(() => validateSettings({ recentFilesLimit: 0 })).toThrow('Invalid recentFilesLimit'); | ||
| expect(() => validateSettings({ recentFilesLimit: 51 })).toThrow('Invalid recentFilesLimit'); | ||
| }); | ||
| }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,8 @@ | ||
| import { vi } from 'vitest'; | ||
|
|
||
| vi.mock('electron', () => ({ | ||
| app: { | ||
| isPackaged: false, | ||
| getPath: vi.fn(), | ||
| }, | ||
| })); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.