Skip to content

Add unit tests for the tool functions of replace_tool and special page configuration - #60

Open
kanasimi wants to merge 1 commit into
masterfrom
devin/1784937197-unit-tests
Open

Add unit tests for the tool functions of replace_tool and special page configuration#60
kanasimi wants to merge 1 commit into
masterfrom
devin/1784937197-unit-tests

Conversation

@kanasimi

Copy link
Copy Markdown
Owner

Summary

The repo had no test infrastructure at all (no test script, no framework, no CI), so coverage was 0% for every file. Only two files are require()-able modules rather than one-shot bot scripts — replace/replace_tool.js and special page configuration.js — so this adds a node:test suite (no new dependencies) covering their pure tool functions: 41 tests, all offline.

  • npm testnode --test test/, npm run test:coverage → same with --experimental-test-coverage.
  • test/helper.js loads wiki loader.js the way the bot scripts do, and creates wiki configuration.js from the sample when missing, so tests run on a fresh clone without credentials.
  • replace/replace_tool.js: exported the already-pure helpers (convert_special_move_to, unshift_move_configuration, normalize_page_title_token, remove_slash_tail, text_processor_for_search, text_processor_for_exturlusage) so they can be tested; no behavioral change to the exports used by task files.
  • Added .gitignore for node_modules/, package-lock.json and the private wiki configuration.js.

One real bug found while testing text_processor_for_exturlusage: the URL pattern was built from a normal string, so '\W' collapsed to the literal W and URLs were only replaced at the very start of the wikitext (i.e. see [http://old.example.com/page] was left untouched).

-new RegExp('(^|\W)' + CeL.to_RegExp_pattern(move_from_link), 'g')
+new RegExp('(^|\\W)' + CeL.to_RegExp_pattern(move_from_link), 'g')

Not covered (needs a live wiki session): get_all_sections, main_move_process, parse_move_pairs_from_page and the rest of the API-driven flow. Those would need an injectable session/HTTP mock to be testable.

Link to Devin session: https://app.devin.ai/sessions/7b5c7d5e46cc4ce39db5e8d0cc5839a1
Requested by: @kanasimi

…nfiguration

Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
@kanasimi kanasimi self-assigned this Jul 24, 2026
@devin-ai-integration

Copy link
Copy Markdown

🤖 Devin AI Engineer

I'll be helping with this pull request! Here's what you should know:

✅ I will automatically:

  • Address comments on this PR. Add '(aside)' to your comment to have me ignore it.
  • Look at CI failures and help fix them

Note: I can only respond to comments from users who have write access to this repository.

⚙️ Control Options:

  • Disable automatic comment, CI, and merge conflict monitoring

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant