Skip to content

feat(test): Add unit test for fedify node#299

Merged
dahlia merged 8 commits into
fedify-dev:mainfrom
dodok8:dodok8-fix-issue-259
Jul 16, 2025
Merged

feat(test): Add unit test for fedify node#299
dahlia merged 8 commits into
fedify-dev:mainfrom
dodok8:dodok8-fix-issue-259

Conversation

@dodok8
Copy link
Copy Markdown
Contributor

@dodok8 dodok8 commented Jul 16, 2025

Target Area

Add unit test for fedify node

Motivation

This is part of issue #259, to add tests to fedify/cli

Risk Assessment

I changed the logic of rgbTo256Color() to pass tests, so it may produce different color results after merge.

Acceptance Criteria

All newly added tests must pass.

Optional Benchmark or Coverage Info

The checkTerminalTrueColorSupport() function was excluded from testing since its return value varies depending on the terminal emulator being used.

Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Summary of Changes

Hello @dodok8, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request introduces comprehensive unit tests for the fedify node module, fulfilling a part of issue #259 to enhance test coverage for the fedify/cli components. The changes involve adding a new test file, incorporating necessary testing dependencies, and exporting previously internal functions to make them testable. A notable adjustment was made to the rgbTo256Color function's logic to ensure it correctly maps colors to the 256-color terminal palette under various conditions, which might subtly alter its output for certain colors.

Highlights

  • Unit Test Introduction: New unit tests have been added for the fedify node module, specifically covering getFaviconUrl, rgbTo256Color, and getAsciiArt functions, as part of the effort to increase test coverage for fedify/cli.
  • Dependency Updates: New testing dependencies (@std/assert for assertions and fetch-mock for network request mocking) have been introduced in cli/deno.json to support the newly added tests.
  • Function Export for Testability: Several previously internal functions (getFaviconUrl, Jimp, rgbTo256Color, getAsciiArt) in cli/node.ts have been exported to make them accessible and testable.
  • rgbTo256Color Logic Refinement: The logic for rgbTo256Color has been updated to improve accuracy in handling grayscale values and mapping RGB colors to the 256-color palette, which the author notes was necessary to pass the new tests and may result in different color outputs.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point in your pull request via creating an issue comment (i.e. comment on the pull request page) using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in issue comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist is currently in preview and may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments to provide feedback.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

@github-actions github-actions Bot added component/cli CLI tools related priority/medium runtime/deno Deno runtime related status/in progress In progress labels Jul 16, 2025
Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

The code changes introduce unit tests for the fedify node command and improve the color mapping logic. The tests are comprehensive, covering various scenarios for getFaviconUrl, rgbTo256Color, and getAsciiArt. The refactoring of rgbTo256Color is a notable improvement in correctness. The review focuses on enhancing the new test code and the refactored function, including suggestions to clean up test code, adhere to naming conventions, increase efficiency, and refactor rgbTo256Color for better performance and maintainability. Overall, these changes increase the project's test coverage and reliability.

Comment thread cli/node.ts
Comment thread cli/node.test.ts Outdated
Comment thread cli/node.test.ts Outdated
Comment thread cli/node.test.ts Outdated
Comment thread cli/node.test.ts Outdated
Comment thread cli/node.test.ts Outdated
Comment thread cli/node.test.ts Outdated
Comment thread cli/node.test.ts
Comment thread cli/node.test.ts
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Jul 16, 2025

The docs for this pull request have been published:

https://c03d8c7a.fedify.pages.dev

@dodok8
Copy link
Copy Markdown
Contributor Author

dodok8 commented Jul 16, 2025

If you have any tests that you think should be added to node.test.ts, please leave a comment.

Copy link
Copy Markdown
Member

@dahlia dahlia left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Everything looks good!

@github-actions
Copy link
Copy Markdown
Contributor

The latest push to this pull request has been published to JSR and npm as a pre-release:

Package Version JSR npm
@fedify/fedify 1.8.0-pr.299.1020+685445c2 JSR npm
@fedify/cli 1.8.0-pr.299.1020+685445c2 JSR
@fedify/amqp 1.8.0-pr.299.1020+685445c2 JSR npm
@fedify/express 1.8.0-pr.299.1020+685445c2 JSR npm
@fedify/h3 1.8.0-pr.299.1020+685445c2 JSR npm
@fedify/postgres 1.8.0-pr.299.1020+685445c2 JSR npm
@fedify/redis 1.8.0-pr.299.1020+685445c2 JSR npm

@dahlia dahlia merged commit bc94dc1 into fedify-dev:main Jul 16, 2025
10 checks passed
@dodok8 dodok8 deleted the dodok8-fix-issue-259 branch July 22, 2025 06:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

component/cli CLI tools related runtime/deno Deno runtime related status/in progress In progress

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants