Skip to content

test(workflow): improve dataset item tests with edit and remove functionality#33937

Merged
hyoban merged 4 commits intomainfrom
fix/test-datasetItem
Mar 23, 2026
Merged

test(workflow): improve dataset item tests with edit and remove functionality#33937
hyoban merged 4 commits intomainfrom
fix/test-datasetItem

Conversation

@CodingOnStar
Copy link
Contributor

Important

  1. Make sure you have read our contribution guidelines
  2. Ensure there is an associated issue and you have been assigned to it
  3. Use the correct syntax to link this PR: Fixes #<issue number>.

Summary

test(workflow): improve dataset item tests with edit and remove functionality

  • Enhanced integration tests for the DatasetItem component to verify editing and removing dataset items.
  • Updated test cases to utilize userEvent and waitFor for better async handling.
  • Added aria-labels and data-testid attributes to action buttons for improved accessibility and testing.

Checklist

  • This change requires a documentation update, included: Dify Document
  • I understand that this PR may be closed in case there was no previous discussion or issues. (This doesn't apply to typos!)
  • I've added a test for each change that was introduced, and I tried as much as possible to make a single atomic change.
  • I've updated the documentation accordingly.
  • I ran make lint and make type-check (backend) and cd web && npx lint-staged (frontend) to appease the lint gods

…ionality

- Enhanced integration tests for the DatasetItem component to verify editing and removing dataset items.
- Updated test cases to utilize userEvent and waitFor for better async handling.
- Added aria-labels and data-testid attributes to action buttons for improved accessibility and testing.
@CodingOnStar CodingOnStar requested a review from lyzno1 March 23, 2026 09:58
@CodingOnStar CodingOnStar requested a review from iamjoel as a code owner March 23, 2026 09:58
Copilot AI review requested due to automatic review settings March 23, 2026 09:58
@CodingOnStar CodingOnStar requested a review from zxhlyh as a code owner March 23, 2026 09:58
@dosubot dosubot bot added the size:M This PR changes 30-99 lines, ignoring generated files. label Mar 23, 2026
@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello, 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 enhances the integration tests for the DatasetItem component by adding specific tests for editing and removing dataset items. It also improves the test's async handling and adds accessibility attributes.

Highlights

  • Enhanced DatasetItem Tests: Improved integration tests for the DatasetItem component, focusing on verifying editing and removing dataset items.
  • Asynchronous Handling: Updated test cases to utilize userEvent and waitFor for better asynchronous handling of UI interactions.
  • Accessibility and Testing: Added aria-labels and data-testid attributes to action buttons, enhancing accessibility and making tests more robust.

🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console.

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 by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

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 pull request 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 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. If you're interested in giving your feedback about your experience with Gemini Code Assist for GitHub and other Google products, sign up here.

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 the web This relates to changes on the web. label Mar 23, 2026
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Improves the workflow “knowledge-retrieval” frontend test suite around dataset item interactions, while also making the DatasetItem action buttons more accessible and easier to target in tests.

Changes:

  • Added aria-label and data-testid attributes to the DatasetItem edit/remove action buttons.
  • Refined integration tests to separately verify “edit” and “remove” flows using userEvent, within, and waitFor.
  • Introduced a small test helper (getDatasetItem) to reduce repeated DOM traversal logic.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
web/app/components/workflow/nodes/knowledge-retrieval/components/dataset-item.tsx Adds accessible names and stable test selectors to icon-only action buttons.
web/app/components/workflow/nodes/knowledge-retrieval/__tests__/integration.spec.tsx Updates dataset item integration tests to target edit/remove actions more explicitly and handle async updates more reliably.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Copy link
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

This pull request improves the integration tests for the DatasetItem component by splitting a large test into two more focused ones and using more robust queries. It also enhances accessibility by adding aria-labels to action buttons. My review focuses on further improving the test robustness and cleaning up redundant test attributes. I've suggested refining the helper function for querying the DOM to be less brittle and removing unused data-testid attributes since the tests now correctly use accessibility labels for selection.

…nd removal

- Updated the MockSettingsModal to use useEffect and useRef for improved state management during tests.
- Simplified test cases by removing unnecessary userEvent setup and mouseOver events.
- Enhanced clarity and maintainability of the integration tests for dataset item operations.
lyzno1
lyzno1 previously approved these changes Mar 23, 2026
@dosubot dosubot bot added the lgtm This PR has been approved by a maintainer label Mar 23, 2026
…omponent

- Updated the resize timer and chart ready timer to use clearer cleanup functions.
- Refactored the debounced resize and chart ready handling to enhance performance and prevent memory leaks.
- Added console error and warning spies in tests for better error handling during component testing.
Copilot AI review requested due to automatic review settings March 23, 2026 10:25
@CodingOnStar CodingOnStar requested a review from hyoban as a code owner March 23, 2026 10:25
@dosubot dosubot bot added size:L This PR changes 100-499 lines, ignoring generated files. and removed size:M This PR changes 30-99 lines, ignoring generated files. labels Mar 23, 2026
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 4 out of 4 changed files in this pull request and generated 3 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@codecov
Copy link

codecov bot commented Mar 23, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 77.90%. Comparing base (6be7ba2) to head (b3fba90).
⚠️ Report is 2 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main   #33937   +/-   ##
=======================================
  Coverage   77.90%   77.90%           
=======================================
  Files        4578     4578           
  Lines      181219   181238   +19     
  Branches    35347    35347           
=======================================
+ Hits       141179   141197   +18     
- Misses      36794    36795    +1     
  Partials     3246     3246           
Flag Coverage Δ
web 79.62% <100.00%> (+<0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@hyoban hyoban merged commit 8b6fc07 into main Mar 23, 2026
24 checks passed
@hyoban hyoban deleted the fix/test-datasetItem branch March 23, 2026 12:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

lgtm This PR has been approved by a maintainer size:L This PR changes 100-499 lines, ignoring generated files. web This relates to changes on the web.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants