Skip to content

test: Add unit test for projects/app/src/pages/api/core/dataset/detail.ts #4823

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

gru-agent[bot]
Copy link
Contributor

@gru-agent gru-agent bot commented May 15, 2025

Trigger Info

Trigger Type Triggered By Source Pull Request Assignment
PR Created dreamer6680 4822 Detail

Summary

This PR introduces the following changes:

  1. Export handler Function:

    • The handler function in detail.ts is now explicitly exported to facilitate testing.
  2. Unit Tests for Dataset Detail API:

    • Added a new test file detail.test.ts to cover the functionality of the handler function in detail.ts.

    • Tests include:

      • Validation for missing dataset ID.

      • Handling of non-website datasets, ensuring proper transformation and inclusion of mocked models.

      • Handling of website datasets, including status retrieval and error handling.

  3. Mocking Dependencies:

    • Mocked the following modules to isolate and test the handler function:

      • @fastgpt/service/support/permission/dataset/auth

      • @fastgpt/service/core/dataset/websiteSync

      • @fastgpt/service/core/ai/model

  4. Binary and Map Files:

    • Added binary and map files related to pnpm in the v8-compile-cache directory. These appear to be related to the build or runtime environment.

Coverage

The change in coverage value, such as: 0% -> 50%, indicates that the coverage was 0% before writing the tests and 50% after writing them.

https://web.dev/articles/ta-code-coverage

Type Change
lines 0% -> 100% 🔺
functions 0% -> 100% 🔺
statements 0% -> 100% 🔺
branches 0% -> 100% 🔺
source program

Test Statuses

Status Change
passed 0 -> 3 🔺
failed 0 -> 0
skipped 0 -> 0
source program

Tip

You can @gru-agent and leave your feedback. TestGru will make adjustments based on your input

Tip

You can @gru-agent rebase to rebase the PR.

Tip

You can @gru-agent redo to reset or rebase before redoing the PR.

Tip

To modify the test code yourself, click here Edit Test Code

@gru-agent gru-agent bot mentioned this pull request May 15, 2025
Copy link

Preview sandbox Image: ghcr.io/labring/fastgpt-pr:fatsgpt_sandbox_ed90a32a38f84ea9b930a4012932135c1aeb6469

Copy link

github-actions bot commented May 15, 2025

Coverage Report

Status Category Percentage Covered / Total
🔵 Lines 22.28% 11480 / 51508
🔵 Statements 22.28% 11480 / 51508
🔵 Functions 29.02% 303 / 1044
🔵 Branches 66.02% 787 / 1192
File Coverage
File Stmts Branches Functions Lines Uncovered Lines
Changed Files
projects/app/src/pages/api/core/dataset/detail.ts 100% 100% 100% 100%
Generated in workflow #884 for commit 75b44e1 by the Vitest Coverage Report Action

Copy link

Preview mcp_server Image: ghcr.io/labring/fastgpt-pr:fatsgpt_mcp_server_ed90a32a38f84ea9b930a4012932135c1aeb6469

Copy link

Preview fastgpt Image: ghcr.io/labring/fastgpt-pr:fatsgpt_ed90a32a38f84ea9b930a4012932135c1aeb6469

@gru-agent gru-agent bot force-pushed the gru/projects-app-src-pages-api-core-dataset-detail-ts-1747306685224 branch from ed90a32 to 75b44e1 Compare May 17, 2025 14:50
@gru-agent gru-agent bot mentioned this pull request May 17, 2025
Copy link

Preview sandbox Image: ghcr.io/labring/fastgpt-pr:fatsgpt_sandbox_75b44e1bbc0d31e0c9e8f66573fbcc00adf44292

Copy link

Preview mcp_server Image: ghcr.io/labring/fastgpt-pr:fatsgpt_mcp_server_75b44e1bbc0d31e0c9e8f66573fbcc00adf44292

Copy link

Preview fastgpt Image: ghcr.io/labring/fastgpt-pr:fatsgpt_75b44e1bbc0d31e0c9e8f66573fbcc00adf44292

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

0 participants